emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] xwidget_mvp 2f7b194 4/4: upstream merge


From: Joakim Verona
Subject: [Emacs-diffs] xwidget_mvp 2f7b194 4/4: upstream merge
Date: Thu, 22 Oct 2015 21:17:07 +0000

branch: xwidget_mvp
commit 2f7b194667e998dd2bf330d74c7d35c8bdb7c2ae
Merge: 67ef998 d4352f8
Author: Joakim Verona <address@hidden>
Commit: Joakim Verona <address@hidden>

    upstream merge
---
 .gitignore                            |    1 +
 ChangeLog.2                           |  596 ++++++++++++++++++++++++++++++++-
 admin/FOR-RELEASE                     |    2 +
 configure.ac                          |    2 +-
 doc/emacs/ack.texi                    |    3 +-
 doc/emacs/dired.texi                  |   12 +-
 doc/lispref/elisp.texi                |    1 +
 doc/lispref/files.texi                |    7 +-
 doc/lispref/internals.texi            |    9 +
 doc/lispref/minibuf.texi              |    3 +
 doc/lispref/numbers.texi              |   17 +-
 doc/lispref/os.texi                   |  104 ++++++
 doc/lispref/processes.texi            |    4 +-
 doc/lispref/sequences.texi            |   19 +
 doc/misc/htmlfontify.texi             |   77 ++---
 doc/misc/texinfo.tex                  |  194 +++++++----
 doc/misc/tramp.texi                   |   26 +-
 etc/HISTORY                           |  204 +++++++++++
 etc/NEWS                              |   19 +-
 lib-src/ChangeLog.1                   |    2 +-
 lib-src/ebrowse.c                     |   84 +++--
 lib-src/etags.c                       |   27 ++-
 lib/binary-io.c                       |    1 +
 lib/c-ctype.h                         |  531 +++--------------------------
 lib/stdalign.in.h                     |    5 +-
 lib/time_rz.c                         |    9 +-
 lib/u64.c                             |    1 +
 lib/unistd.c                          |    1 +
 lisp/ChangeLog.17                     |    4 +-
 lisp/ChangeLog.5                      |    2 +-
 lisp/cedet/semantic/senator.el        |    2 +-
 lisp/color.el                         |   18 +-
 lisp/custom.el                        |   14 +-
 lisp/dired-aux.el                     |  224 +++++++++----
 lisp/dired-x.el                       |   49 ++--
 lisp/dired.el                         |   17 +-
 lisp/doc-view.el                      |   23 +-
 lisp/emacs-lisp/bytecomp.el           |    4 +-
 lisp/emacs-lisp/cl-extra.el           |    2 +-
 lisp/emacs-lisp/eldoc.el              |    1 +
 lisp/emacs-lisp/map.el                |   10 +-
 lisp/emacs-lisp/package.el            |   10 +
 lisp/emacs-lisp/seq.el                |   26 ++-
 lisp/faces.el                         |   11 +-
 lisp/files.el                         |   21 +-
 lisp/frame.el                         |   25 ++-
 lisp/gnus/mailcap.el                  |   37 +--
 lisp/gnus/nnmail.el                   |    9 +-
 lisp/gnus/nnml.el                     |   27 ++-
 lisp/hexl.el                          |    2 +-
 lisp/image.el                         |    2 +-
 lisp/info.el                          |    6 +-
 lisp/isearch.el                       |  184 ++++++-----
 lisp/menu-bar.el                      |    8 +-
 lisp/minibuffer.el                    |   11 +-
 lisp/mpc.el                           |  129 ++++++--
 lisp/net/eww.el                       |   22 +-
 lisp/net/shr-color.el                 |    6 +-
 lisp/net/shr.el                       |    2 +-
 lisp/net/tramp-adb.el                 |    1 +
 lisp/net/tramp-compat.el              |    6 -
 lisp/net/tramp-gvfs.el                |    7 +-
 lisp/net/tramp-sh.el                  |   12 +-
 lisp/net/tramp.el                     |    7 +-
 lisp/obsolete/longlines.el            |    2 +-
 lisp/obsolete/vc-arch.el              |    4 -
 lisp/progmodes/js.el                  |   13 +-
 lisp/replace.el                       |    4 +-
 lisp/select.el                        |    2 +-
 lisp/server.el                        |   13 +-
 lisp/subr.el                          |    6 +-
 lisp/textmodes/reftex.el              |   26 ++-
 lisp/vc/vc-bzr.el                     |    1 -
 lisp/vc/vc-cvs.el                     |    2 -
 lisp/vc/vc-dir.el                     |    2 +-
 lisp/vc/vc-git.el                     |   10 +-
 lisp/vc/vc-hg.el                      |    2 -
 lisp/vc/vc-mtn.el                     |    4 -
 lisp/vc/vc-svn.el                     |    4 -
 lwlib/lwlib-widget.h                  |    4 +-
 m4/gnulib-common.m4                   |   43 ++-
 m4/gnulib-comp.m4                     |    5 +-
 nt/INSTALL                            |    4 +
 src/ChangeLog.3                       |    2 +-
 src/alloc.c                           |   62 ++--
 src/atimer.c                          |    1 -
 src/buffer.c                          |    5 +-
 src/buffer.h                          |    8 +
 src/callint.c                         |    2 -
 src/callproc.c                        |    7 +-
 src/casetab.c                         |    1 -
 src/category.c                        |    2 -
 src/category.h                        |    6 +
 src/ccl.h                             |    2 -
 src/character.c                       |    1 -
 src/character.h                       |    1 +
 src/charset.c                         |    1 -
 src/charset.h                         |    1 +
 src/chartab.c                         |    1 -
 src/cm.c                              |    2 -
 src/cm.h                              |    5 +
 src/cmds.c                            |    2 -
 src/coding.c                          |    2 -
 src/coding.h                          |    2 +
 src/commands.h                        |    6 +
 src/composite.c                       |    3 +-
 src/data.c                            |   14 +-
 src/dbusbind.c                        |    1 -
 src/decompress.c                      |    1 -
 src/dired.c                           |    3 -
 src/dispnew.c                         |    7 +-
 src/disptab.h                         |    7 +
 src/doc.c                             |    2 +-
 src/editfns.c                         |    2 +-
 src/emacs.c                           |    4 +-
 src/emacsgtkfixed.h                   |    2 +
 src/fileio.c                          |    3 +-
 src/filelock.c                        |    2 -
 src/fns.c                             |   13 +-
 src/font.c                            |    6 +-
 src/font.h                            |    5 +-
 src/fontset.c                         |    6 -
 src/fontset.h                         |    4 +
 src/frame.c                           |  228 ++++++++-----
 src/frame.h                           |   15 +-
 src/fringe.c                          |    1 -
 src/ftcrfont.c                        |    5 -
 src/ftfont.c                          |    4 -
 src/ftxfont.c                         |    4 -
 src/gfilenotify.c                     |    2 -
 src/gnutls.h                          |    2 +
 src/gtkutil.c                         |   48 ++--
 src/gtkutil.h                         |    1 -
 src/image.c                           |   19 +-
 src/indent.c                          |    2 -
 src/indent.h                          |    7 +
 src/inotify.c                         |    2 -
 src/insdel.c                          |    2 +-
 src/intervals.c                       |    2 -
 src/intervals.h                       |    7 +-
 src/keyboard.c                        |    4 +-
 src/keyboard.h                        |    6 +-
 src/keymap.c                          |    2 -
 src/keymap.h                          |    2 +
 src/lisp.h                            |    6 -
 src/lread.c                           |    3 +-
 src/macros.c                          |    3 -
 src/macros.h                          |    6 +
 src/menu.c                            |    3 +-
 src/menu.h                            |    1 -
 src/minibuf.c                         |   12 +-
 src/nsfns.m                           |   26 ++-
 src/nsterm.m                          |   16 +-
 src/print.c                           |    9 +-
 src/process.c                         |    4 -
 src/process.h                         |    5 +
 src/puresize.h                        |    7 +
 src/regex.h                           |    1 +
 src/region-cache.c                    |    1 -
 src/region-cache.h                    |    5 +
 src/scroll.c                          |    2 -
 src/search.c                          |    2 -
 src/sheap.c                           |   11 +-
 src/sound.c                           |    1 -
 src/syntax.c                          |    3 -
 src/syntax.h                          |    8 +
 src/sysdep.c                          |    4 +-
 src/sysselect.h                       |    2 +
 src/syssignal.h                       |    5 +
 src/sysstdio.h                        |    5 +
 src/systime.h                         |    4 +-
 src/systty.h                          |    7 +
 src/term.c                            |    6 -
 src/termchar.h                        |    6 +
 src/termhooks.h                       |    3 +
 src/terminal.c                        |    3 +-
 src/termopts.h                        |    4 +
 src/textprop.c                        |    1 -
 src/tparam.h                          |    4 +
 src/undo.c                            |    3 -
 src/unexcw.c                          |    2 +-
 src/unexec.h                          |    3 +
 src/unexsol.c                         |    2 -
 src/w32.c                             |   10 +-
 src/w32console.c                      |   19 +-
 src/w32fns.c                          |  215 ++++---------
 src/w32font.c                         |   21 +-
 src/w32heap.c                         |    2 +-
 src/w32inevt.c                        |    6 +-
 src/w32menu.c                         |   17 +-
 src/w32proc.c                         |   20 +-
 src/w32reg.c                          |    6 +-
 src/w32select.c                       |    8 +-
 src/w32term.c                         |   47 +--
 src/w32uniscribe.c                    |    5 -
 src/w32xfns.c                         |    8 +-
 src/widget.c                          |  208 ++----------
 src/widget.h                          |    2 +
 src/widgetprv.h                       |    1 -
 src/window.c                          |    3 -
 src/xdisp.c                           |   26 ++-
 src/xfaces.c                          |    4 -
 src/xfns.c                            |   47 ++-
 src/xfont.c                           |    3 -
 src/xftfont.c                         |    3 -
 src/xgselect.c                        |    3 +-
 src/xgselect.h                        |    3 +-
 src/xmenu.c                           |   40 ++-
 src/xml.c                             |    1 -
 src/xrdb.c                            |    5 -
 src/xselect.c                         |    4 -
 src/xsettings.h                       |    4 +
 src/xsmfns.c                          |    2 -
 src/xterm.c                           |   72 ++--
 test/automated/coding-tests.el        |    2 +-
 test/automated/file-notify-tests.el   |   21 +-
 test/automated/seq-tests.el           |    9 +
 test/automated/tabulated-list-test.el |    2 +-
 test/indent/js.js                     |    7 +
 219 files changed, 2764 insertions(+), 1916 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1e2f206..7f023b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@
 # Built by 'autogen.sh'.
 /aclocal.m4
 /configure
+build-aux/ar-lib
 build-aux/compile
 build-aux/config.guess
 build-aux/config.sub
diff --git a/ChangeLog.2 b/ChangeLog.2
index 9e04ab0..8c30a11 100644
--- a/ChangeLog.2
+++ b/ChangeLog.2
@@ -1,3 +1,597 @@
+2015-10-18  Michael Albinus  <address@hidden>
+
+       Minor edits in Tramp
+
+       * lisp/net/tramp-adb.el (directory-listing-before-filename-regexp):
+       Declare it.
+
+       * lisp/net/tramp-compat.el (directory-listing-before-filename-regexp):
+       Remove declaration.
+
+2015-10-17  Mark Oteiza  <address@hidden>
+
+       * lisp/emacs-lisp/eldoc.el: Add back-to-indentation to the command list
+
+2015-10-17  Eli Zaretskii  <address@hidden>
+
+       Avoid crashes when redisplayng a window changes faces or fonts
+
+       * src/xdisp.c (redisplay_internal): If redisplaying the selected
+       window or one of the frames turns on the frame's 'redisplay' flag,
+       redisplay again.  (Bug#21428)
+
+       * src/frame.c (x_set_font): Set the frame's 'fonts_changed' flag.
+
+2015-10-17  Michael Albinus  <address@hidden>
+
+       Solve timimg issues in file-notify-tests.el
+
+       * test/automated/file-notify-tests.el (file-notify-test02-events):
+       Rectify `attribute-change' tests.  There are timing issues with
+       gfilenotify.  (Bug#21669)
+
+2015-10-16  Paul Eggert  <address@hidden>
+
+       Fix quoting of data within htmlfontify doc
+
+       * doc/misc/htmlfontify.texi (Data Structures, Customization):
+       Fix quoting of data structures.  A Lisp quote is needed only
+       when data appears within Lisp code.
+
+2015-10-16  Artur Malabarba  <address@hidden>
+
+       * emacs-lisp/package.el: Reload archive-contents if priorities change
+
+       (package--old-archive-priorities): New variable.
+       (package-read-all-archive-contents, package-menu--refresh): Use it
+       to decide when the `package-archive-contents' needs to be read
+       again.
+
+2015-10-16  Paul Eggert  <address@hidden>
+
+       Make src headers idempotent and standalone
+
+       Redo src/*.h so that each include file is idempotent (that is, can
+       be included multiple times with the latter inclusions having no
+       effect) and standalone (that is, can be included by itself,
+       with no include file other than config.h needed as a prerequisite).
+       This is standard practice in GNU programs nowadays.
+       * lwlib/lwlib-widget.h, src/buffer.h, src/category.h, src/character.h:
+       * src/charset.h, src/coding.h, src/commands.h, src/disptab.h:
+       * src/fontset.h, src/gnutls.h, src/indent.h, src/keymap.h, src/macros.h:
+       * src/regex.h [emacs]:
+       * src/syntax.h, src/systty.h, src/termhooks.h:
+       Include lisp.h, for Lisp_Object.
+       * src/buffer.h, src/category.h, src/cm.h, src/commands.h, src/disptab.h:
+       * src/indent.h, src/intervals.h, src/keyboard.h, src/macros.h:
+       * src/process.h, src/puresize.h, src/region-cache.h, src/syntax.h:
+       * src/syssignal.h, src/sysstdio.h, src/systty.h, src/termchar.h:
+       * src/termopts.h, src/tparam.h, src/unexec.h:
+       Protect against multiple inclusion.
+       * src/buffer.h: Include character.h, for STRING_CHAR.
+       * src/emacsgtkfixed.h (struct frame):
+       * src/fontset.h (struct face):
+       * src/region-cache.h (struct buffer):
+       * src/termhooks.h (struct glyph):
+       * src/xsettings.h (struct x_display_info):
+       Add possibly-forward decl.
+       * src/syntax.h: Include buffer.h, for BVAR.
+       * src/sysselect.h: Include lisp.h, for eassume.
+       * src/termchar.h: Include <stdio.h>, for FILE.
+       * src/widget.h: Include <X11/IntrinsicP.h>, for Widget.
+       * src/xsettings.h: Include <X11/Xlib.h>, for XEvent.
+
+2015-10-16  Jürgen Hötzel  <address@hidden>
+
+       Handle symlink targets containing spaces in tramp-gvfs.el
+
+       * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-attributes):
+       Handle symlink targets containing spaces.
+
+2015-10-16  Artur Malabarba  <address@hidden>
+
+       * custom.el (custom-theme-load-path): Demote to defvar
+
+       `custom-theme-load-path' was a defcustom, but it shouldn't be for the
+       same reason that `load-path' shouldn't.  Setting it via the customize
+       interface is a trap for the user.
+
+       Installed themes commonly add themselves to this variable, which means
+       its value is not fit for being saved (it will permanently remember dirs
+       that don't exist anymore).
+
+       This is aggravated by the fact that Emacs always applies the `user'
+       theme on top of any theme that's loaded, since this will apply the old
+       variable value and remove any new directories that had been recently
+       added by themes themselves.
+
+       Not to mention, we already have `custom-theme-directory', which is safe
+       to customize.
+
+2015-10-16  Stefan Monnier  <address@hidden>
+
+       * lisp/mpc.el: Rename the new toggling commands
+
+       (mpc-toggle-consume, mpc-toggle-repeat, mpc-toggle-single)
+       (mpc-toggle-shuffle): Add "-toggle" in the name.
+
+2015-10-16  Eli Zaretskii  <address@hidden>
+
+       Improve the doc string of 'completion-boundaries'
+
+       * lisp/minibuffer.el (completion-boundaries): Rename the argument
+       TABLE to COLLECTION, for consistency with other high-level
+       completion functions.  Document how COLLECTION is called if it
+       is a function.  (Bug#21644)
+
+2015-10-16  Oleh Krehel  <address@hidden>
+
+       lisp/dired-aux.el (dired-shell-command): Fix compile warning
+
+2015-10-16  Oleh Krehel  <address@hidden>
+
+       Make dired-do-compress work for *.zip files
+
+       * lisp/dired-aux.el (dired-check-process): Transform the top-level
+         comment into a docstring.
+       (dired-shell-command): New command. This mirrors
+       `dired-check-process', but is more user-friendly for passing
+       arguments.
+       (dired-compress-file-suffixes): Allow to specify the command switches
+       along with input (%i) and output (%o) inside the PROGRAM part.
+       Add an entry for *.zip files, and update the entry for *.tar.gz files
+       to the new style. Update the docstring.
+       (dired-compress-file): When PROGRAM matches %i or %o, use the new
+       logic.
+       (dired-update-file-line): Avoid an error when at end of buffer.
+
+       Fixes Bug#21637
+
+2015-10-16  Eli Zaretskii  <address@hidden>
+
+       Minor improvement in documentation of internals
+
+       * doc/lispref/internals.texi (Writing Emacs Primitives): Document QUIT.
+
+2015-10-16  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of COLLECTION in completion functions
+
+       * doc/lispref/minibuf.texi (Minibuffer Completion): Add a
+       cross-reference to "Programmed Completion".
+
+       * src/minibuf.c (Fcompleting_read): Improve the doc string.
+       (Bug#21644)
+
+2015-10-16  Eli Zaretskii  <address@hidden>
+
+       Add more release info to etc/HISTORY
+
+       * etc/HISTORY: Add more release information about 19.x and 20.x
+       versions.
+
+2015-10-15  Paul Eggert  <address@hidden>
+
+       New file etc/HISTORY
+
+       * admin/FOR-RELEASE: Procedure for etc/HISTORY.
+       * etc/HISTORY: New file.
+       * etc/NEWS: Mention it.
+
+2015-10-15  Dmitry Gutov  <address@hidden>
+
+       js-mode: Don't misindent generator methods
+
+       * lisp/progmodes/js.el (js--looking-at-operator-p): Distinguish
+       generator methods from multiplication operator
+       (https://github.com/mooz/js2-mode/issues/275).
+
+2015-10-15  Paul Eggert  <address@hidden>
+
+       Fix animation timeout delay calculation
+
+       * lisp/image.el (image-animate-timeout):
+       Don’t assume speed is floating-point.
+
+2015-10-15  Mark Oteiza  <address@hidden>
+
+       Add commands for controlling MPD modes
+
+       * lisp/mpc.el (mpc-cmd-consume, mpc-cmd-random, mpc-cmd-repeat)
+       (mpc-cmd-single): New functions.
+       (mpc-consume, mpc-repeat, mpc-single, mpc-shuffle): New commands.
+       (mpc-mode-menu): Add new commands as menu items.
+
+2015-10-15  Dmitry Gutov  <address@hidden>
+
+       Refer to `(elisp)Basic Completion' in completing-read docstring
+
+       * src/minibuf.c (Fcompleting_read): Refer to `(elisp)Basic
+       Completion' in the docstring (bug#21644).
+
+2015-10-14  Mark Oteiza  <address@hidden>
+
+       * lisp/mpc.el (mpc-format): Always push form to pred
+
+2015-10-14  Paul Eggert  <address@hidden>
+
+       Spelling fixes
+
+       * configure.ac (bitmapdir): Fix misspelling of bmd_acc.
+       * test/automated/coding-tests.el (ert-test-coding-bogus-coding-systems):
+       Fix misspelling of nonexistent file name.
+
+2015-10-14  Mark Oteiza  <address@hidden>
+
+       * lisp/mpc.el (mpc-mode-menu, mpc-toggle-play): Fix docstrings
+
+2015-10-14  Michael Albinus  <address@hidden>
+
+       Some editing fixes in Tramp
+
+       * lisp/net/tramp-gvfs.el:
+       * doc/misc/tramp.texi: "customer option" -> "custom option".
+
+       * lisp/net/tramp.el (tramp-completion-function-alist): Fix docstring.
+
+2015-10-14  Jürgen Hötzel  <address@hidden>
+
+       Use proper localization in tramp-gvfs.el
+
+       * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-attributes):
+       Suppress localized settings in order to proper parse gfvs output.
+
+2015-10-14  Warren Lynn  <address@hidden>  (tiny change)
+
+       Fix Bug#21562
+
+       * lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band):
+       Quote argument in proper order.  (Bug#21562)
+
+2015-10-14  Nicolas Petton  <address@hidden>
+
+       Fix typos in docstrings
+
+       * lisp/emacs-lisp/map.el:
+       * lisp/emacs-lisp/seq.el: Fix typos in the docstrings of the pcase
+         macros.
+
+2015-10-14  Mark Oteiza  <address@hidden>
+
+       * lisp/mpc.el (mpc-volume-refresh): Check if buffer is live.
+
+2015-10-14  Oleh Krehel  <address@hidden>
+
+       Make dired-jump work with tar-subfile-mode
+
+       * lisp/dired-x.el (dired-jump): When in `tar-subfile-mode', instead of
+         emitting an error, switch to `tar-superior-buffer'.
+
+2015-10-14  Juanma Barranquero  <address@hidden>
+
+       * .gitignore: Add build-aux/ar-lib.
+
+2015-10-14  Nicolas Petton  <address@hidden>
+
+       Better docstrings in seq.el and map.el
+
+       * lisp/emacs-lisp/map.el:
+       * lisp/emacs-lisp/seq.el: Improve the docstring for the pcase patterns.
+
+2015-10-14  Paul Eggert  <address@hidden>
+
+       Merge from gnulib
+
+       This incorporates:
+       2015-10-13 binary-io, u64, unistd: port to strict C
+       2015-09-26 c-ctype: do not worry about EBCDIC + char signed
+       2015-09-25 c-ctype: port better to z/OS EBCDIC
+       2015-09-25 gnulib-common.m4: fix gl_PROG_AR_RANLIB/AM_PROG_AR clash
+       * doc/misc/texinfo.tex, lib/binary-io.c, lib/c-ctype.h, lib/u64.c:
+       * lib/unistd.c, m4/gnulib-common.m4, m4/gnulib-comp.m4:
+       Copy from gnulib.
+
+2015-10-14  Paul Eggert  <address@hidden>
+
+       Take XPNTR private
+
+       * src/alloc.c (PURE_POINTER_P): Remove.
+       All uses replaced with PURE_P.
+       (XPNTR_OR_SYMBOL_OFFSET): New function.
+       (XPNTR): Move here from lisp.h.
+       Reimplement in terms of XPNTR_OR_SYMBOL_OFFSET.
+       (mark_maybe_object, valid_lisp_object_p, survives_gc_p):
+       Remove unnecessary cast.
+       (purecopy): Use XPNTR_OR_SYMBOL_OFFSET instead of XPNTR,
+       to avoid an unnecessary runtime test for symbols.
+       * src/lisp.h (lisp_h_XPNTR, XPNTR): Remove, moving XPNTR to alloc.c.
+       Only alloc.c needs XPNTR now.
+
+2015-10-13  Mark Oteiza  <address@hidden>
+
+       Add MPC play/pause command
+
+       * lisp/mpc.el (mpc-toggle-play): New command.
+       (mpc-mode-map): Bind it to "s".
+       (mpc-mode-menu): Add corresponding menu item.
+
+2015-10-13  Mark Oteiza  <address@hidden>
+
+       Add bindings and menu items for prev and next tracks
+
+       * lisp/mpc.el (mpc-mode-map): Bind ">" to mpc-next,
+       "<" to mpc-prev.
+       (mpc-mode-menu): Add corresponding menu items
+
+2015-10-13  Ken Raeburn  <address@hidden>
+
+       Reduce face-related consing during frame creation.
+
+       * faces.el (face--attributes-unspecified): Compute the "unspecified"
+       attribute list once.
+       (face-spec-reset-face): Use it instead of building the list.
+
+2015-10-13  Ken Raeburn  <address@hidden>
+
+       Do process ConfigureNotify events indicating size changes.
+
+       * src/xterm.c (handle_one_xevent): If consecutive ConfigureNotify
+       events don't have the same size, process each one.
+
+2015-10-13  Mark Oteiza  <address@hidden>
+
+       Derive mpc-mode from special-mode
+
+       lisp/mpc.el (mpc-mode-map): Make from sparse keymap. Unbind g.
+       (mpc-mode): Derive from special mode.
+       (mpc-songs-mode-map): Don't set parent keymap.
+
+2015-10-13  Mark Oteiza  <address@hidden>
+
+       Fix error messages for when covers are not found.
+
+       The last change to mpc-format let the binding to file call
+       mpc-file-local-copy with nil argument. Instead, employ if-let here so
+       nil bindings don't result in needless computation and errors.
+       * lisp/mpc.el: Require 'subr-x at compile time.
+       * lisp/mpc.el (mpc-format): Use if-let.
+
+2015-10-13  Oleh Krehel  <address@hidden>
+
+       Make dired-do-compress work for *.tar.gz files
+
+       * lisp/dired-aux.el (dired-compress-file-suffixes): Associate
+         "tar -zxvf" to *.tar.gz; update docstring.
+
+       (dired-compress-file): Allow to specify switches after the command in
+       `dired-compress-file-suffixes'.
+
+2015-10-13  Oleh Krehel  <address@hidden>
+
+       Make dired-do-compress work for directories
+
+       * lisp/dired-aux.el (dired-compress-file): When FILE is a directory,
+         instead of emitting an error, call "tar -czf FILE.tar.gz FILE".
+       Also convert the top comment into a docstring.
+
+2015-10-13  Stefan Monnier  <address@hidden>
+
+       * lisp/mpc.el (mpc-songs-refresh): Don't side-effect `active'
+
+       ... since it might come straight from the memoizing table.
+
+2015-10-13  Juanma Barranquero  <address@hidden>
+
+       * src/w32fns.c (x_change_tool_bar_height): Remove unused variable frame.
+
+2015-10-13  Mark Oteiza  <address@hidden>
+
+       Use special-mode in eww list modes
+
+       * lisp/net/eww.el (eww-bookmark-mode, eww-history-mode)
+       (eww-buffers-mode): Derive from special-mode and remove redundant
+       setting of buffer-read-only.
+       (eww-mode-map): Remove redundant keymap parent setting.
+       (eww-bookmark-mode-map, eww-history-mode-map, eww-buffers-mode-map):
+       Remove redundant keymap suppressions and mappings.
+
+2015-10-13  Martin Rudalics  <address@hidden>
+
+       Allow setting frame pixel sizes from frame parameters (Bug#21415)
+
+       Also fix some misfeatures in frame (re-)sizing code, add more
+       debugging information and remove some dead code.
+
+       * lisp/frame.el (frame-notice-user-settings, make-frame): Change
+       parameter names when setting `frame-size-history'.
+       (frame--size-history): New function.
+
+       * src/frame.c (frame_inhibit_resize): If frame has not been made
+       yet, return t if inhibit_horizontal_resize or
+       inhibit_vertical_resize bit have been set.
+       (adjust_frame_size): Simplify.
+       (make_frame): Initialize inhibit_horizontal_resize,
+       inhibit_vertical_resize, tool_bar_redisplayed, tool_bar_resized.
+       (Fframe_after_make_frame): Reset inhibit_horizontal_resize and
+       inhibit_vertical_resize slots.
+       (x_set_frame_parameters): Handle `text-pixels' specification for
+       width and height parameters.  Don't consider new_height or
+       new_width changes.  Call adjust_frame_size instead of
+       Fset_frame_size.
+       (x_figure_window_size): Two new arguments x_width and y_width
+       returning frame's figures width and height.  Calculate tool bar
+       height before frame sizes so SET_FRAME_HEIGHT can pick it up.
+       Handle `text-pixels' specification for width and height
+       parameters.
+       (Qtext_pixels, Qx_set_frame_parameters, Qset_frame_size)
+       (Qx_set_window_size_1, Qx_set_window_size_2)
+       (Qx_set_window_size_3, Qx_set_menu_bar_lines)
+       (Qupdate_frame_menubar, Qfree_frame_menubar_1)
+       (Qfree_frame_menubar_2): New symbols.
+       * src/frame.h (structure frame): New booleans
+       tool_bar_redisplayed, tool_bar_resized,
+       inhibit_horizontal_resize, inhibit_vertical_resize.
+       (x_figure_window_size): Update external declaration.
+       * src/gtkutil.c (xg_frame_set_char_size): Set size hints before
+       calling gtk_window_resize.
+       (update_frame_tool_bar): Make inhibiting of frame resizing more
+       discriminative.  Set tool_bar_resized bit.
+       * src/nsfns.m (x_set_tool_bar_lines): Make inhibiting of frame
+       resizing more discriminative.  Call adjust_frame_size instead of
+       x_set_window_size.
+       (Fx_create_frame): Handle x_width and x_height if
+       set by x_figure_window_size.
+       * src/nsterm.m (x_set_window_size): For GNUSTEP build don't
+       subtract 3 from tool bar height.
+       (x_set_window_size): Add frame_size_history_add call.
+       (x_new_font): Call adjust_frame_size instead of
+       x_set_window_size.
+       * src/w32fns.c (x_change_tool_bar_height): Reset
+       tool_bar_redisplayed and tool_bar_resized bits when adding tool
+       bar.  Make inhibiting of frame resizing more discriminative.
+       (w32_wnd_proc): Remove dead code in WM_WINDOWPOSCHANGING case.
+       (Fx_create_frame): Handle x_width and x_height if set by
+       x_figure_window_size.  Set size hints before adjusting frame size.
+       (x_create_tip_frame): Adjust x_figure_window_size call.
+       * src/w32term.c (x_set_window_size): Add frame_size_history_add
+       call.
+       * src/widget.c (set_frame_size): Remove dead code.  Add
+       frame_size_history_add call.  When frame_resize_pixelwise is t
+       use FRAME_PIXEL_WIDTH and FRAME_PIXEL_HEIGHT instead of
+       pixel_width and pixel_height.
+       (update_various_frame_slots): Remove dead code.
+       (EmacsFrameResize): Add more information in
+       frame_size_history_add call.
+       (EmacsFrameQueryGeometry): Round only when frame_resize_pixelwise
+       is not set.
+       * src/xdisp.c (redisplay_tool_bar): Set tool_bar_redisplayed bits.
+       * src/xfns.c (x_set_menu_bar_lines): Change argument name.
+       (x_change_tool_bar_height): Reset tool_bar_redisplayed and
+       tool_bar_resized bits when adding tool bar.  Make inhibiting of
+       frame resizing more discriminative.
+       (Fx_create_frame): Handle x_width and x_height if set by
+       x_figure_window_size.  Set size hints before adjusting frame size.
+       (x_create_tip_frame): Adjust x_figure_window_size call.
+       * src/xmenu.c (update_frame_menubar): Don't handle Lucid specially.
+       (set_frame_menubar): On Lucid never add core-border-width to
+       avoid that adding XtNinternalBorderWidth adds it again.
+       (free_frame_menubar): Handle frame_inhibit_resize true for Motif.
+       * src/xterm.c (x_new_font): In non-toolkit case handle size
+       change of menu bar.
+       (x_set_window_size_1): Fix calls to frame_size_history_add.
+       (x_wm_set_size_hint): Remove dead code.  Set
+       size_hints.min_width and size_hints.min_height to base_width and
+       base_height.
+
+2015-10-13  Michael Albinus  <address@hidden>
+
+       * test/automated/file-notify-tests.el (file-notify--test-timeout):
+
+       Add docstring.  Increase to 10 seconds for remote
+       directories.  (Bug#21669)
+
+2015-10-12  Paul Eggert  <address@hidden>
+
+       Unmacroize ebrowse.c and etags.c a bit
+
+       * lib-src/ebrowse.c (READ_CHUNK_SIZE): Now an enum constant.
+       (streq, filename_eq, set_flag, has_flag): Now inline functions.
+       (set_flag): First arg is now an address, not an lvalue.
+       All callers changed.
+       (filename_eq, set_flag, has_flag):
+       Rename from FILENAME_EQ, SET_FLAG, HAS_FLAG.
+       All callers changed.
+       * lib-src/etags.c (streq, strcaseeq, strneq, strncaseeq):
+       Now inline functions.  Remove asserts that are unnecessary these
+       days (and in some cases were too-generous anyway).
+
+2015-10-12  Mark Oteiza  <address@hidden>
+
+       Use highlight for current items.
+
+       * lisp/mpc.el (mpc-select-make-overlay, mpc-tagbrowser-all-select):
+       Apply highlight face instead of region face.
+
+2015-10-12  Mark Oteiza  <address@hidden>
+
+       Search for more cover image names in MPC
+
+       * lisp/mpc.el (mpc-format): Also look for .folder.jpg or folder.jpg
+       case insensitively
+
+2015-10-12  Juanma Barranquero  <address@hidden>
+
+       Remove or comment out unused variables
+
+       * src/w32fns.c (x_set_mouse_color): Comment out variables cursor,
+       nontext_cursor, mode_cursor, hand_cursor and count.
+       (x_change_tool_bar_height): Remove variable old_text_height.
+       (deliver_wm_chars): Remove variable strip_Alt.
+       (Fw32_shell_execute): Remove variable document_a.
+       (Fw32_frame_geometry): Remove variable fullboth.
+       * src/w32term.c (w32_setup_relief_color): Comment out variable
+       w32_display_info.
+       (w32_horizontal_scroll_bar_handle_click): Remove variables start, end.
+       (w32_read_socket): Comment out variables rows, columns.
+       * src/w32uniscribe.c (uniscribe_check_otf_1): Remove variable rest.
+
+2015-10-12  Juanma Barranquero  <address@hidden>
+
+       * src/w32proc.c (sys_select): Fix bitwise test.
+
+2015-10-12  Eli Zaretskii  <address@hidden>
+
+       Minor typo corrections in doc strings
+
+       * lisp/menu-bar.el (popup-menu, popup-menu-normalize-position):
+       Doc fixes.
+
+2015-10-12  Eli Zaretskii  <address@hidden>
+
+       * nt/INSTALL: Recommend MSYS Automake/Autoconf from ezwinports.
+
+2015-10-12  Eli Zaretskii  <address@hidden>
+
+       Attempt to avoid crashes in plist-member
+
+       * src/fns.c (Fplist_member): Don't call QUIT between a CONSP test
+       and a call to XCDR.  (Bug#21655)
+
+2015-10-12  Mike FABIAN  <address@hidden>
+
+       In gui-get-primary-selection use gui--selection-value-internal 
(Bug#20906)
+
+       * lisp/select.el (gui-get-primary-selection): In 
gui-get-primary-selection
+       use gui--selection-value-internal (Bug#20906)
+
+2015-10-12  Tassilo Horn  <address@hidden>
+
+       Support RTF in doc-view
+
+       * lisp/doc-view.el (doc-view-set-doc-type): Add entry for RTF extension.
+
+2015-10-12  Juanma Barranquero  <address@hidden>
+
+       * w32fns.c (get_wm_chars): Increment counter, not pointer.
+
+2015-10-11  Nicolas Petton  <address@hidden>
+
+       Replace the usage of an obsolete function in auth-source.el
+
+       * lisp/gnus/auth-source.el (auth-source-epa-make-gpg-token): Replace an
+         usage of `epg-context-set-armor' with `setf'.
+
+2015-10-11  Nicolas Petton  <address@hidden>
+
+       * lisp/gnus/auth-source.el: Use sharp-quoting with functions.
+
+2015-10-11  Jay Belanger  <address@hidden>
+
+       Have calc-yank recognize numbers in different bases.
+
+       * lisp/calc/calc-yank.el (math-number-regexp): New function.
+       (calc-yank): Use `math-number-regexp' to recognize numbers.
+
 2015-10-11  Ken Raeburn  <address@hidden>
 
        Handle an opaque-move X11 window manager operation more efficiently.
@@ -15086,7 +15680,7 @@
 
 This file records repository revisions from
 commit 9d56a21e6a696ad19ac65c4b405aeca44785884a (exclusive) to
-commit ce402dd77fe39c3a6d968e23d7a4a20f2b04ccf0 (inclusive).
+commit f8ff3937660f4192d72dec2da31fa5c582434d1f (inclusive).
 See ChangeLog.1 for earlier changes.
 
 ;; Local Variables:
diff --git a/admin/FOR-RELEASE b/admin/FOR-RELEASE
index 327723f..6ecec89 100644
--- a/admin/FOR-RELEASE
+++ b/admin/FOR-RELEASE
@@ -107,6 +107,8 @@ sk  Miroslav Vaško
 ** cusver-check from admin.el can help find new defcustoms missing
 :version tags.
 
+** Add a line to etc/HISTORY for the release version number and date.
+
 * BUGS
 
 ** Check for modes which bind M-s that conflicts with a new global binding M-s
diff --git a/configure.ac b/configure.ac
index ac4d76f..d285c25 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1750,7 +1750,7 @@ else
       bmd_acc="${bmd_acc}:${bmd}/bitmaps"
     fi
   done
-  bitmapdir=${bmdacc#:}
+  bitmapdir=${bmd_acc#:}
 fi
 
 test "${with_ns}" = maybe && test "${opsys}" != darwin && with_ns=no
diff --git a/doc/emacs/ack.texi b/doc/emacs/ack.texi
index 3eac9b3..eebab8a 100644
--- a/doc/emacs/ack.texi
+++ b/doc/emacs/ack.texi
@@ -839,7 +839,8 @@ facility.  He also wrote @code{ebrowse}, the address@hidden 
browser;
 and @file{rx.el}, a regular expression constructor.
 
 @item
-Stefan Monnier was the Emacs (co-)maintainer from Emacs 23 onwards.  He added
+Stefan Monnier was the Emacs (co-)maintainer from Emacs 23 until
+late in the development of 25.1.  He added
 support for Arch and Subversion to VC, re-wrote much of the Emacs server
 to use the built-in networking primitives, and re-wrote the abbrev and
 minibuffer completion code for Emacs 23.  He also wrote @code{PCL-CVS},
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index b00c974..e7e4944 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -722,7 +722,17 @@ suitable guess made using the variables @code{lpr-command} 
and
 @cindex compressing files (in Dired)
 @item Z
 Compress the specified files (@code{dired-do-compress}).  If the file
-appears to be a compressed file already, uncompress it instead.
+appears to be a compressed file already, uncompress it instead.  Each
+marked file is compressed into its own archive.
+
address@hidden dired-do-compress-to
address@hidden c @r{(Dired)}
address@hidden compressing files (in Dired)
address@hidden c
+Compress the specified files (@code{dired-do-compress-to}) into a
+single archive anywhere on the file system. The compression algorithm
+is determined by the extension of the archive, see
address@hidden
 
 @findex epa-dired-do-decrypt
 @kindex :d @r{(Dired)}
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 5ca518e..2d3548f 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -1487,6 +1487,7 @@ Operating System Interface
 * Desktop Notifications::   Desktop notifications.
 * File Notifications::      File notifications.
 * Dynamic Libraries::       On-demand loading of support libraries.
+* Security Considerations:: Running Emacs in an unfriendly environment.
 
 Starting Up Emacs
 
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index db2ecc0..ca8abe5 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -1481,7 +1481,10 @@ in @code{exec-path}, and tries all the file-name 
extensions in
 @cindex setting modes of files
 
   The functions in this section rename, copy, delete, link, and set
-the modes (permissions) of files.
+the modes (permissions) of files.  They all signal a @code{file-error}
+error if they fail to perform their function, reporting the
+system-dependent error message that describes the reason for the
+failure.
 
   In the functions that have an argument @var{newname}, if a file by the
 name of @var{newname} already exists, the actions taken depend on the
@@ -1755,6 +1758,8 @@ time and must be in the format returned by 
@code{current-time}
 This function sets the Emacs-recognized extended file attributes for
 @code{filename}.  The second argument @var{attribute-alist} should be
 an alist of the same form returned by @code{file-extended-attributes}.
+The return value is @code{t} if the attributes are successfully set,
+otherwise it is @code{nil}.
 @xref{Extended Attributes}.
 @end defun
 
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index 20681c0..e620da0 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -660,6 +660,7 @@ usage: (or CONDITIONS...)  */)
       if (!NILP (val))
         break;
       args = XCDR (args);
+      QUIT;
     @}
 @end group
 
@@ -779,6 +780,14 @@ their addresses after performing Lisp evaluation.  Lisp 
evaluation can
 occur via calls to @code{eval_sub} or @code{Feval}, either directly or
 indirectly.
 
address@hidden @code{QUIT}, use in Lisp primitives
+  Note the call to the @code{QUIT} macro inside the loop: this macro
+checks whether the user pressed @kbd{C-g}, and if so, aborts the
+processing.  You should do that in any loop that can potentially
+require a large number of iterations; in this case, the list of
+arguments could be very long.  This increases Emacs responsiveness and
+improves user experience.
+
   You must not use C initializers for static or global variables unless
 the variables are never written once Emacs is dumped.  These variables
 with initializers are allocated in an area of memory that becomes
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 96c1020..0b1a4a9 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -975,6 +975,9 @@ Thus, if @var{predicate} is address@hidden, it should be 
compatible
 with @var{collection} and @code{completion-ignore-case}.
 @xref{Definition of test-completion}.
 
address@hidden Completion}, for detailed requirements when
address@hidden is a function.
+
 The value of the optional argument @var{require-match} determines how
 the user may exit the minibuffer:
 
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi
index 3c70d2f..54c8d3e 100644
--- a/doc/lispref/numbers.texi
+++ b/doc/lispref/numbers.texi
@@ -642,10 +642,11 @@ product.  When given no arguments, @code{*} returns 1.
 @end example
 @end defun
 
address@hidden / dividend divisor &rest divisors
-This function divides @var{dividend} by @var{divisor} and returns the
-quotient.  If there are additional arguments @var{divisors}, then it
-divides @var{dividend} by each divisor in turn.  Each argument may be a
address@hidden / number &rest divisors
+With one or more @var{divisors}, this function divides @var{number}
+by each divisor in @var{divisors} in turn, and returns the quotient.
+With no @var{divisors}, this function returns 1/@var{number}, i.e.,
+the multiplicative inverse of @var{number}.  Each argument may be a
 number or a marker.
 
 If all the arguments are integers, the result is an integer, obtained
@@ -673,6 +674,14 @@ by rounding the quotient towards zero after each division.
      @result{} 2.5
 @end group
 @group
+(/ 4.0)
+     @result{} 0.25
address@hidden group
address@hidden
+(/ 4)
+     @result{} 0
address@hidden group
address@hidden
 (/ 25 3 2)
      @result{} 4
 @end group
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 204055d..1925bd5 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -37,6 +37,7 @@ terminal and the screen.
 * Desktop Notifications:: Desktop notifications.
 * File Notifications::  File notifications.
 * Dynamic Libraries::   On-demand loading of support libraries.
+* Security Considerations:: Running Emacs in an unfriendly environment.
 @end menu
 
 @node Starting Up
@@ -2760,3 +2761,106 @@ be loaded through it.
 This variable is ignored if the given @var{library} is statically
 linked into Emacs.
 @end defvar
+
address@hidden Security Considerations
address@hidden Security Considerations
address@hidden security
address@hidden hardening
+
+Like any application, Emacs can be run in a secure environment, where
+the operating system enforces rules about access and the like.  With
+some care, Emacs-based applications can also be part of a security
+perimeter that checks such rules.  Although the default settings for
+Emacs work well for a typical software development environment, they
+may require adjustment in environments containing untrusted users that
+may include attackers.  Here is a compendium of security issues that
+may be helpful if you are developing such applications.  It is by no
+means complete; it is intended to give you an idea of the security
+issues involved, rather than to be a security checklist.
+
address@hidden @asis
address@hidden Access control
+Although Emacs normally respects access permissions of the underlying
+operating system, in some cases it handles accesses specially.  For
+example, file names can have handlers that treat the files specially,
+with their own access checking.  @xref{Magic File Names}.  Also, a
+buffer can be read-only even if the corresponding file is writeable,
+and vice versa, which can result in messages such as @samp{File passwd
+is write-protected; try to save anyway? (yes or no)}.  @xref{Read Only
+Buffers}.
+
address@hidden Authentication
+Emacs has several functions that deal with passwords, e.g.,
address@hidden  Although these functions do not attempt to
+broadcast passwords to the world, their implementations are not proof
+against determined attackers with access to Emacs internals.  For
+example, even if Elisp code attempts to scrub a password from
+its memory after using it, remnants of the password may still reside
+in the garbage-collected free list.
+
address@hidden Code injection
+Emacs can send commands to many other applications, and applications
+should take care that strings sent as operands of these commands are
+not misinterpreted as directives.  For example, when sending a shell
+command to rename a file @var{a} to @var{b}, do not simply use the
+string @code{mv @var{a} @var{b}}, because either file name might start
+with @samp{-}, or might contain shell metacharacters like @samp{;}.
+Although functions like @code{shell-quote-argument} can help avoid
+this sort of problem, they are not panaceas; for example, on a POSIX
+platform @code{shell-quote-argument} quotes shell metacharacters but
+not leading @samp{-}.  @xref{Shell Arguments}.
+
address@hidden Coding systems
+Emacs attempts to infer the coding systems of the files and network
+connections it accesses.  If it makes a mistake, or if the other
+parties to the network connection disagree with Emacs's deductions,
+the resulting system could be unreliable.  Also, even when it infers
+correctly, Emacs often can use bytes that other programs cannot.  For
+example, although to Emacs the NUL (all bits zero) byte is just a
+character like any other, many other applications treat it as a string
+terminator and mishandle strings or files containing NUL bytes.
+
address@hidden Environment and configuration variables
+POSIX specifies several environment variables that can affect how
+Emacs behaves.  Any environment variable whose name consists entirely
+of uppercase ASCII letters, digits, and the underscore may affect the
+internal behavior of Emacs.  Emacs uses several such variables, e.g.,
address@hidden  @xref{Library Search}.  On some platforms some
+environment variables (e.g., @env{PATH}, @env{POSIXLY_CORRECT},
address@hidden, @env{TMPDIR}) need to have properly-configured values in
+order to get standard behavior for any utility Emacs might invoke.
+Even seemingly-benign variables like @env{TZ} may have security
+implications.
+
+Emacs has customization and other variables with similar
+considerations.  For example, if the variable @code{shell-file-name}
+specifies a shell with nonstandard behavior, an Emacs-based
+application may misbehave.
+
address@hidden Installation
+When Emacs is installed, if the installation directory hierarchy can
+be modified by untrusted users, the application cannot be trusted.
+This applies also to the directory hierarchies of the programs that
+Emacs uses, and of the files that Emacs reads and writes.
+
address@hidden Network access
+Emacs often accesses the network, and you may want to configure it to
+avoid network accesses that it would normally do.  For example, unless
+you set @code{tramp-mode} to @code{nil}, file names using a certain
+syntax are interpreted as being network files, and are retrieved
+across the network.  @xref{Top, The Tramp Manual,, tramp, The Tramp
+Manual}.
+
address@hidden Race conditions
+Emacs applications have the same sort of race-condition issues that
+other applications do.  For example, even when
address@hidden(file-readable-p "foo.txt")} returns @code{t}, it could be that
address@hidden is unreadable because some other program changed the
+file's permissions between the call to @code{file-readable-p} and now.
+
address@hidden Resource limits
+When Emacs exhausts memory or other operating system resources, its
+behavior can be less reliable, in that computations that ordinarily
+run to completion may abort back to the top level.  This may cause
+Emacs to neglect operations that it normally would have done.
address@hidden table
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index 845db0d..0ce696a 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -180,7 +180,7 @@ and then pass it to a shell for execution.
 Precisely what this function does depends on your operating system.  The
 function is designed to work with the syntax of your system's standard
 shell; if you use an unusual shell, you will need to redefine this
-function.
+function.  @xref{Security Considerations}.
 
 @example
 ;; @r{This example shows the behavior on GNU and Unix systems.}
@@ -290,7 +290,7 @@ Here are the possibilities:
 Insert the output in that buffer, before point.  This includes both the
 standard output stream and the standard error stream of the process.
 
address@hidden a string
address@hidden a buffer name (a string)
 Insert the output in a buffer with that name, before point.
 
 @item @code{t}
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi
index 0a6f4c6..8ecae7b 100644
--- a/doc/lispref/sequences.texi
+++ b/doc/lispref/sequences.texi
@@ -743,6 +743,25 @@ it is a function of two arguments to use instead of the 
default @code{equal}.
 
 @end defun
 
address@hidden seq-position sequence elt &optional function
+  This function returns the index of the first element in
address@hidden that 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}.
+
address@hidden
address@hidden
+(seq-position '(a b c) 'b)
address@hidden 1
address@hidden group
address@hidden
+(seq-position '(a b c) 'd)
address@hidden nil
address@hidden group
address@hidden example
address@hidden defun
+
+
 @defun seq-uniq sequence &optional function
   This function returns a list of the elements of @var{sequence} with
 duplicates removed.  If the optional argument @var{function} is address@hidden,
diff --git a/doc/misc/htmlfontify.texi b/doc/misc/htmlfontify.texi
index b14f2d3..1b0afdd 100644
--- a/doc/misc/htmlfontify.texi
+++ b/doc/misc/htmlfontify.texi
@@ -1153,8 +1153,8 @@ An assoc with elements of the form @samp{(face-name 
style-name . style-string)}.
 The actual stylesheet for each page is derived from one of these.
 
 @lisp
-'((default       "default" . "@{ background: black; color: address@hidden")
-  (font-lock-string-face "string"  . "@{ color: rgb(64,224,208) @}"))
+((default       "default" . "@{ background: black; color: address@hidden")
+ (font-lock-string-face "string"  . "@{ color: rgb(64,224,208) @}"))
 @end lisp
 
 @item hfy-facemap-assoc
@@ -1173,24 +1173,24 @@ dealt with (and therefore no longer care about) will be 
invalid at any
 time.
 
 @lisp
-'((64820 . end)
-  (64744 . font-lock-comment-face)
-  (64736 . end)
-  (64722 . font-lock-string-face)
-  (64630 . end)
-  (64623 . font-lock-string-face)
-  (64449 . end)
-  ;; Big similar section elided.  You get the idea.
-  (5459 . end)
-  (5431 . (:inherit font-lock-keyword-face :background "7e7e7e"))
-  (5431 . end)
-  (4285 . font-lock-constant-face)
-  (4285 . end)
-  (4221 . font-lock-comment-face)
-  (4221 . end)
-  (4197 . font-lock-constant-face)
-  (4197 . end)
-  (1 . font-lock-comment-face))
+((64820 . end)
+ (64744 . font-lock-comment-face)
+ (64736 . end)
+ (64722 . font-lock-string-face)
+ (64630 . end)
+ (64623 . font-lock-string-face)
+ (64449 . end)
+ ;; Big similar section elided.  You get the idea.
+ (5459 . end)
+ (5431 . (:inherit font-lock-keyword-face :background "7e7e7e"))
+ (5431 . end)
+ (4285 . font-lock-constant-face)
+ (4285 . end)
+ (4221 . font-lock-comment-face)
+ (4221 . end)
+ (4197 . font-lock-constant-face)
+ (4197 . end)
+ (1 . font-lock-comment-face))
 @end lisp
 
 @end table
@@ -1301,36 +1301,35 @@ access to the face spec you would use if you were 
connected to an X display.
 Some valid class specification elements are:
 
 @lisp
-  '(class      color)
-  '(class      grayscale)
-  '(background dark)
-  '(background light)
-  '(type       x-toolkit)
-  '(type       tty)
-  '(type       motif)
-  '(type       lucid)
+  (class      color)
+  (class      grayscale)
+  (background dark)
+  (background light)
+  (type       x-toolkit)
+  (type       tty)
+  (type       motif)
+  (type       lucid)
 @end lisp
 
 Multiple values for a tag may be combined, to indicate that any one or more
-of these values in the specification key constitutes a match, eg:
+of these values in the specification key constitutes a match.  For
+example, @code{((class color grayscale) (type tty))} would match any of:
 
-'((class color grayscale) (type tty)) would match any of:
 @lisp
-  '((class color))
-  '((class grayscale))
-  '((class color grayscale)))
-  '((class color foo))
-  '((type  tty))
-  '((type  tty) (class color))
+  ((class color))
+  ((class grayscale))
+  ((class color grayscale)))
+  ((class color foo))
+  ((type  tty))
+  ((type  tty) (class color))
 @end lisp
-and so on.
 
 @item hfy-page-header
 @vindex hfy-page-header
 @anchor{hfy-page-header}
 
 Function called with two arguments (the filename relative to the top
-level source directory being etag'd and fontified), and a string containing
+level source directory being etagged and fontified), and a string containing
 the @samp{<style>@dots{}</style>} text to embed in the document---the string
 returned will be used as the header for the htmlfontified version of
 the source file.
@@ -1355,7 +1354,7 @@ be large and take a long time to render or be difficult 
to navigate.
 @vindex hfy-find-cmd
 @anchor{hfy-find-cmd}
 
-``find'' command used to harvest a list of files to attempt to fontify.
+The ``find'' command used to harvest a list of files to attempt to fontify.
 
 @item hfy-extn
 @vindex hfy-extn
diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex
index bff8eb0..c75ddd6 100644
--- a/doc/misc/texinfo.tex
+++ b/doc/misc/texinfo.tex
@@ -3,7 +3,7 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2015-09-20.17}
+\def\texinfoversion{2015-10-17.11}
 %
 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -530,14 +530,13 @@
 %
 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
 
+
+% \parseargdef - define a command taking an argument on the line
+%
 % \parseargdef\foo{...}
 %      is roughly equivalent to
 % \def\foo{\parsearg\Xfoo}
 % \def\Xfoo#1{...}
-%
-% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
-% favourite TeX trick.  --kasal, 16nov03
-
 \def\parseargdef#1{%
   \expandafter \doparseargdef \csname\string#1\endcsname #1%
 }
@@ -1107,6 +1106,7 @@ where each line of input produces a line of output.}
 \newtoks\toksC
 \newtoks\toksD
 \newbox\boxA
+\newbox\boxB
 \newcount\countA
 \newif\ifpdf
 \newif\ifpdfmakepagedest
@@ -1416,6 +1416,7 @@ output) for that.)}
       \normalturnoffactive
       address@hidden@}%
       \let\/=\empty
+      \let\xprocessmacroarg=\eatspaces % in case we are in a macro expansion
       \makevalueexpandable
       % do we want to go so far as to use \indexnofonts instead of just
       % special-casing \var here?
@@ -4605,6 +4606,8 @@ end
 }
 
 % \commondummiesnofonts: common to \commondummies and \indexnofonts.
+% Define \definedumyletter, \definedummyaccent and \definedummyword before
+% using.
 %
 \def\commondummiesnofonts{%
   % Control letters and accents.
@@ -4700,11 +4703,27 @@ end
 {
 \catcode`\<=13
 \catcode`\-=13
+\catcode`\`=13
   \gdef\indexnonalnumdisappear{%
-    \backslashdisappear
-    \def-{}%
-    \def<{}%
-    address@hidden
+    \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
+      % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
+      % (Introduced for FSFS 2nd ed.)
+      \let`=\empty
+    \fi
+    %
+    \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
+      \backslashdisappear
+    \fi
+    %
+    \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
+      \def-{}%
+    \fi
+    \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
+      \def<{}%
+    \fi
+    \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
+      address@hidden
+    \fi
   }
 
   \gdef\indexnonalnumreappear{%
@@ -4728,7 +4747,6 @@ end
   \def\definedummyletter##1{\let##1\empty}%
   % All control words become @asis by default; overrides below.
   \let\definedummyword\definedummyaccent
-  %
   \commondummiesnofonts
   %
   % Don't no-op \tt, since it isn't a user-level command
@@ -4741,8 +4759,6 @@ end
   \def\_{\normalunderscore}%
   \def\-{}% @- shouldn't affect sorting
   %
-  % Unfortunately, texindex < 6.0 is not prepared to handle braces in the
-  % content at all, so these won't be sorted in ASCII order.
   \def\lbracechar{{\indexlbrace}}%
   \def\rbracechar{{\indexrbrace}}%
   \let\{=\lbracechar
@@ -4805,9 +4821,6 @@ end
   \def\result{=>}%
   \def\textdegree{o}%
   %
-  \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax
-  \else \indexlquoteignore \fi
-  %
   % We need to get rid of all macros, leaving only the arguments (if present).
   % Of course this is not nearly correct, but it is the best we can do for now.
   % makeinfo does not expand macros in the argument to @deffn, which ends up
@@ -4821,10 +4834,6 @@ end
   \macrolist
 }
 
-% Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us
-% ignore left quotes in the sort term.
-{\catcode`\`=\active
- \gdef\indexlquoteignore{\let`=\empty}}
 
 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
 
@@ -4864,11 +4873,17 @@ end
 \def\requireopenindexfile#1{%
 \ifnum\csname #1indfile\endcsname=0
   \expandafter\newwrite \csname#1indfile\endcsname
-  \immediate\openout\csname#1indfile\endcsname \jobname.#1 % Open the file
+  \edef\suffix{#1}%
+  % A .fls suffix would conflict with the file extension for the output
+  % of -recorder, so use .f1s instead.
+  \ifx\suffix\indexisfl\def\suffix{f1}\fi
+  % Open the file
+  \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
   % Using \immediate here prevents an object entering into the current box,
   % which could confound checks such as those in \safewhatsit for preceding
   % skips.
 \fi}
+\def\indexisfl{fl}
 
 % Output \ as {\indexbackslash}, because \ is an escape character in
 % the index files.
@@ -4911,9 +4926,9 @@ end
   % Get the string to sort by, by processing the index entry with all
   % font commands turned off.
   {\indexnofonts
+   \indexnonalnumdisappear
    \xdef\indexsortkey{}%
    \let\sortas=\indexwritesortas
-   \indexnonalnumdisappear
    \edef\temp{\the\toks0}%
    \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
    \ifx\indexsortkey\empty
@@ -5059,7 +5074,9 @@ end
   % as its first line, TeX doesn't complain about mismatched braces
   % (because it thinks @} is a control sequence).
   \catcode`\@ = 11
-  \openin 1 \jobname.#1s
+  % See comment in \requireopenindexfile.
+  \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
+  \openin 1 \jobname.\indexname s
   \ifeof 1
     % \enddoublecolumns gets confused if there is no text in the index,
     % and it loses the chapter title and the aux file entries for the
@@ -5206,30 +5223,6 @@ end
     %  How much \indexdotfill is stretched, or how much \parfillskip is shrunk
     %  Number of lines (\linepenalty)
     %  
-    % Do not prefer a separate line ending with a hyphen to fewer lines.
-    \finalhyphendemerits = 0
-    %
-    % Word spacing - no stretch
-    \spaceskip=\fontdimen2\font minus \fontdimen4\font
-    %
-    \linepenalty=1000  % Discourage line breaks.
-    \hyphenpenalty=5000  % Discourage hyphenation.
-    %
-    % Ragged right margin, but not for the last line with the leaders in it.
-    % When an index entry spans lines, this stretch competes with the stretch
-    % in \indexdotfill to determine how the line will be split.
-    \rightskip=\entryrightmargin
-    \advance\rightskip by 0pt plus .6\hsize
-    %
-    % \parfillskip is at the end of the line with the page number
-    \parfillskip=0pt
-    % Cancel the \rightskip stretch
-    \advance \parfillskip by 0pt plus -.6\hsize
-    % Determine how far we can stretch into the margin.
-    % This allows, e.g., "Appendix H  GNU Free Documentation License" to fit
-    % on one line.
-    \advance \parfillskip by 0pt minus .6\entryrightmargin
-    %
     % Swallow the left brace of the text (first parameter):
     \afterassignment\doentry
     \let\temp =
@@ -5237,21 +5230,27 @@ end
 \def\entrybreak{\unskip\space\ignorespaces}%
 \def\doentry{%
     % Save the text of the entry in a \vtop.
-    \global\setbox\entryindexbox=\vtop\bgroup
+    \global\setbox\boxA=\hbox\bgroup
     \bgroup % Instead of the swallowed brace.
       \noindent
       \aftergroup\finishentry
       % And now comes the text of the entry.
+      % Not absorbing as a macro argument reduces the chance of problems
+      % with catcodes occurring.
 }
-\def\finishentry#1{%
address@hidden
+\gdef\finishentry#1{%
+    \egroup % end box A
+    \dimen@ = \wd\boxA % Length of text of entry
+    \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
     % #1 is the page number.
     %
     % The following is kludged to not output a line of dots in the index if
     % there are no page numbers.  The next person who breaks this will be
     % cursed by a Unix daemon.
-    \setbox\boxA = \hbox{#1}%
-    \ifdim\wd\boxA = 0pt
-      \ %
+    \setbox\boxB = \hbox{#1}%
+    \ifdim\wd\boxB = 0pt
+      \null\nobreak\hfill\ %
     \else
       %
       \null\nobreak\indexdotfill % Have leaders before the page number.
@@ -5263,23 +5262,62 @@ end
         \hskip\skip\thinshrinkable #1%
       \fi
     \fi
-    % Parameters for formatting this paragraph, reset for each paragraph.
+    \egroup % end \boxA
+    \global\setbox\entryindexbox=\vtop\bgroup\noindent
+    % We want the text of the entries to be aligned to the left, and the
+    % page numbers to be aligned to the right.
     %
-    % \hangindent is only relevant when the entry text and page number
-    % don't both fit on one line.  In that case, bob suggests starting the
-    % dots pretty far over on the line.  Unfortunately, a large
-    % indentation looks wrong when the entry text itself is broken across
-    % lines.  So we use a small indentation and put up with long leaders.
+    \advance\leftskip by 0pt plus 1fil
+    \advance\leftskip by 0pt plus -1fill
+    \rightskip = 0pt plus -1fil
+    \advance\rightskip by 0pt plus 1fill
+    % Cause last line, which could consist of page numbers on their own if the 
+    % list of page numbers is long, to be aligned to the right.
+    \parfillskip=0pt plus -1fill
     %
-    \hangafter = 1
-    \hangindent = 1em
-    \par
+    \hangindent=1em
+    %
+    \advance\rightskip by \entryrightmargin
+    % Determine how far we can stretch into the margin.
+    % This allows, e.g., "Appendix H  GNU Free Documentation License" to fit
+    % on one line.
+    \advance \parfillskip by 0pt minus .6\entryrightmargin
+    %
+    \ifdim\wd\boxA > \hsize % If the entry doesn't fit in one line
+    \ifdim\dimen@ > 0.9\hsize   % due to long index text
+      \dimen@ = 0.6\dimen@ % Try to split the text roughly evenly
+      address@hidden = \hsize
+      \advance address@hidden by -1em
+      \ifnum\dimen@>address@hidden
+        % If the entry is too long, use the whole line
+        \dimen@ = address@hidden
+      \else
+        % Cause stretch of 1fill at the end of the first line, to avoid
+        % extra spacing in a short first line.
+        \hskip 0pt plus 1fill
+      \fi
+      \parshape = 2 0pt \dimen@ 1em address@hidden
+      % Ideally we'd add a finite glue at the end of the first line only, but
+      % TeX doesn't seem to provide a way to do such a thing.
+    \fi\fi
+    \unhbox\boxA
+    %
+    % Do not prefer a separate line ending with a hyphen to fewer lines.
+    \finalhyphendemerits = 0
+    %
+    % Word spacing - no stretch
+    \spaceskip=\fontdimen2\font minus \fontdimen4\font
+    %
+    \linepenalty=1000  % Discourage line breaks.
+    \hyphenpenalty=10000  % Discourage hyphenation.
+    %
+    \par % format the paragraph
     \egroup % The \vtop
   \endgroup
   % delay text of entry until after penalty
   \bgroup\aftergroup\insertindexentrybox
   \entryorphanpenalty
-}
+}}
 
 \newskip\thinshrinkable
 \skip\thinshrinkable=.15em minus .15em
@@ -5314,10 +5352,11 @@ end
 }
 
 % Like plain.tex's \dotfill, except uses up at least 1 em.
-% Using a finite stretch encourages several words to appear on a second line
-% if the entry is broken.
+% The filll stretch here overpowers both the fil and fill stretch to push
+% the page number to the right.
 \def\indexdotfill{\cleaders
-  \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus .4\hsize}
+  \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
+
 
 \def\primary #1{\line{#1\hfil}}
 
@@ -5558,7 +5597,8 @@ end
     \writetocentry{part}{#1}{}% but put it in the toc
     \headingsoff              % no headline or footline on the part page
     % This outputs a mark at the end of the page that clears \thischapter
-    % and \thissection, like is done in \startcontents.
+    % and \thissection, as is done in \startcontents.
+    \let\pchapsepmacro\relax
     \chapmacro{}{Yomitfromtoc}{}%
     \chapoddpage
   \endgroup
@@ -8936,6 +8976,7 @@ end
 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
   \catcode`\^^M = 5     % in case we're inside an example
   \normalturnoffactive  % allow _ et al. in names
+  \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
   % If the image is by itself, center it.
   \ifvmode
     \imagevmodetrue
@@ -9339,7 +9380,8 @@ directory should work if nowhere else does.}
 % @documentencoding sets the definition of non-ASCII characters
 % according to the specified encoding.
 %
-\parseargdef\documentencoding{%
+\def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
+\def\documentencodingzzz#1{%
   % Encoding being declared for the document.
   \def\declaredencoding{\csname #1.enc\endcsname}%
   %
@@ -10066,6 +10108,9 @@ directory should work if nowhere else does.}
 
   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
 
+  % Greek letters
+  \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}
+
   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
@@ -10193,6 +10238,7 @@ directory should work if nowhere else does.}
   \DeclareUnicodeCharacter{1EF8}{\~Y}
   \DeclareUnicodeCharacter{1EF9}{\~y}
 
+  % Punctuation
   \DeclareUnicodeCharacter{2013}{--}
   \DeclareUnicodeCharacter{2014}{---}
   \DeclareUnicodeCharacter{2018}{\quoteleft}
@@ -10204,18 +10250,34 @@ directory should work if nowhere else does.}
   \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}
   \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}
   \DeclareUnicodeCharacter{2022}{\bullet}
+  \DeclareUnicodeCharacter{202F}{\thinspace}
   \DeclareUnicodeCharacter{2026}{\dots}
   \DeclareUnicodeCharacter{2039}{\guilsinglleft}
   \DeclareUnicodeCharacter{203A}{\guilsinglright}
+
   \DeclareUnicodeCharacter{20AC}{\euro}
 
   \DeclareUnicodeCharacter{2192}{\expansion}
   \DeclareUnicodeCharacter{21D2}{\result}
 
+  % Mathematical symbols
+  \DeclareUnicodeCharacter{2200}{\ensuremath\forall}
+  \DeclareUnicodeCharacter{2203}{\ensuremath\exists}
+  \DeclareUnicodeCharacter{2208}{\ensuremath\in}
   \DeclareUnicodeCharacter{2212}{\minus}
   \DeclareUnicodeCharacter{2217}{\point}
+  \DeclareUnicodeCharacter{221E}{\ensuremath\infty}
   \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}
+  \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}
+  \DeclareUnicodeCharacter{2229}{\ensuremath\cap}
   \DeclareUnicodeCharacter{2261}{\equiv}
+  \DeclareUnicodeCharacter{2264}{\ensuremath\leq}
+  \DeclareUnicodeCharacter{2265}{\ensuremath\geq}
+  \DeclareUnicodeCharacter{2282}{\ensuremath\subset}
+  \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}
+
+  \global\mathchardef\checkmark="1370 % actually the square root sign
+  \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}
 }% end of \utfeightchardefs
 
 % US-ASCII character definitions.
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index ac2e74e..8673b00 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -429,6 +429,14 @@ Or follow the example session below:
 @end example
 
 @noindent
+If you reside behind a firewall, you could use
+
address@hidden
+] @strong{git config --global http.proxy 
http://user:pwd@@proxy.server.com:8080}
+] @strong{git clone http://git.savannah.gnu.org/r/tramp.git}
address@hidden example
+
address@hidden
 Tramp developers use instead
 
 @example
@@ -1015,7 +1023,7 @@ program is not found via the @env{PATH} environment 
variable, the
 variable @var{tramp-adb-program} must point to its absolute path.
 
 @value{tramp} does not connect Android devices to @command{adb},
-unless the customer option @option{tramp-adb-connect-if-not-connected}
+unless the custom option @option{tramp-adb-connect-if-not-connected}
 is address@hidden  If there is exactly one Android device connected
 to @command{adb}, a host name is not needed in the remote file name.
 The default @value{tramp} name to be used is @address@hidden, , ,}},
@@ -1098,7 +1106,7 @@ FUSE, it also needs the SYNCE-GVFS plugin.
 
 @vindex tramp-gvfs-methods
 @defopt tramp-gvfs-methods
-This customer option, a list, defines the external methods which shall
+This custom option, a list, defines the external methods which shall
 be used with address@hidden  Per default, these are @option{dav},
 @option{davs}, @option{obex}, @option{sftp} and @option{synce}.  Other
 possible values are @option{ftp} and @option{smb}.
@@ -1371,7 +1379,7 @@ bastion host.
 @vindex tramp-default-proxies-alist
 @defopt tramp-default-proxies-alist
 In order to specify multiple hops, it is possible to define a proxy
-host to pass through, via the customer option
+host to pass through, via the custom option
 @option{tramp-default-proxies-alist}.  This variable keeps a list of
 triples (@var{host} @var{user} @var{proxy}).
 
@@ -1486,7 +1494,7 @@ Sometimes they offer limited features only, like running 
@command{rbash}
 
 @vindex tramp-restricted-shell-hosts-alist
 @defopt tramp-restricted-shell-hosts-alist
-This customer option keeps a list of regular expressions, which denote
+This custom option keeps a list of regular expressions, which denote
 hosts running a registered shell like @command{rbash}.  Those hosts
 can be used as proxies only.
 
@@ -1827,7 +1835,7 @@ remote file access.
 @vindex tramp-own-remote-path
 @defopt tramp-remote-path
 When @value{tramp} connects to the remote host, it searches for the
-programs that it can use.  The customer option
+programs that it can use.  The custom option
 @option{tramp-remote-path} controls the directories searched on the
 remote host.
 
@@ -2631,7 +2639,7 @@ changes, which would be invisible otherwise 
(@pxref{Connection caching}).
 
 @vindex tramp-completion-reread-directory-timeout
 @defopt tramp-completion-reread-directory-timeout
-This customer option defines the number of seconds since last remote
+This custom option defines the number of seconds since last remote
 command before rereading a directory contents.  A value of 0 would
 require an immediate reread during file name completion, @code{nil}
 means to use always cached values for the directory contents.
@@ -2672,7 +2680,7 @@ remotehost, /path}} would be sufficient from now on.
 
 @vindex tramp-save-ad-hoc-proxies
 @defopt tramp-save-ad-hoc-proxies
-This customer option controls whether ad-hoc definitions are kept
+This custom option controls whether ad-hoc definitions are kept
 persistently in @option{tramp-default-proxies-alist}.  That means,
 those definitions are available also for future @value{emacsname}
 sessions.
@@ -3704,8 +3712,8 @@ all hops, like @address@hidden, bird,
 bastion|address@hidden, /opt/news/etc}}.
 
 Alternatively, if you save only the abbreviated multi-hop file name
address@hidden@trampfn{ssh, news, news.my.domain, /opt/news/etc}}, the
-customer option @code{tramp-save-ad-hoc-proxies} must be set to a to a
address@hidden@trampfn{ssh, news, news.my.domain, /opt/news/etc}}, the custom
+option @code{tramp-save-ad-hoc-proxies} must be set to a to a
 address@hidden value.
 
 
diff --git a/etc/HISTORY b/etc/HISTORY
new file mode 100644
index 0000000..0426425
--- /dev/null
+++ b/etc/HISTORY
@@ -0,0 +1,204 @@
+       GNU Emacs versions and their release dates
+
+For more details about release contents, see the NEWS* files.
+
+Dates are approximate in the following list; some are when the version
+was made, some are when it was announced.
+
+
+GNU Emacs 1.0 through 1.12 were released in early 1985.
+The next release after 1.12 was 13.
+
+GNU Emacs 13 (1985-03-20)
+Initial release announced on Usenet.
+
+GNU Emacs 15.10 (1985-04-10)
+
+GNU Emacs 15.34 (1985-05-07)
+Last version 15 release.
+
+GNU Emacs 16.56 (1985-07-15)
+First version 16 release.
+
+GNU Emacs 16.57 (1985-09-16)
+
+GNU Emacs 16.58 (1985-09-17)
+
+GNU Emacs 16.59 (1985-09-17)
+
+GNU Emacs 16.60 (1985-09-19)
+
+GNU Emacs 17.36 (1985-12-20)
+First version 17 release.
+
+GNU Emacs 17.43 (1986-01-25)
+
+GNU Emacs 17.46 (1986-02-04)
+
+GNU Emacs 17.48 (1986-02-10)
+
+GNU Emacs 17.49 (1986-02-12)
+
+GNU Emacs 17.55 (1986-03-18)
+
+GNU Emacs 17.57 (1986-03-27)
+
+GNU Emacs 17.58 (1986-04-04)
+
+GNU Emacs 17.61 (1986-04-22)
+
+GNU Emacs 17.63 (1986-05-07)
+
+GNU Emacs 17.64 (1986-05-12)
+
+GNU Emacs 18.41 (1987-03-22)
+
+GNU Emacs 18.45 (1987-06-02)
+
+GNU Emacs 18.46 (1987-06-08)
+
+GNU Emacs 18.47 (1987-06-10)
+
+GNU Emacs 18.48 (1987-08-30)
+
+GNU Emacs 18.49 (1987-09-18)
+
+GNU Emacs 18.50 (1988-02-13)
+
+GNU Emacs 18.51 (1988-05-07)
+
+GNU Emacs 18.52 (1988-09-01)
+
+GNU Emacs 18.53 (1989-02-24)
+
+GNU Emacs 18.54 (1989-04-26)
+
+GNU Emacs 18.55 (1989-08-23)
+
+GNU Emacs 18.56 (1991-01-16)
+
+GNU Emacs 18.57 (1991-01-25)
+
+GNU Emacs 18.58 (1991-02-18)
+
+GNU Emacs 18.59 (1992-10-30)
+
+GNU Emacs 19.7  (1993-05-22)
+
+GNU Emacs 19.8  (1993-05-24)
+
+GNU Emacs 19.9  (1993-05-27)
+
+GNU Emacs 19.10 (1993-05-30)
+
+GNU Emacs 19.11 (1993-06-01)
+
+GNU Emacs 19.12 (1993-06-02)
+
+GNU Emacs 19.13 (1993-06-08)
+
+GNU Emacs 19.14 (1993-06-17)
+
+GNU Emacs 19.15 (1993-06-19)
+
+GNU Emacs 19.16 (1993-07-06)
+
+GNU Emacs 19.17 (1993-07-19)
+
+GNU Emacs 19.18 (1993-08-08)
+
+GNU Emacs 19.19 (1993-08-14)
+
+GNU Emacs 19.20 (1993-11-11)
+
+GNU Emacs 19.21 (1993-11-16)
+
+GNU Emacs 19.22 (1993-11-27)
+
+GNU Emacs 19.23 (1994-05-16)
+
+GNU Emacs 19.24 (1994-05-23)
+
+GNU Emacs 19.25 (1994-05-30)
+
+GNU Emacs 19.26 (1994-09-07)
+
+GNU Emacs 19.28 (1994-10-06)
+
+GNU Emacs 19.29 (1995-06-19)
+
+GNU Emacs 19.30 (1995-11-24)
+
+GNU Emacs 19.31 (1996-05-25)
+
+GNU Emacs 19.32 (1996-07-31)
+
+GNU Emacs 19.33 (1996-08-11)
+
+GNU Emacs 19.34 (1996-08-21)
+
+GNU Emacs 20.1 (1997-09-15)
+
+GNU Emacs 20.2 (1997-09-19)
+
+GNU Emacs 20.3 (1998-08-19)
+
+GNU Emacs 20.4 (1999-07-12)
+
+GNU Emacs 20.5 (1999-12-04)
+
+GNU Emacs 20.6 (2000-02-15)
+
+GNU Emacs 20.7 (2000-06-13)
+
+GNU Emacs 21.1 (2001-10-20)
+
+GNU Emacs 21.2 (2002-03-16)
+
+GNU Emacs 21.3 (2003-03-19)
+
+GNU Emacs 21.4 (2005-02-08)
+
+GNU Emacs 21.4a (2005-02-17)
+This is Emacs 21.4 with an updated notice in etc/PROBLEMS.
+
+GNU Emacs 22.1 (2007-06-02)
+
+GNU Emacs 22.2 (2008-03-26)
+
+GNU Emacs 22.3 (2008-09-05)
+
+GNU Emacs 23.1 (2009-07-29)
+
+GNU Emacs 23.2 (2010-05-08)
+
+GNU Emacs 23.3 (2011-03-10)
+
+GNU Emacs 23.4 (2012-01-29)
+
+GNU Emacs 24.1 (2012-06-10)
+
+GNU Emacs 24.2 (2012-08-27)
+
+GNU Emacs 24.3 (2013-03-10)
+
+GNU Emacs 24.4 (2014-10-20)
+
+GNU Emacs 24.5 (2015-04-10)
+
+
+----------------------------------------------------------------------
+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/>.
diff --git a/etc/NEWS b/etc/NEWS
index dbe0de3..8672f99 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -8,6 +8,7 @@ If possible, use M-x report-emacs-bug.
 
 This file is about changes in Emacs version 25.
 
+See file HISTORY for a list of GNU Emacs versions and release dates.
 See files NEWS.24, NEWS.23, NEWS.22, NEWS.21, NEWS.20, NEWS.19, NEWS.18,
 and NEWS.1-17 for changes in older Emacs versions.
 
@@ -274,6 +275,14 @@ header.
 ** `tabulated-list-print' takes a second optional argument, update,
 which specifies an alternative printing method which is faster when
 few or no entries have changed.
+** The command `dired-do-compress' bound to `Z' now can compress
+directories and decompress zip files.
+** New command `dired-do-compress-to' bound to `c' can be used to compress
+many marked files into a single named archive.  The compression
+command is determined from the new `dired-compress-files-alist'
+variable.
+
++++
 
 
 * Editing Changes in Emacs 25.1
@@ -1000,13 +1009,15 @@ behavior, set `diff-switches' to `-c'.
 
 ** `grep-template' and `grep-find-template' values don't include the
 --color argument anymore.  It's added at the <C> place holder position
-dynamically.
-
-** `grep-template' and `grep-find-template' values don't include the
---color argument anymore.  It's added at the <C> place holder position
 dynamically.  Any third-party code that changes these templates should
 be updated accordingly.
 
++++
+** ‘(/ N)’ is now equivalent to ‘(/ 1 N)’ rather than to ‘(/ N 1)’.
+The new behavior is compatible with Common Lisp and with XEmacs.
+This change does not affect Lisp code intended to be portable to
+Emacs 24.2 and earlier, which did not support unary ‘/’.
+
 
 * Lisp Changes in Emacs 25.1
 
diff --git a/lib-src/ChangeLog.1 b/lib-src/ChangeLog.1
index 0bb24c3..5b41540 100644
--- a/lib-src/ChangeLog.1
+++ b/lib-src/ChangeLog.1
@@ -456,7 +456,7 @@
        * update-game-score.c: Include inttypes.h, stdbool.h.
        (min): New macro, if not already defined.
        (MAX_SCORES, main): Limit the maximum number of scores only from
-       limits imposed by the underyling platform, instead of the
+       limits imposed by the underlying platform, instead of the
        arbitrary value 200.
        (struct score_entry, main, read_score, write_score):
        Scores are now intmax_t, not long.
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index 09edc7d..f2093ae 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -32,27 +32,32 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #define SEEK_END 2
 #endif
 
-/* Conditionalize function prototypes.  */
-
-/* Value is non-zero if strings X and Y compare equal.  */
-
-#define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0)
-
 #include <min-max.h>
 
 /* Files are read in chunks of this number of bytes.  */
 
-#define READ_CHUNK_SIZE (100 * 1024)
+enum { READ_CHUNK_SIZE = 100 * 1024 };
 
-#if defined (__MSDOS__)
-#define FILENAME_EQ(X,Y)    (strcasecmp (X,Y) == 0)
-#else
-#if defined (WINDOWSNT)
-#define FILENAME_EQ(X,Y)    (stricmp (X,Y) == 0)
+/* Value is true if strings X and Y compare equal.  */
+
+static bool
+streq (char const *x, char const *y)
+{
+  return strcmp (x, y) == 0;
+}
+
+static bool
+filename_eq (char const *x, char const *y)
+{
+#ifdef __MSDOS__
+  return strcasecmp (x, y) == 0;
+#elif defined WINDOWSNT
+  return stricmp (x, y) == 0;
 #else
-#define FILENAME_EQ(X,Y)    (streq (X,Y))
-#endif
+  return streq (x, y);
 #endif
+}
+
 /* The default output file name.  */
 
 #define DEFAULT_OUTFILE "BROWSE"
@@ -217,10 +222,19 @@ enum visibility
 #define F_EXTERNC      256     /* Is declared extern "C".  */
 #define F_DEFINE       512     /* Is a #define.  */
 
-/* Two macros to set and test a bit in an int.  */
+/* Set and test a bit in an int.  */
 
-#define SET_FLAG(F, FLAG)      ((F) |= (FLAG))
-#define HAS_FLAG(F, FLAG)      (((F) & (FLAG)) != 0)
+static void
+set_flag (int *f, int flag)
+{
+  *f |= flag;
+}
+
+static bool
+has_flag (int f, int flag)
+{
+  return (f & flag) != 0;
+}
 
 /* Structure describing a class member.  */
 
@@ -682,7 +696,7 @@ add_member_decl (struct sym *cls, char *name, char *regexp, 
int pos, unsigned in
     m = add_member (cls, name, var, sc, hash);
 
   /* Have we seen a new filename?  If so record that.  */
-  if (!cls->filename || !FILENAME_EQ (cls->filename, filename))
+  if (!cls->filename || !filename_eq (cls->filename, filename))
     m->filename = filename;
 
   m->regexp = regexp;
@@ -745,7 +759,7 @@ add_member_defn (struct sym *cls, char *name, char *regexp, 
int pos, unsigned in
   if (!cls->sfilename)
     cls->sfilename = filename;
 
-  if (!FILENAME_EQ (cls->sfilename, filename))
+  if (!filename_eq (cls->sfilename, filename))
     m->def_filename = filename;
 
   m->def_regexp = regexp;
@@ -830,7 +844,7 @@ add_global_decl (char *name, char *regexp, int pos, 
unsigned int hash, int var,
   if (!found)
     {
       if (!global_symbols->filename
-         || !FILENAME_EQ (global_symbols->filename, filename))
+         || !filename_eq (global_symbols->filename, filename))
        m->filename = filename;
 
       m->regexp = regexp;
@@ -931,11 +945,11 @@ mark_virtual (struct sym *r)
   for (p = r->subs; p; p = p->next)
     {
       for (m = r->fns; m; m = m->next)
-        if (HAS_FLAG (m->flags, F_VIRTUAL))
+        if (has_flag (m->flags, F_VIRTUAL))
           {
             for (m2 = p->sym->fns; m2; m2 = m2->next)
               if (m->param_hash == m2->param_hash && streq (m->name, m2->name))
-                SET_FLAG (m2->flags, F_VIRTUAL);
+                set_flag (&m2->flags, F_VIRTUAL);
           }
 
       mark_virtual (p->sym);
@@ -1159,7 +1173,7 @@ sym_scope_1 (struct sym *p)
   strcpy (scope_buffer + scope_buffer_len, p->name);
   scope_buffer_len += len;
 
-  if (HAS_FLAG (p->flags, F_TEMPLATE))
+  if (has_flag (p->flags, F_TEMPLATE))
     {
       ensure_scope_buffer_room (3);
       strcpy (scope_buffer + scope_buffer_len, "<>");
@@ -2435,7 +2449,7 @@ parm_list (int *flags)
         {
           /* We can overload the same function on `const' */
           hash = (hash << 1) ^ CONST;
-          SET_FLAG (*flags, F_CONST);
+          set_flag (flags, F_CONST);
           MATCH ();
         }
 
@@ -2443,7 +2457,7 @@ parm_list (int *flags)
         {
           MATCH ();
           SKIP_MATCHING_IF ('(');
-          SET_FLAG (*flags, F_THROW);
+          set_flag (flags, F_THROW);
         }
 
       if (LOOKING_AT ('='))
@@ -2452,7 +2466,7 @@ parm_list (int *flags)
           if (LOOKING_AT (CINT) && yyival == 0)
             {
               MATCH ();
-              SET_FLAG (*flags, F_PURE);
+              set_flag (flags, F_PURE);
             }
         }
     }
@@ -2505,25 +2519,25 @@ member (struct sym *cls, int vis)
           /* A function or class may follow.  */
         case TEMPLATE:
           MATCH ();
-          SET_FLAG (flags, F_TEMPLATE);
+          set_flag (&flags, F_TEMPLATE);
           /* Skip over template argument list */
           SKIP_MATCHING_IF ('<');
           break;
 
         case EXPLICIT:
-          SET_FLAG (flags, F_EXPLICIT);
+          set_flag (&flags, F_EXPLICIT);
           goto typeseen;
 
         case MUTABLE:
-          SET_FLAG (flags, F_MUTABLE);
+          set_flag (&flags, F_MUTABLE);
           goto typeseen;
 
         case T_INLINE:
-          SET_FLAG (flags, F_INLINE);
+          set_flag (&flags, F_INLINE);
           goto typeseen;
 
         case VIRTUAL:
-          SET_FLAG (flags, F_VIRTUAL);
+          set_flag (&flags, F_VIRTUAL);
           goto typeseen;
 
         case '[':
@@ -2761,7 +2775,7 @@ parse_classname (void)
       if (LOOKING_AT ('<'))
         {
           skip_matching ();
-          SET_FLAG (last_class->flags, F_TEMPLATE);
+          set_flag (&last_class->flags, F_TEMPLATE);
         }
 
       if (!LOOKING_AT (DCOLON))
@@ -3189,7 +3203,7 @@ declaration (int flags)
           break;
 
         case T_INLINE:
-          SET_FLAG (flags, F_INLINE);
+          set_flag (&flags, F_INLINE);
           MATCH ();
           break;
 
@@ -3335,14 +3349,14 @@ globals (int start_flags)
                   MATCH_IF ('}');
                 }
               else
-                SET_FLAG (flags, F_EXTERNC);
+                set_flag (&flags, F_EXTERNC);
             }
           break;
 
         case TEMPLATE:
           MATCH ();
           SKIP_MATCHING_IF ('<');
-          SET_FLAG (flags, F_TEMPLATE);
+          set_flag (&flags, F_TEMPLATE);
           break;
 
         case CLASS: case STRUCT: case UNION:
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 791722d..8b980d3 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -150,10 +150,29 @@ char pot_etags_version[] = "@(#) pot revision number is 
17.38.1.4";
 # define CTAGS false
 #endif
 
-#define streq(s,t)     (assert ((s)!=NULL || (t)!=NULL), !strcmp (s, t))
-#define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=NULL), !c_strcasecmp (s, t))
-#define strneq(s,t,n)  (assert ((s)!=NULL || (t)!=NULL), !strncmp (s, t, n))
-#define strncaseeq(s,t,n) (assert ((s)!=NULL && (t)!=NULL), !c_strncasecmp (s, 
t, n))
+static bool
+streq (char const *s, char const *t)
+{
+  return strcmp (s, t) == 0;
+}
+
+static bool
+strcaseeq (char const *s, char const *t)
+{
+  return c_strcasecmp (s, t) == 0;
+}
+
+static bool
+strneq (char const *s, char const *t, size_t n)
+{
+  return strncmp (s, t, n) == 0;
+}
+
+static bool
+strncaseeq (char const *s, char const *t, size_t n)
+{
+  return c_strncasecmp (s, t, n) == 0;
+}
 
 /* C is not in a name.  */
 static bool
diff --git a/lib/binary-io.c b/lib/binary-io.c
index 8bbdb44..d828bcd 100644
--- a/lib/binary-io.c
+++ b/lib/binary-io.c
@@ -1,3 +1,4 @@
 #include <config.h>
 #define BINARY_IO_INLINE _GL_EXTERN_INLINE
 #include "binary-io.h"
+typedef int dummy;
diff --git a/lib/c-ctype.h b/lib/c-ctype.h
index 50ebbb5..1512530 100644
--- a/lib/c-ctype.h
+++ b/lib/c-ctype.h
@@ -78,82 +78,65 @@ extern "C" {
 # error "Only ASCII and EBCDIC are supported"
 #endif
 
-#define _C_CTYPE_SIGNED_EBCDIC ('A' < 0)
+#if 'A' < 0
+# error "EBCDIC and char is signed -- not supported"
+#endif
+
+/* Cases for control characters.  */
+
+#define _C_CTYPE_CNTRL \
+   case '\a': case '\b': case '\f': case '\n': \
+   case '\r': case '\t': case '\v': \
+   _C_CTYPE_OTHER_CNTRL
+
+/* ASCII control characters other than those with \-letter escapes.  */
 
 #if C_CTYPE_ASCII
-# define _C_CTYPE_CNTRL \
+# define _C_CTYPE_OTHER_CNTRL \
     case '\x00': case '\x01': case '\x02': case '\x03': \
-    case '\x04': case '\x05': case '\x06': case '\x07': \
-    case '\x08': case '\x09': case '\x0a': case '\x0b': \
-    case '\x0c': case '\x0d': case '\x0e': case '\x0f': \
-    case '\x10': case '\x11': case '\x12': case '\x13': \
-    case '\x14': case '\x15': case '\x16': case '\x17': \
-    case '\x18': case '\x19': case '\x1a': case '\x1b': \
-    case '\x1c': case '\x1d': case '\x1e': case '\x1f': \
-    case '\x7f'
+    case '\x04': case '\x05': case '\x06': case '\x0e': \
+    case '\x0f': case '\x10': case '\x11': case '\x12': \
+    case '\x13': case '\x14': case '\x15': case '\x16': \
+    case '\x17': case '\x18': case '\x19': case '\x1a': \
+    case '\x1b': case '\x1c': case '\x1d': case '\x1e': \
+    case '\x1f': case '\x7f'
 #else
    /* Use EBCDIC code page 1047's assignments for ASCII control chars;
       assume all EBCDIC code pages agree about these assignments.  */
-# define _C_CTYPE_CNTRL \
+# define _C_CTYPE_OTHER_CNTRL \
     case '\x00': case '\x01': case '\x02': case '\x03': \
-    case '\x05': case '\x07': case '\x0b': case '\x0c': \
-    case '\x0d': case '\x0e': case '\x0f': case '\x10': \
-    case '\x11': case '\x12': case '\x13': case '\x16': \
-    case '\x18': case '\x19': case '\x1c': case '\x1d': \
-    case '\x1e': case '\x1f': case '\x25': case '\x26': \
-    case '\x27': case '\x2d': case '\x2e': case '\x2f': \
-    case '\x32': case '\x37': case '\x3c': case '\x3d': \
-    case '\x3f'
+    case '\x07': case '\x0e': case '\x0f': case '\x10': \
+    case '\x11': case '\x12': case '\x13': case '\x18': \
+    case '\x19': case '\x1c': case '\x1d': case '\x1e': \
+    case '\x1f': case '\x26': case '\x27': case '\x2d': \
+    case '\x2e': case '\x32': case '\x37': case '\x3c': \
+    case '\x3d': case '\x3f'
 #endif
 
-/* Cases for hex letter digits, digits, lower, and upper, offset by N.  */
+/* Cases for lowercase hex letters, and lowercase letters, all offset by N.  */
 
-#define _C_CTYPE_A_THRU_F_N(n) \
+#define _C_CTYPE_LOWER_A_THRU_F_N(n) \
    case 'a' + (n): case 'b' + (n): case 'c' + (n): case 'd' + (n): \
-   case 'e' + (n): case 'f' + (n): \
-   case 'A' + (n): case 'B' + (n): case 'C' + (n): case 'D' + (n): \
-   case 'E' + (n): case 'F' + (n)
-#define _C_CTYPE_DIGIT_N(n) \
-   case '0' + (n): case '1' + (n): case '2' + (n): case '3' + (n): \
-   case '4' + (n): case '5' + (n): case '6' + (n): case '7' + (n): \
-   case '8' + (n): case '9' + (n)
+   case 'e' + (n): case 'f' + (n)
 #define _C_CTYPE_LOWER_N(n) \
-   case 'a' + (n): case 'b' + (n): case 'c' + (n): case 'd' + (n): \
-   case 'e' + (n): case 'f' + (n): case 'g' + (n): case 'h' + (n): \
-   case 'i' + (n): case 'j' + (n): case 'k' + (n): case 'l' + (n): \
-   case 'm' + (n): case 'n' + (n): case 'o' + (n): case 'p' + (n): \
-   case 'q' + (n): case 'r' + (n): case 's' + (n): case 't' + (n): \
-   case 'u' + (n): case 'v' + (n): case 'w' + (n): case 'x' + (n): \
-   case 'y' + (n): case 'z' + (n)
-#define _C_CTYPE_UPPER_N(n) \
-   case 'A' + (n): case 'B' + (n): case 'C' + (n): case 'D' + (n): \
-   case 'E' + (n): case 'F' + (n): case 'G' + (n): case 'H' + (n): \
-   case 'I' + (n): case 'J' + (n): case 'K' + (n): case 'L' + (n): \
-   case 'M' + (n): case 'N' + (n): case 'O' + (n): case 'P' + (n): \
-   case 'Q' + (n): case 'R' + (n): case 'S' + (n): case 'T' + (n): \
-   case 'U' + (n): case 'V' + (n): case 'W' + (n): case 'X' + (n): \
-   case 'Y' + (n): case 'Z' + (n)
-
-/* Given MACRO_N, expand to all the cases for the corresponding class.  */
-#if _C_CTYPE_SIGNED_EBCDIC
-# define _C_CTYPE_CASES(macro_n) macro_n (0): macro_n (256)
-#else
-# define _C_CTYPE_CASES(macro_n) macro_n (0)
-#endif
-
-/* Cases for hex letter digits, digits, lower, and upper, with another
-   case for unsigned char if the original char is negative.  */
-
-#define _C_CTYPE_A_THRU_F _C_CTYPE_CASES (_C_CTYPE_A_THRU_F_N)
-#define _C_CTYPE_DIGIT _C_CTYPE_CASES (_C_CTYPE_DIGIT_N)
-#define _C_CTYPE_LOWER _C_CTYPE_CASES (_C_CTYPE_LOWER_N)
-#define _C_CTYPE_UPPER _C_CTYPE_CASES (_C_CTYPE_UPPER_N)
-
-/* The punct class differs because some punctuation characters may be
-   negative while others are nonnegative.  Instead of attempting to
-   define _C_CTYPE_PUNCT, define just the plain chars here, and do any
-   cases-plus-256 by hand after using this macro.  */
-#define _C_CTYPE_PUNCT_PLAIN \
+   _C_CTYPE_LOWER_A_THRU_F_N(n): \
+   case 'g' + (n): case 'h' + (n): case 'i' + (n): case 'j' + (n): \
+   case 'k' + (n): case 'l' + (n): case 'm' + (n): case 'n' + (n): \
+   case 'o' + (n): case 'p' + (n): case 'q' + (n): case 'r' + (n): \
+   case 's' + (n): case 't' + (n): case 'u' + (n): case 'v' + (n): \
+   case 'w' + (n): case 'x' + (n): case 'y' + (n): case 'z' + (n)
+
+/* Cases for hex letters, digits, lower, punct, and upper.  */
+
+#define _C_CTYPE_A_THRU_F \
+   _C_CTYPE_LOWER_A_THRU_F_N (0): \
+   _C_CTYPE_LOWER_A_THRU_F_N ('A' - 'a')
+#define _C_CTYPE_DIGIT                     \
+   case '0': case '1': case '2': case '3': \
+   case '4': case '5': case '6': case '7': \
+   case '8': case '9'
+#define _C_CTYPE_LOWER _C_CTYPE_LOWER_N (0)
+#define _C_CTYPE_PUNCT \
    case '!': case '"': case '#': case '$':  \
    case '%': case '&': case '\'': case '(': \
    case ')': case '*': case '+': case ',':  \
@@ -162,6 +145,8 @@ extern "C" {
    case '?': case '@': case '[': case '\\': \
    case ']': case '^': case '_': case '`':  \
    case '{': case '|': case '}': case '~'
+#define _C_CTYPE_UPPER _C_CTYPE_LOWER_N ('A' - 'a')
+
 
 /* Function definitions.  */
 
@@ -189,7 +174,6 @@ c_isalnum (int c)
     _C_CTYPE_LOWER:
     _C_CTYPE_UPPER:
       return true;
-
     default:
       return false;
     }
@@ -203,7 +187,6 @@ c_isalpha (int c)
     _C_CTYPE_LOWER:
     _C_CTYPE_UPPER:
       return true;
-
     default:
       return false;
     }
@@ -220,107 +203,9 @@ c_isascii (int c)
     _C_CTYPE_CNTRL:
     _C_CTYPE_DIGIT:
     _C_CTYPE_LOWER:
+    _C_CTYPE_PUNCT:
     _C_CTYPE_UPPER:
-
-    _C_CTYPE_PUNCT_PLAIN:
-#if '!' < 0
-    case '!' + 256:
-#endif
-#if '"' < 0
-    case '"' + 256:
-#endif
-#if '#' < 0
-    case '#' + 256:
-#endif
-#if '$' < 0
-    case '$' + 256:
-#endif
-#if '%' < 0
-    case '%' + 256:
-#endif
-#if '&' < 0
-    case '&' + 256:
-#endif
-#if '\'' < 0
-    case '\'' + 256:
-#endif
-#if '(' < 0
-    case '(' + 256:
-#endif
-#if ')' < 0
-    case ')' + 256:
-#endif
-#if '*' < 0
-    case '*' + 256:
-#endif
-#if '+' < 0
-    case '+' + 256:
-#endif
-#if ',' < 0
-    case ',' + 256:
-#endif
-#if '-' < 0
-    case '-' + 256:
-#endif
-#if '.' < 0
-    case '.' + 256:
-#endif
-#if '/' < 0
-    case '/' + 256:
-#endif
-#if ':' < 0
-    case ':' + 256:
-#endif
-#if ';' < 0
-    case ';' + 256:
-#endif
-#if '<' < 0
-    case '<' + 256:
-#endif
-#if '=' < 0
-    case '=' + 256:
-#endif
-#if '>' < 0
-    case '>' + 256:
-#endif
-#if '?' < 0
-    case '?' + 256:
-#endif
-#if '@' < 0
-    case '@' + 256:
-#endif
-#if '[' < 0
-    case '[' + 256:
-#endif
-#if '\\' < 0
-    case '\\' + 256:
-#endif
-#if ']' < 0
-    case ']' + 256:
-#endif
-#if '^' < 0
-    case '^' + 256:
-#endif
-#if '_' < 0
-    case '_' + 256:
-#endif
-#if '`' < 0
-    case '`' + 256:
-#endif
-#if '{' < 0
-    case '{' + 256:
-#endif
-#if '|' < 0
-    case '|' + 256:
-#endif
-#if '}' < 0
-    case '}' + 256:
-#endif
-#if '~' < 0
-    case '~' + 256:
-#endif
       return true;
-
     default:
       return false;
     }
@@ -363,107 +248,9 @@ c_isgraph (int c)
     {
     _C_CTYPE_DIGIT:
     _C_CTYPE_LOWER:
+    _C_CTYPE_PUNCT:
     _C_CTYPE_UPPER:
-
-    _C_CTYPE_PUNCT_PLAIN:
-#if '!' < 0
-    case '!' + 256:
-#endif
-#if '"' < 0
-    case '"' + 256:
-#endif
-#if '#' < 0
-    case '#' + 256:
-#endif
-#if '$' < 0
-    case '$' + 256:
-#endif
-#if '%' < 0
-    case '%' + 256:
-#endif
-#if '&' < 0
-    case '&' + 256:
-#endif
-#if '\'' < 0
-    case '\'' + 256:
-#endif
-#if '(' < 0
-    case '(' + 256:
-#endif
-#if ')' < 0
-    case ')' + 256:
-#endif
-#if '*' < 0
-    case '*' + 256:
-#endif
-#if '+' < 0
-    case '+' + 256:
-#endif
-#if ',' < 0
-    case ',' + 256:
-#endif
-#if '-' < 0
-    case '-' + 256:
-#endif
-#if '.' < 0
-    case '.' + 256:
-#endif
-#if '/' < 0
-    case '/' + 256:
-#endif
-#if ':' < 0
-    case ':' + 256:
-#endif
-#if ';' < 0
-    case ';' + 256:
-#endif
-#if '<' < 0
-    case '<' + 256:
-#endif
-#if '=' < 0
-    case '=' + 256:
-#endif
-#if '>' < 0
-    case '>' + 256:
-#endif
-#if '?' < 0
-    case '?' + 256:
-#endif
-#if '@' < 0
-    case '@' + 256:
-#endif
-#if '[' < 0
-    case '[' + 256:
-#endif
-#if '\\' < 0
-    case '\\' + 256:
-#endif
-#if ']' < 0
-    case ']' + 256:
-#endif
-#if '^' < 0
-    case '^' + 256:
-#endif
-#if '_' < 0
-    case '_' + 256:
-#endif
-#if '`' < 0
-    case '`' + 256:
-#endif
-#if '{' < 0
-    case '{' + 256:
-#endif
-#if '|' < 0
-    case '|' + 256:
-#endif
-#if '}' < 0
-    case '}' + 256:
-#endif
-#if '~' < 0
-    case '~' + 256:
-#endif
       return true;
-
     default:
       return false;
     }
@@ -489,107 +276,9 @@ c_isprint (int c)
     case ' ':
     _C_CTYPE_DIGIT:
     _C_CTYPE_LOWER:
+    _C_CTYPE_PUNCT:
     _C_CTYPE_UPPER:
-
-    _C_CTYPE_PUNCT_PLAIN:
-#if '!' < 0
-    case '!' + 256:
-#endif
-#if '"' < 0
-    case '"' + 256:
-#endif
-#if '#' < 0
-    case '#' + 256:
-#endif
-#if '$' < 0
-    case '$' + 256:
-#endif
-#if '%' < 0
-    case '%' + 256:
-#endif
-#if '&' < 0
-    case '&' + 256:
-#endif
-#if '\'' < 0
-    case '\'' + 256:
-#endif
-#if '(' < 0
-    case '(' + 256:
-#endif
-#if ')' < 0
-    case ')' + 256:
-#endif
-#if '*' < 0
-    case '*' + 256:
-#endif
-#if '+' < 0
-    case '+' + 256:
-#endif
-#if ',' < 0
-    case ',' + 256:
-#endif
-#if '-' < 0
-    case '-' + 256:
-#endif
-#if '.' < 0
-    case '.' + 256:
-#endif
-#if '/' < 0
-    case '/' + 256:
-#endif
-#if ':' < 0
-    case ':' + 256:
-#endif
-#if ';' < 0
-    case ';' + 256:
-#endif
-#if '<' < 0
-    case '<' + 256:
-#endif
-#if '=' < 0
-    case '=' + 256:
-#endif
-#if '>' < 0
-    case '>' + 256:
-#endif
-#if '?' < 0
-    case '?' + 256:
-#endif
-#if '@' < 0
-    case '@' + 256:
-#endif
-#if '[' < 0
-    case '[' + 256:
-#endif
-#if '\\' < 0
-    case '\\' + 256:
-#endif
-#if ']' < 0
-    case ']' + 256:
-#endif
-#if '^' < 0
-    case '^' + 256:
-#endif
-#if '_' < 0
-    case '_' + 256:
-#endif
-#if '`' < 0
-    case '`' + 256:
-#endif
-#if '{' < 0
-    case '{' + 256:
-#endif
-#if '|' < 0
-    case '|' + 256:
-#endif
-#if '}' < 0
-    case '}' + 256:
-#endif
-#if '~' < 0
-    case '~' + 256:
-#endif
       return true;
-
     default:
       return false;
     }
@@ -600,105 +289,8 @@ c_ispunct (int c)
 {
   switch (c)
     {
-    _C_CTYPE_PUNCT_PLAIN:
-#if '!' < 0
-    case '!' + 256:
-#endif
-#if '"' < 0
-    case '"' + 256:
-#endif
-#if '#' < 0
-    case '#' + 256:
-#endif
-#if '$' < 0
-    case '$' + 256:
-#endif
-#if '%' < 0
-    case '%' + 256:
-#endif
-#if '&' < 0
-    case '&' + 256:
-#endif
-#if '\'' < 0
-    case '\'' + 256:
-#endif
-#if '(' < 0
-    case '(' + 256:
-#endif
-#if ')' < 0
-    case ')' + 256:
-#endif
-#if '*' < 0
-    case '*' + 256:
-#endif
-#if '+' < 0
-    case '+' + 256:
-#endif
-#if ',' < 0
-    case ',' + 256:
-#endif
-#if '-' < 0
-    case '-' + 256:
-#endif
-#if '.' < 0
-    case '.' + 256:
-#endif
-#if '/' < 0
-    case '/' + 256:
-#endif
-#if ':' < 0
-    case ':' + 256:
-#endif
-#if ';' < 0
-    case ';' + 256:
-#endif
-#if '<' < 0
-    case '<' + 256:
-#endif
-#if '=' < 0
-    case '=' + 256:
-#endif
-#if '>' < 0
-    case '>' + 256:
-#endif
-#if '?' < 0
-    case '?' + 256:
-#endif
-#if '@' < 0
-    case '@' + 256:
-#endif
-#if '[' < 0
-    case '[' + 256:
-#endif
-#if '\\' < 0
-    case '\\' + 256:
-#endif
-#if ']' < 0
-    case ']' + 256:
-#endif
-#if '^' < 0
-    case '^' + 256:
-#endif
-#if '_' < 0
-    case '_' + 256:
-#endif
-#if '`' < 0
-    case '`' + 256:
-#endif
-#if '{' < 0
-    case '{' + 256:
-#endif
-#if '|' < 0
-    case '|' + 256:
-#endif
-#if '}' < 0
-    case '}' + 256:
-#endif
-#if '~' < 0
-    case '~' + 256:
-#endif
+    _C_CTYPE_PUNCT:
       return true;
-
     default:
       return false;
     }
@@ -736,7 +328,6 @@ c_isxdigit (int c)
     _C_CTYPE_DIGIT:
     _C_CTYPE_A_THRU_F:
       return true;
-
     default:
       return false;
     }
@@ -747,14 +338,8 @@ c_tolower (int c)
 {
   switch (c)
     {
-    _C_CTYPE_UPPER_N (0):
-#if _C_CTYPE_SIGNED_EBCDIC
-      c += 256;
-      /* Fall through.  */
-    _C_CTYPE_UPPER_N (256):
-#endif
+    _C_CTYPE_UPPER:
       return c - 'A' + 'a';
-
     default:
       return c;
     }
@@ -765,14 +350,8 @@ c_toupper (int c)
 {
   switch (c)
     {
-    _C_CTYPE_LOWER_N (0):
-#if _C_CTYPE_SIGNED_EBCDIC
-      c += 256;
-      /* Fall through.  */
-    _C_CTYPE_LOWER_N (256):
-#endif
+    _C_CTYPE_LOWER:
       return c - 'a' + 'A';
-
     default:
       return c;
     }
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index c6115b6..ce1e793 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -52,7 +52,10 @@
 #undef _Alignas
 #undef _Alignof
 
-#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
+/* GCC releases before GCC 4.9 had a bug in _Alignof.  See GCC bug 52023
+   <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.  */
+#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
+     || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9)))
 # ifdef __cplusplus
 #  if 201103 <= __cplusplus
 #   define _Alignof(type) alignof (type)
diff --git a/lib/time_rz.c b/lib/time_rz.c
index f94893a..a89b7e7 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -90,8 +90,7 @@ extend_abbrs (char *abbrs, char const *abbr, size_t abbr_size)
 }
 
 /* Return a newly allocated time zone for NAME, or NULL on failure.
-   As a special case, return a nonzero constant for wall clock time, a
-   constant that survives freeing.  */
+   A null NAME stands for wall clock time (which is like unset TZ).  */
 timezone_t
 tzalloc (char const *name)
 {
@@ -288,10 +287,8 @@ localtime_rz (timezone_t tz, time_t const *t, struct tm 
*tm)
       timezone_t old_tz = set_tz (tz);
       if (old_tz)
         {
-          tm = localtime_r (t, tm);
-          if (tm && !save_abbr (tz, tm))
-            tm = NULL;
-          if (revert_tz (old_tz))
+          bool abbr_saved = localtime_r (t, tm) && save_abbr (tz, tm);
+          if (revert_tz (old_tz) && abbr_saved)
             return tm;
         }
       return NULL;
diff --git a/lib/u64.c b/lib/u64.c
index 04cf7a2..1e3854d 100644
--- a/lib/u64.c
+++ b/lib/u64.c
@@ -1,3 +1,4 @@
 #include <config.h>
 #define _GL_U64_INLINE _GL_EXTERN_INLINE
 #include "u64.h"
+typedef int dummy;
diff --git a/lib/unistd.c b/lib/unistd.c
index 6c6a8e2..72bad1c 100644
--- a/lib/unistd.c
+++ b/lib/unistd.c
@@ -1,3 +1,4 @@
 #include <config.h>
 #define _GL_UNISTD_INLINE _GL_EXTERN_INLINE
 #include "unistd.h"
+typedef int dummy;
diff --git a/lisp/ChangeLog.17 b/lisp/ChangeLog.17
index a40f8f3..8a255d7 100644
--- a/lisp/ChangeLog.17
+++ b/lisp/ChangeLog.17
@@ -10383,13 +10383,13 @@
        (todo-move-category): Keep the moved category's name unless the
        file moved to already has a category with that name.  If the
        numerically last category of the source file was moved, make the
-       first category current to avoid selecting a nonexisting category.
+       first category current to avoid selecting a nonexistent category.
        (todo-merge-category): Fix implementation to make merging to a
        category in another file work as documented.  Eliminate now
        insufficient and unnecessary renaming of archive category, correct
        document string accordingly, and clarify it.  If the numerically
        last category of the source file was merged, make the first
-       category current to avoid selecting a nonexisting category.
+       category current to avoid selecting a nonexistent category.
        (todo-archive-done-item): When there are marked items and point
        happens to be on an unmarked item, ignore the latter.  Don't leave
        point below last item after archiving marked items.
diff --git a/lisp/ChangeLog.5 b/lisp/ChangeLog.5
index 85f8fc1..6103eaf 100644
--- a/lisp/ChangeLog.5
+++ b/lisp/ChangeLog.5
@@ -8261,7 +8261,7 @@
        * rmail.el (rmail-mode-map): Add "Get New Mail" menu item under Mail.
 
        * compile.el (compilation-next-error-locus): Don't call
-       compilation-forget-errors if compilation is still runing.
+       compilation-forget-errors if compilation is still running.
 
 1994-07-11  Erik Naggum  (address@hidden)
 
diff --git a/lisp/cedet/semantic/senator.el b/lisp/cedet/semantic/senator.el
index 372e1d9..544abff 100644
--- a/lisp/cedet/semantic/senator.el
+++ b/lisp/cedet/semantic/senator.el
@@ -813,7 +813,7 @@ Use a senator search function when semantic isearch mode is 
enabled."
    (concat (if senator-isearch-semantic-mode
                "senator-"
              "")
-           (cond (isearch-word "word-")
+           (cond (isearch-regexp-function "word-")
                  (isearch-regexp "re-")
                  (t ""))
            "search-"
diff --git a/lisp/color.el b/lisp/color.el
index d572222..97656ca 100644
--- a/lisp/color.el
+++ b/lisp/color.el
@@ -93,7 +93,7 @@ resulting list."
   "Compute hue from V1 and V2 H.
 Used internally by `color-hsl-to-rgb'."
   (cond
-   ((< h (/ 1.0 6))   (+ v1 (* (- v2 v1) h 6.0)))
+   ((< h (/ 6.0))     (+ v1 (* (- v2 v1) h 6.0)))
    ((< h 0.5)         v2)
    ((< h (/ 2.0 3))   (+ v1 (* (- v2 v1) (- (/ 2.0 3) h) 6.0)))
    (t                 v1)))
@@ -110,9 +110,9 @@ inclusive."
                 (- (+ L S) (* L S))))
           (m1 (- (* 2.0 L) m2)))
       (list
-       (color-hue-to-rgb m1 m2 (mod (+ H (/ 1.0 3)) 1))
+       (color-hue-to-rgb m1 m2 (mod (+ H (/ 3.0)) 1))
        (color-hue-to-rgb m1 m2 H)
-       (color-hue-to-rgb m1 m2 (mod (- H (/ 1.0 3)) 1))))))
+       (color-hue-to-rgb m1 m2 (mod (- H (/ 3.0)) 1))))))
 
 (defun color-complement-hex (color)
   "Return the color that is the complement of COLOR, in hexadecimal format."
@@ -199,13 +199,13 @@ RED, GREEN and BLUE should be between 0.0 and 1.0, 
inclusive."
         (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z))))
     (list (if (<= r 0.0031308)
               (* 12.92 r)
-            (- (* 1.055 (expt r (/ 1 2.4))) 0.055))
+            (- (* 1.055 (expt r (/ 2.4))) 0.055))
           (if (<= g 0.0031308)
               (* 12.92 g)
-            (- (* 1.055 (expt g (/ 1 2.4))) 0.055))
+            (- (* 1.055 (expt g (/ 2.4))) 0.055))
           (if (<= b 0.0031308)
               (* 12.92 b)
-            (- (* 1.055 (expt b (/ 1 2.4))) 0.055)))))
+            (- (* 1.055 (expt b (/ 2.4))) 0.055)))))
 
 (defconst color-d65-xyz '(0.950455 1.0 1.088753)
   "D65 white point in CIE XYZ.")
@@ -222,13 +222,13 @@ conversion.  If omitted or nil, use `color-d65-xyz'."
              (yr (/ Y Yr))
              (zr (/ Z Zr))
              (fx (if (> xr color-cie-ε)
-                     (expt xr (/ 1 3.0))
+                     (expt xr (/ 3.0))
                    (/ (+ (* color-cie-κ xr) 16) 116.0)))
              (fy (if (> yr color-cie-ε)
-                     (expt yr (/ 1 3.0))
+                     (expt yr (/ 3.0))
                    (/ (+ (* color-cie-κ yr) 16) 116.0)))
              (fz (if (> zr color-cie-ε)
-                     (expt zr (/ 1 3.0))
+                     (expt zr (/ 3.0))
                    (/ (+ (* color-cie-κ zr) 16) 116.0))))
         (list
          (- (* 116 fy) 16)                  ; L
diff --git a/lisp/custom.el b/lisp/custom.el
index e212e32..c5d0e65 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -1120,7 +1120,7 @@ directory first---see `custom-theme-load-path'."
   :group 'customize
   :version "22.1")
 
-(defcustom custom-theme-load-path (list 'custom-theme-directory t)
+(defvar custom-theme-load-path (list 'custom-theme-directory t)
   "List of directories to search for custom theme files.
 When loading custom themes (e.g. in `customize-themes' and
 `load-theme'), Emacs searches for theme files in the specified
@@ -1132,13 +1132,11 @@ order.  Each element in the list should be one of the 
following:
 - a directory name (a string).
 
 Each theme file is named THEME-theme.el, where THEME is the theme
-name."
-  :type '(repeat (choice (const :tag "custom-theme-directory"
-                               custom-theme-directory)
-                        (const :tag "Built-in theme directory" t)
-                        directory))
-  :group 'customize
-  :version "24.1")
+name.
+
+This variable is designed for use in lisp code (including
+external packages).  For manual user customizations, use
+`custom-theme-directory' instead.")
 
 (defvar custom--inhibit-theme-enable nil
   "Whether the custom-theme-set-* functions act immediately.
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index a67b11f..46d40d2 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -762,12 +762,12 @@ can be produced by `dired-get-marked-files', for example."
 
 
 (defun dired-check-process (msg program &rest arguments)
-;  "Display MSG while running PROGRAM, and check for output.
-;Remaining arguments are strings passed as command arguments to PROGRAM.
-; On error, insert output
-; in a log buffer and return the offending ARGUMENTS or PROGRAM.
-; Caller can cons up a list of failed args.
-;Else returns nil for success."
+  "Display MSG while running PROGRAM, and check for output.
+Remaining arguments are strings passed as command arguments to PROGRAM.
+On error, insert output
+in a log buffer and return the offending ARGUMENTS or PROGRAM.
+Caller can cons up a list of failed args.
+Else returns nil for success."
   (let (err-buffer err (dir default-directory))
     (message "%s..." msg)
     (save-excursion
@@ -785,6 +785,26 @@ can be produced by `dired-get-marked-files', for example."
        (kill-buffer err-buffer)
        (message "%s...done" msg)
        nil))))
+
+(defun dired-shell-command (cmd)
+  "Run CMD, and check for output.
+On error, pop up the log buffer.
+Return the result of `process-file' - zero for success."
+  (let ((out-buffer " *dired-check-process output*")
+        (dir default-directory))
+    (with-current-buffer (get-buffer-create out-buffer)
+      (erase-buffer)
+      (let* ((default-directory dir)
+             (res (process-file
+                   shell-file-name
+                   nil
+                   t
+                   nil
+                   shell-command-switch
+                   cmd)))
+        (unless (zerop res)
+          (pop-to-buffer out-buffer))
+        res))))
 
 ;; Commands that delete or redisplay part of the dired buffer.
 
@@ -864,7 +884,12 @@ command with a prefix argument (the value does not 
matter)."
       from-file)))
 
 (defvar dired-compress-file-suffixes
-  '(("\\.gz\\'" "" "gunzip")
+  '(
+    ;; "tar -zxf" isn't used because it's not available on the
+    ;; Solaris10 version of tar. Solaris10 becomes obsolete in 2021.
+    ;; Same thing on AIX 7.1.
+    ("\\.tar\\.gz\\'" "" "gzip -dc %i | tar -xv")
+    ("\\.gz\\'" "" "gunzip")
     ("\\.tgz\\'" ".tar" "gunzip")
     ("\\.Z\\'" "" "uncompress")
     ;; For .z, try gunzip.  It might be an old gzip file,
@@ -874,8 +899,11 @@ command with a prefix argument (the value does not 
matter)."
     ("\\.tbz\\'" ".tar" "bunzip2")
     ("\\.bz2\\'" "" "bunzip2")
     ("\\.xz\\'" "" "unxz")
+    ("\\.zip\\'" "" "unzip -o -d %o %i")
     ;; This item controls naming for compression.
-    ("\\.tar\\'" ".tgz" nil))
+    ("\\.tar\\'" ".tgz" nil)
+    ;; This item controls the compression of directories
+    (":" ".tar.gz" "tar -c %i | gzip -c9 > %o"))
   "Control changes in file name suffixes for compression and uncompression.
 Each element specifies one transformation rule, and has the form:
   (REGEXP NEW-SUFFIX PROGRAM)
@@ -884,60 +912,137 @@ The new file name is computed by deleting the part that 
matches REGEXP
  (as well as anything after that), then adding NEW-SUFFIX in its place.
 If PROGRAM is non-nil, the rule is an uncompression rule,
 and uncompression is done by running PROGRAM.
-Otherwise, the rule is a compression rule, and compression is done with gzip.")
+
+Within PROGRAM, %i denotes the input file, and %o denotes the
+output file.
+
+Otherwise, the rule is a compression rule, and compression is done with gzip.
+ARGS are command switches passed to PROGRAM.")
+
+(defvar dired-compress-files-alist
+  '(("\\.tar\\.gz\\'" . "tar -c %i | gzip -c9 > %o")
+    ("\\.zip\\'" . "zip %o -r --filesync %i"))
+  "Control the compression shell command for `dired-do-compress-to'.
+
+Each element is (REGEXP . CMD), where REGEXP is the name of the
+archive to which you want to compress, and CMD the the
+corresponding command.
+
+Within CMD, %i denotes the input file(s), and %o denotes the
+output file. %i path(s) are relative, while %o is absolute.")
+
+;;;###autoload
+(defun dired-do-compress-to ()
+  "Compress selected files and directories to an archive.
+You are prompted for the archive name.
+The archiving command is chosen based on the archive name extension and
+`dired-compress-files-alist'."
+  (interactive)
+  (let* ((in-files (dired-get-marked-files))
+         (out-file (read-file-name "Compress to: "))
+         (rule (cl-find-if
+                (lambda (x)
+                  (string-match (car x) out-file))
+                dired-compress-files-alist)))
+    (cond ((not rule)
+           (error
+            "No compression rule found for %s, see 
`dired-compress-files-alist'"
+            out-file))
+          ((and (file-exists-p out-file)
+                (not (y-or-n-p
+                      (format "%s exists, overwrite?"
+                              (abbreviate-file-name out-file)))))
+           (message "Compression aborted"))
+          (t
+           (when (zerop
+                  (dired-shell-command
+                   (replace-regexp-in-string
+                    "%o" out-file
+                    (replace-regexp-in-string
+                     "%i" (mapconcat #'file-name-nondirectory in-files " ")
+                     (cdr rule)))))
+             (message "Compressed %d file(s) to %s"
+                      (length in-files)
+                      (file-name-nondirectory out-file)))))))
 
 ;;;###autoload
 (defun dired-compress-file (file)
-  ;; Compress or uncompress FILE.
-  ;; Return the name of the compressed or uncompressed file.
-  ;; Return nil if no change in files.
+  "Compress or uncompress FILE.
+Return the name of the compressed or uncompressed file.
+Return nil if no change in files."
   (let ((handler (find-file-name-handler file 'dired-compress-file))
-       suffix newname
-       (suffixes dired-compress-file-suffixes))
+        suffix newname
+        (suffixes dired-compress-file-suffixes)
+        command)
     ;; See if any suffix rule matches this file name.
     (while suffixes
       (let (case-fold-search)
-       (if (string-match (car (car suffixes)) file)
-           (setq suffix (car suffixes) suffixes nil))
-       (setq suffixes (cdr suffixes))))
+        (if (string-match (car (car suffixes)) file)
+            (setq suffix (car suffixes) suffixes nil))
+        (setq suffixes (cdr suffixes))))
     ;; If so, compute desired new name.
     (if suffix
-       (setq newname (concat (substring file 0 (match-beginning 0))
-                             (nth 1 suffix))))
+        (setq newname (concat (substring file 0 (match-beginning 0))
+                              (nth 1 suffix))))
     (cond (handler
-          (funcall handler 'dired-compress-file file))
-         ((file-symlink-p file)
-          nil)
-         ((and suffix (nth 2 suffix))
-          ;; We found an uncompression rule.
-          (if (not (dired-check-process (concat "Uncompressing " file)
-                                        (nth 2 suffix) file))
-              newname))
-         (t
-          ;;; We don't recognize the file as compressed, so compress it.
-          ;;; Try gzip; if we don't have that, use compress.
-          (condition-case nil
-              (let ((out-name (concat file ".gz")))
-                (and (or (not (file-exists-p out-name))
-                         (y-or-n-p
-                          (format "File %s already exists.  Really compress? "
-                                  out-name)))
-                     (not (dired-check-process (concat "Compressing " file)
-                                               "gzip" "-f" file))
-                     (or (file-exists-p out-name)
-                         (setq out-name (concat file ".z")))
-                     ;; Rename the compressed file to NEWNAME
-                     ;; if it hasn't got that name already.
-                     (if (and newname (not (equal newname out-name)))
-                         (progn
-                           (rename-file out-name newname t)
-                           newname)
-                       out-name)))
-            (file-error
-             (if (not (dired-check-process (concat "Compressing " file)
-                                           "compress" "-f" file))
-                 ;; Don't use NEWNAME with `compress'.
-                 (concat file ".Z"))))))))
+           (funcall handler 'dired-compress-file file))
+          ((file-symlink-p file)
+           nil)
+          ((and suffix (setq command (nth 2 suffix)))
+           (if (string-match "%[io]" command)
+               (prog1 (setq newname (file-name-as-directory newname))
+                 (dired-shell-command
+                  (replace-regexp-in-string
+                   "%o" newname
+                   (replace-regexp-in-string
+                    "%i" file
+                    command))))
+             ;; We found an uncompression rule.
+             (when (not
+                    (dired-check-process
+                     (concat "Uncompressing " file)
+                     command
+                     file))
+               newname)))
+          (t
+           ;; We don't recognize the file as compressed, so compress it.
+           ;; Try gzip; if we don't have that, use compress.
+           (condition-case nil
+               (if (file-directory-p file)
+                   (progn
+                     (setq suffix (cdr (assoc ":" 
dired-compress-file-suffixes)))
+                     (when suffix
+                       (let ((out-name (concat file (car suffix)))
+                             (default-directory (file-name-directory file)))
+                         (dired-shell-command
+                          (replace-regexp-in-string
+                           "%o" out-name
+                           (replace-regexp-in-string
+                            "%i" (file-name-nondirectory file)
+                            (cadr suffix))))
+                         out-name)))
+                 (let ((out-name (concat file ".gz")))
+                   (and (or (not (file-exists-p out-name))
+                            (y-or-n-p
+                             (format "File %s already exists.  Really 
compress? "
+                                     out-name)))
+                        (not
+                         (dired-check-process (concat "Compressing " file)
+                                              "gzip" "-f" file))
+                        (or (file-exists-p out-name)
+                            (setq out-name (concat file ".z")))
+                        ;; Rename the compressed file to NEWNAME
+                        ;; if it hasn't got that name already.
+                        (if (and newname (not (equal newname out-name)))
+                            (progn
+                              (rename-file out-name newname t)
+                              newname)
+                          out-name))))
+             (file-error
+              (if (not (dired-check-process (concat "Compressing " file)
+                                            "compress" "-f" file))
+                  ;; Don't use NEWNAME with `compress'.
+                  (concat file ".Z"))))))))
 
 (defun dired-mark-confirm (op-symbol arg)
   ;; Request confirmation from the user that the operation described
@@ -1121,15 +1226,16 @@ See Info node `(emacs)Subdir switches' for more 
details."
   ;; here is faster than with dired-add-entry's optional arg).
   ;; Does not update other dired buffers.  Use dired-relist-entry for that.
   (let* ((opoint (line-beginning-position))
-        (char (char-after opoint))
-        (buffer-read-only))
+         (char (char-after opoint))
+         (buffer-read-only))
     (delete-region opoint (progn (forward-line 1) (point)))
     (if file
-       (progn
-         (dired-add-entry file nil t)
-         ;; Replace space by old marker without moving point.
-         ;; Faster than goto+insdel inside a save-excursion?
-         (subst-char-in-region opoint (1+ opoint) ?\040 char))))
+        (progn
+          (dired-add-entry file nil t)
+          ;; 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)))))
   (dired-move-to-filename))
 
 ;;;###autoload
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 1b69091..b6704bb 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -402,6 +402,7 @@ See variables `dired-texinfo-unclean-extensions',
                                 dired-tex-unclean-extensions
                                 (list ".dvi"))))
 
+(defvar tar-superior-buffer)
 ;;; JUMP.
 
 ;;;###autoload
@@ -416,30 +417,32 @@ Interactively with prefix argument, read FILE-NAME and
 move to its line in dired."
   (interactive
    (list nil (and current-prefix-arg
-                 (read-file-name "Jump to Dired file: "))))
-  (let* ((file (or file-name buffer-file-name))
-         (dir (if file (file-name-directory file) default-directory)))
-    (if (and (eq major-mode 'dired-mode) (null file-name))
-        (progn
-          (setq dir (dired-current-directory))
-          (dired-up-directory other-window)
-          (unless (dired-goto-file dir)
-              ;; refresh and try again
-            (dired-insert-subdir (file-name-directory dir))
-            (dired-goto-file dir)))
-      (if other-window
-          (dired-other-window dir)
-        (dired dir))
-      (if file
-          (or (dired-goto-file file)
+                  (read-file-name "Jump to Dired file: "))))
+  (if (bound-and-true-p tar-subfile-mode)
+      (switch-to-buffer tar-superior-buffer)
+    (let* ((file (or file-name buffer-file-name))
+           (dir (if file (file-name-directory file) default-directory)))
+      (if (and (eq major-mode 'dired-mode) (null file-name))
+          (progn
+            (setq dir (dired-current-directory))
+            (dired-up-directory other-window)
+            (unless (dired-goto-file dir)
               ;; refresh and try again
-              (progn
-                (dired-insert-subdir (file-name-directory file))
-                (dired-goto-file file))
-              ;; Toggle omitting, if it is on, and try again.
-             (when dired-omit-mode
-                (dired-omit-mode)
-                (dired-goto-file file)))))))
+              (dired-insert-subdir (file-name-directory dir))
+              (dired-goto-file dir)))
+        (if other-window
+            (dired-other-window dir)
+          (dired dir))
+        (if file
+            (or (dired-goto-file file)
+                ;; refresh and try again
+                (progn
+                  (dired-insert-subdir (file-name-directory file))
+                  (dired-goto-file file))
+                ;; Toggle omitting, if it is on, and try again.
+                (when dired-omit-mode
+                  (dired-omit-mode)
+                  (dired-goto-file file))))))))
 
 ;;;###autoload
 (defun dired-jump-other-window (&optional file-name)
diff --git a/lisp/dired.el b/lisp/dired.el
index b78b632..0fe2349 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1466,6 +1466,7 @@ Do so according to the former subdir alist 
OLD-SUBDIR-ALIST."
     (define-key map "T" 'dired-do-touch)
     (define-key map "X" 'dired-do-shell-command)
     (define-key map "Z" 'dired-do-compress)
+    (define-key map "c" 'dired-do-compress-to)
     (define-key map "!" 'dired-do-shell-command)
     (define-key map "&" 'dired-do-async-shell-command)
     ;; Comparison commands
@@ -3896,7 +3897,7 @@ Ask means pop up a menu for the user to select one of 
copy, move or link."
 
 ;;; Start of automatically extracted autoloads.
 
-;;;### (autoloads nil "dired-aux" "dired-aux.el" 
"637aadf6baffb10be036ba4cec2372f9")
+;;;### (autoloads nil "dired-aux" "dired-aux.el" 
"ce82e4e2d385923def05089e8aedb519")
 ;;; Generated autoloads from dired-aux.el
 
 (autoload 'dired-diff "dired-aux" "\
@@ -4088,8 +4089,18 @@ command with a prefix argument (the value does not 
matter).
 
 \(fn &optional ARG FMT)" t nil)
 
-(autoload 'dired-compress-file "dired-aux" "\
+(autoload 'dired-do-compress-to "dired-aux" "\
+Compress selected files and directories to an archive.
+You are prompted for the archive name.
+The archiving command is chosen based on the archive name extension and
+`dired-compress-files-alist'.
+
+\(fn)" t nil)
 
+(autoload 'dired-compress-file "dired-aux" "\
+Compress or uncompress FILE.
+Return the name of the compressed or uncompressed file.
+Return nil if no change in files.
 
 \(fn FILE)" nil nil)
 
@@ -4399,7 +4410,7 @@ instead.
 
 ;;;***
 
-;;;### (autoloads nil "dired-x" "dired-x.el" 
"63be23901985afd2a9aadc64f2aacf37")
+;;;### (autoloads nil "dired-x" "dired-x.el" 
"06f532e2e812fa1cb10ade31249e9700")
 ;;; Generated autoloads from dired-x.el
 
 (autoload 'dired-jump "dired-x" "\
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 5f1c94a..edc0014 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -440,10 +440,23 @@ Typically \"page-%s.png\".")
 
 (defun doc-view-revert-buffer (&optional ignore-auto noconfirm)
   "Like `revert-buffer', but preserves the buffer's current modes."
-  ;; FIXME: this should probably be moved to files.el and used for
-  ;; most/all "g" bindings to revert-buffer.
   (interactive (list (not current-prefix-arg)))
-  (revert-buffer ignore-auto noconfirm 'preserve-modes))
+  (cl-labels ((revert ()
+                      (let (revert-buffer-function)
+                        (revert-buffer ignore-auto noconfirm 
'preserve-modes))))
+    (if (and (eq 'pdf doc-view-doc-type)
+             (executable-find "pdfinfo"))
+        ;; We don't want to revert if the PDF file is corrupted which
+        ;; might happen when it it currently recompiled from a tex
+        ;; file.  (TODO: We'd like to have something like that also
+        ;; for other types, at least PS, but I don't know a good way
+        ;; to test if a PS file is complete.)
+        (if (= 0 (call-process (executable-find "pdfinfo") nil nil nil
+                               doc-view--buffer-file-name))
+            (revert)
+          (when (called-interactively-p 'interactive)
+            (message "Can't revert right now because the file is corrupted.")))
+      (revert))))
 
 
 (easy-menu-define doc-view-menu doc-view-mode-map
@@ -1648,7 +1661,7 @@ If BACKWARD is non-nil, jump to the previous match."
                    ;; Microsoft Office formats (also handled by the odf
                    ;; conversion chain).
                    ("doc" odf) ("docx" odf) ("xls" odf) ("xlsx" odf)
-                   ("ppt" odf) ("pps" odf) ("pptx" odf))
+                   ("ppt" odf) ("pps" odf) ("pptx" odf) ("rtf" odf))
                 t))))
        (content-types
         (save-excursion
@@ -1766,6 +1779,8 @@ 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-hook 'change-major-mode-hook
              (lambda ()
                (doc-view-kill-proc)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 6f7ba33..d138eff 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3617,8 +3617,8 @@ discarding."
 
 (defun byte-compile-quo (form)
   (let ((len (length form)))
-    (cond ((<= len 2)
-          (byte-compile-subr-wrong-args form "2 or more"))
+    (cond ((< len 2)
+          (byte-compile-subr-wrong-args form "1 or more"))
          ((= len 3)
           (byte-compile-two-args form))
          (t
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index dddfca7..afa021d 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -497,7 +497,7 @@ This sets the values of: `cl-most-positive-float', 
`cl-most-negative-float',
        (setq cl-least-positive-normalized-float y
              cl-least-negative-normalized-float (- y))
        ;; Divide down until value underflows to zero.
-       (setq x (/ 1 z) y x)
+       (setq x (/ z) y x)
        (while (condition-case _ (> (/ x 2) 0) (arith-error nil))
          (setq x (/ x 2)))
        (setq cl-least-positive-float x
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 2dae86e..bbc8e15 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -410,6 +410,7 @@ return any documentation.")
 
 ;; Prime the command list.
 (eldoc-add-command-completions
+ "back-to-indentation"
  "backward-" "beginning-of-" "delete-other-windows" "delete-window"
  "down-list" "end-of-" "exchange-point-and-mark" "forward-" "goto-"
  "handle-select-window" "indent-for-tab-command" "left-" "mark-page"
diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el
index ea56efe..cc437e0 100644
--- a/lisp/emacs-lisp/map.el
+++ b/lisp/emacs-lisp/map.el
@@ -46,11 +46,15 @@
 
 (pcase-defmacro map (&rest args)
   "pcase pattern matching map elements.
+
 Matches if the object is a map (list, hash-table or array), and
-binds values from ARGS to their corresponding elements of the map.
+each PATTERN matches the corresponding elements of the map.
+
+Supernumerary elements of the map are ignored if fewer ARGS are
+given, and the match does not fail.
 
-ARGS can be a list elements of the form (KEY PAT), in which case
-KEY in an unquoted form.
+ARGS can be a list of the form (KEY PAT), in which case KEY in an
+unquoted form.
 
 ARGS can also be a list of symbols, which stands for ('SYMBOL
 SYMBOL)."
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 89f2a1a..2dbcdf6 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1364,10 +1364,18 @@ If the archive version is too new, signal an error."
       (dolist (package contents)
         (package--add-to-archive-contents package archive)))))
 
+(defvar package--old-archive-priorities nil
+  "Store currently used `package-archive-priorities'.
+This is the value of `package-archive-priorities' last time
+`package-read-all-archive-contents' was called.  It can be used
+by arbitrary functions to decide whether it is necessary to call
+it again.")
+
 (defun package-read-all-archive-contents ()
   "Re-read `archive-contents', if it exists.
 If successful, set `package-archive-contents'."
   (setq package-archive-contents nil)
+  (setq package--old-archive-priorities package-archive-priorities)
   (dolist (archive package-archives)
     (package-read-archive-contents (car archive))))
 
@@ -2675,6 +2683,8 @@ KEYWORDS should be nil or a list of keywords."
             (push pkg info-list)))))
 
     ;; Available and disabled packages:
+    (unless (equal package--old-archive-priorities package-archive-priorities)
+      (package-read-all-archive-contents))
     (dolist (elt package-archive-contents)
       (let ((name (car elt)))
         ;; To be displayed it must be in PACKAGES;
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index a63447d..f5189c7 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -4,7 +4,7 @@
 
 ;; Author: Nicolas Petton <address@hidden>
 ;; Keywords: sequences
-;; Version: 2.0
+;; Version: 2.1
 ;; Package: seq
 
 ;; Maintainer: address@hidden
@@ -71,13 +71,16 @@ Evaluate BODY with VAR bound to each element of SEQ, in 
turn.
              ,@body)
            ,(cadr spec)))
 
-(pcase-defmacro seq (&rest args)
+(pcase-defmacro seq (&rest patterns)
   "pcase pattern matching sequence elements.
+
 Matches if the object is a sequence (list, string or vector), and
-binds each element of ARGS to the corresponding element of the
-sequence."
+each PATTERN matches the corresponding element of the sequence.
+
+Supernumerary elements of the sequence are ignored if fewer
+PATTERNS are given, and the match does not fail."
   `(and (pred seq-p)
-        ,@(seq--make-pcase-bindings args)))
+        ,@(seq--make-pcase-bindings patterns)))
 
 (defmacro seq-let (args seq &rest body)
   "Bind the variables in ARGS to the elements of SEQ then evaluate BODY.
@@ -291,12 +294,23 @@ found or not."
     count))
 
 (cl-defgeneric seq-contains (seq elt &optional testfn)
-  "Return the first element in SEQ that equals to ELT.
+  "Return the first element in SEQ that is equal to ELT.
 Equality is defined by TESTFN if non-nil or by `equal' if nil."
   (seq-some (lambda (e)
               (funcall (or testfn #'equal) elt e))
             seq))
 
+(cl-defgeneric seq-position (seq elt &optional testfn)
+  "Return the index of the first element in SEQ that is equal to ELT.
+Equality is defined by TESTFN if non-nil or by `equal' if nil."
+  (let ((index 0))
+    (catch 'seq--break
+      (seq-doseq (e seq)
+        (when (funcall (or testfn #'equal) e elt)
+          (throw 'seq--break index))
+        (setq index (1+ index)))
+      nil)))
+
 (cl-defgeneric seq-uniq (seq &optional testfn)
   "Return a list of the elements of SEQ with duplicates removed.
 TESTFN is used to compare elements, or `equal' if TESTFN is nil."
diff --git a/lisp/faces.el b/lisp/faces.el
index 4e7f1a4..de8a0b5 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -1598,6 +1598,13 @@ is given, in which case return its value instead."
          result
        no-match-retval))))
 
+;; When over 80 faces get processed at frame creation time, all but
+;; one specifying all attributes as "unspecified", generating this
+;; list every time means a lot of consing.
+(defconst face--attributes-unspecified
+  (apply 'append
+         (mapcar (lambda (x) (list (car x) 'unspecified))
+                 face-attribute-name-alist)))
 
 (defun face-spec-reset-face (face &optional frame)
   "Reset all attributes of FACE on FRAME to unspecified."
@@ -1622,9 +1629,7 @@ is given, in which case return its value instead."
                                     "unspecified-fg"
                                   "unspecified-bg")))))
           ;; For all other faces, unspecify all attributes.
-          (apply 'append
-                 (mapcar (lambda (x) (list (car x) 'unspecified))
-                         face-attribute-name-alist)))))
+           face--attributes-unspecified)))
 
 (defun face-spec-set (face spec &optional spec-type)
   "Set the face spec SPEC for FACE.
diff --git a/lisp/files.el b/lisp/files.el
index 8565aa8..d0e3e68 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4055,14 +4055,19 @@ such as SELinux context, list of ACL entries, etc."
   "Set extended attributes of file FILENAME to ATTRIBUTES.
 
 ATTRIBUTES must be an alist of file attributes as returned by
-`file-extended-attributes'."
-  (dolist (elt attributes)
-    (let ((attr (car elt))
-         (val (cdr elt)))
-      (cond ((eq attr 'acl)
-            (set-file-acl filename val))
-           ((eq attr 'selinux-context)
-            (set-file-selinux-context filename val))))))
+`file-extended-attributes'.
+Value is t if the function succeeds in setting the attributes."
+  (let (result rv)
+    (dolist (elt attributes)
+      (let ((attr (car elt))
+           (val (cdr elt)))
+       (cond ((eq attr 'acl)
+               (setq rv (set-file-acl filename val)))
+             ((eq attr 'selinux-context)
+               (setq rv (set-file-selinux-context filename val))))
+        (setq result (or result rv))))
+
+    result))
 
 (defun backup-buffer ()
   "Make a backup of the disk file visited by the current buffer, if 
appropriate.
diff --git a/lisp/frame.el b/lisp/frame.el
index bbf0a63..b9e63d5 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -461,7 +461,7 @@ there (in decreasing order of priority)."
                    (cons (1- (car frame-size-history))
                          (cons
                           (list frame-initial-frame
-                                "frame-notice-user-settings"
+                                "FRAME-NOTICE-USER"
                                 nil newparms)
                           (cdr frame-size-history)))))
 
@@ -702,7 +702,7 @@ the new frame according to its own rules."
     (when (numberp (car frame-size-history))
       (setq frame-size-history
            (cons (1- (car frame-size-history))
-                 (cons (list frame "make-frame")
+                 (cons (list frame "MAKE-FRAME")
                        (cdr frame-size-history)))))
 
     ;; We can run `window-configuration-change-hook' for this frame now.
@@ -1382,6 +1382,27 @@ and width values are in pixels.
        (cons 'internal-border-width
             (frame-parameter frame 'internal-border-width)))))))
 
+(defun frame--size-history (&optional frame)
+  "Print history of resize operations for FRAME.
+Print prettified version of `frame-size-history' into a buffer
+called *frame-size-history*.  Optional argument FRAME denotes the
+frame whose history will be printed.  FRAME defaults to the
+selected frame."
+  (let ((history (reverse frame-size-history))
+       entry)
+    (setq frame (window-normalize-frame 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)))
+       (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"))))))
+
 (declare-function x-frame-edges "xfns.c" (&optional frame type))
 (declare-function w32-frame-edges "w32fns.c" (&optional frame type))
 (declare-function ns-frame-edges "nsfns.m" (&optional frame type))
diff --git a/lisp/gnus/mailcap.el b/lisp/gnus/mailcap.el
index 9f84413..11a071b 100644
--- a/lisp/gnus/mailcap.el
+++ b/lisp/gnus/mailcap.el
@@ -96,11 +96,9 @@ This is a compatibility function for different Emacsen."
       (type . "application/vnd.ms-excel"))
      ("x-x509-ca-cert"
       (viewer . ssl-view-site-cert)
-      (test . (fboundp 'ssl-view-site-cert))
       (type . "application/x-x509-ca-cert"))
      ("x-x509-user-cert"
       (viewer . ssl-view-user-cert)
-      (test . (fboundp 'ssl-view-user-cert))
       (type . "application/x-x509-user-cert"))
      ("octet-stream"
       (viewer . mailcap-save-binary-file)
@@ -129,23 +127,18 @@ This is a compatibility function for different Emacsen."
       (type   . "application/x-tar"))
      ("x-latex"
       (viewer . tex-mode)
-      (test   . (fboundp 'tex-mode))
       (type   . "application/x-latex"))
      ("x-tex"
       (viewer . tex-mode)
-      (test   . (fboundp 'tex-mode))
       (type   . "application/x-tex"))
      ("latex"
       (viewer . tex-mode)
-      (test   . (fboundp 'tex-mode))
       (type   . "application/latex"))
      ("tex"
       (viewer . tex-mode)
-      (test   . (fboundp 'tex-mode))
       (type   . "application/tex"))
      ("texinfo"
       (viewer . texinfo-mode)
-      (test   . (fboundp 'texinfo-mode))
       (type   . "application/tex"))
      ("zip"
       (viewer . mailcap-save-binary-file)
@@ -155,8 +148,7 @@ This is a compatibility function for different Emacsen."
      ("pdf"
       (viewer . pdf-view-mode)
       (type . "application/pdf")
-      (test . (and (fboundp 'pdf-view-mode)
-                  (eq window-system 'x))))
+      (test . (eq window-system 'x)))
      ("pdf"
       (viewer . doc-view-mode)
       (type . "application/pdf")
@@ -201,7 +193,6 @@ This is a compatibility function for different Emacsen."
       ("copiousoutput"))
      ("sieve"
       (viewer . sieve-mode)
-      (test   . (fboundp 'sieve-mode))
       (type   . "application/sieve"))
      ("pgp-keys"
       (viewer . "gpg --import --interactive --verbose")
@@ -222,7 +213,6 @@ This is a compatibility function for different Emacsen."
       (type   . "message/rfc822"))
      ("rfc-*822"
       (viewer . vm-mode)
-      (test   . (fboundp 'vm-mode))
       (type   . "message/rfc822"))
      ("rfc-*822"
       (viewer . view-mode)
@@ -259,18 +249,15 @@ This is a compatibility function for different Emacsen."
     ("text"
      ("plain"
       (viewer  . view-mode)
-      (test    . (fboundp 'view-mode))
       (type    . "text/plain"))
      ("plain"
       (viewer  . fundamental-mode)
       (type    . "text/plain"))
      ("enriched"
       (viewer . enriched-decode)
-      (test   . (fboundp 'enriched-decode))
       (type   . "text/enriched"))
      ("dns"
       (viewer . dns-mode)
-      (test   . (fboundp 'dns-mode))
       (type   . "text/dns")))
     ("video"
      ("mpeg"
@@ -287,8 +274,7 @@ This is a compatibility function for different Emacsen."
     ("archive"
      ("tar"
       (viewer . tar-mode)
-      (type . "archive/tar")
-      (test . (fboundp 'tar-mode)))))
+      (type . "archive/tar"))))
   "The mailcap structure is an assoc list of assoc lists.
 1st assoc list is keyed on the major content-type
 2nd assoc list is keyed on the minor content-type (which can be a regexp)
@@ -309,9 +295,9 @@ attribute name (viewer, test, etc).  This looks like:
   FLAG)
 
 Where VIEWERINFO specifies how the content-type is viewed.  Can be
-a string, in which case it is run through a shell, with
-appropriate parameters, or a symbol, in which case the symbol is
-`funcall'ed, with the buffer as an argument.
+a string, in which case it is run through a shell, with appropriate
+parameters, or a symbol, in which case the symbol is `funcall'ed if
+and only if it exists as a function, with the buffer as an argument.
 
 TESTINFO is a test for the viewer's applicability, or nil.  If nil, it
 means the viewer is always valid.  If it is a Lisp function, it is
@@ -555,8 +541,11 @@ MAILCAPS if set; otherwise (on Unix) use the path from RFC 
1524, plus
       results)))
 
 (defun mailcap-mailcap-entry-passes-test (info)
-  "Return non-nil if mailcap entry INFO passes its test clause.
-Also return non-nil if no test clause is present."
+  "Replace the test clause of INFO itself with a boolean for some cases.
+This function supports only `test -n $DISPLAY' and `test -z $DISPLAY',
+replaces them with t or nil.  As for others or if INFO has a interactive
+spec (needsterm, needsterminal, or needsx11) but DISPLAY is not set,
+the test clause will be unchanged."
   (let ((test (assq 'test info))       ; The test clause
        status)
     (setq status (and test (split-string (cdr test) " ")))
@@ -654,10 +643,12 @@ to supply to the test."
   (let* ((test-info (assq 'test viewer-info))
         (test (cdr test-info))
         (otest test)
-        (viewer (cdr (assoc 'viewer viewer-info)))
+        (viewer (cdr (assq 'viewer viewer-info)))
         (default-directory (expand-file-name "~/"))
         status parsed-test cache result)
-    (cond ((setq cache (assoc test mailcap-viewer-test-cache))
+    (cond ((not (or (stringp viewer) (fboundp viewer)))
+          nil)                         ; Non-existent Lisp function
+         ((setq cache (assoc test mailcap-viewer-test-cache))
           (cadr cache))
          ((not test-info) t)           ; No test clause
          (t
diff --git a/lisp/gnus/nnmail.el b/lisp/gnus/nnmail.el
index 7efb154..f3ba169 100644
--- a/lisp/gnus/nnmail.el
+++ b/lisp/gnus/nnmail.el
@@ -1792,6 +1792,12 @@ See the Info node `(gnus)Fancy Mail Splitting' for more 
details."
   "Read new incoming mail."
   (nnmail-get-new-mail-1 method exit-func temp group nil spool-func))
 
+(defun nnmail-get-new-mail-per-group ()
+  "Tell us whether the mail-sources specify that `nnmail-get-new-mail' should
+be called once per group or once for all groups."
+  (or (assq 'group mail-sources)
+      (assq 'directory mail-sources)))
+
 (defun nnmail-get-new-mail-1 (method exit-func temp
                              group in-group spool-func)
   (let* ((sources mail-sources)
@@ -1804,7 +1810,8 @@ See the Info node `(gnus)Fancy Mail Splitting' for more 
details."
               sources)
       (while (setq source (pop sources))
        ;; Use group's parameter
-       (when (eq (car source) 'group)
+       (when (and (eq (car source) 'group)
+                  group)
          (let ((mail-sources
                 (list
                  (gnus-group-find-parameter
diff --git a/lisp/gnus/nnml.el b/lisp/gnus/nnml.el
index c825e09..33eae1c 100644
--- a/lisp/gnus/nnml.el
+++ b/lisp/gnus/nnml.el
@@ -268,10 +268,35 @@ non-nil.")
                           (max (1+ (- (cdr active) (car active))) 0)
                           (car active) (cdr active) group)))))))
 
+(deffoo nnml-retrieve-groups (groups &optional server)
+  (when nnml-get-new-mail
+    (if (nnmail-get-new-mail-per-group)
+       (dolist (group groups)
+         (nnml-request-scan group server))
+      (nnml-request-scan nil server)))
+  (with-current-buffer nntp-server-buffer
+    (erase-buffer)
+    (dolist (group groups)
+      (let* ((entry (assoc group nnml-group-alist))
+            (active (nth 1 entry)))
+       (if (consp active)
+           (insert (format "211 %d %d %d %s\n"
+                           (max (1+ (- (cdr active) (car active))) 0)
+                           (car active) (cdr active) group))))))
+  'group)
+
 (deffoo nnml-request-scan (&optional group server)
   (setq nnml-article-file-alist nil)
   (nnml-possibly-change-directory group server)
-  (nnmail-get-new-mail 'nnml 'nnml-save-incremental-nov nnml-directory group))
+  (cond
+   (group
+    (nnmail-get-new-mail 'nnml 'nnml-save-incremental-nov nnml-directory 
group))
+   ((nnmail-get-new-mail-per-group)
+    (nnml-request-list)
+    (dolist (entry nnml-group-alist)
+      (nnml-request-scan (car entry) server)))
+   (t
+    (nnmail-get-new-mail 'nnml 'nnml-save-incremental-nov nnml-directory 
nil))))
 
 (deffoo nnml-close-group (group &optional server)
   (setq nnml-article-file-alist nil)
diff --git a/lisp/hexl.el b/lisp/hexl.el
index 4aa76d2..499253e 100644
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -406,7 +406,7 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode.
 
 
 (defun hexl-isearch-search-function ()
-  (if (and (not isearch-regexp) (not isearch-word))
+  (if (and (not isearch-regexp) (not isearch-regexp-function))
       (lambda (string &optional bound noerror count)
        (funcall
         (if isearch-forward 're-search-forward 're-search-backward)
diff --git a/lisp/image.el b/lisp/image.el
index d557e39..295b79f 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -735,7 +735,7 @@ for the animation speed.  A negative value means to animate 
in reverse."
           ;; 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 (abs speed)))
+                            (/ 1.0 (abs speed)))
                          time (- (float-time)))
                       image-minimum-frame-delay))
           done)
diff --git a/lisp/info.el b/lisp/info.el
index bd12d56..b11330b 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -2114,14 +2114,14 @@ If DIRECTION is `backward', search in the reverse 
direction."
                   search-whitespace-regexp)))
          (Info-search
           (cond
-           (isearch-word
+           (isearch-regexp-function
             ;; Lax version of word search
             (let ((lax (not (or isearch-nonincremental
                                 (eq (length string)
                                     (length (isearch--state-string
                                              (car isearch-cmds))))))))
-              (if (functionp isearch-word)
-                  (funcall isearch-word string lax)
+              (if (functionp isearch-regexp-function)
+                  (funcall isearch-regexp-function string lax)
                 (word-search-regexp string lax))))
            (isearch-regexp string)
            (t (regexp-quote string)))
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 4fc9b38..6b99da9 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -551,13 +551,16 @@ This is like `describe-bindings', but displays only 
Isearch keys."
 
 (defvar isearch-forward nil)   ; Searching in the forward direction.
 (defvar isearch-regexp nil)    ; Searching for a regexp.
-(defvar isearch-word nil
+(defvar isearch-regexp-function nil
   "Regexp-based search mode for words/symbols.
-If t, do incremental search for a sequence of words, ignoring punctuation.
-If the value is a function (e.g. `isearch-symbol-regexp'), it is called to
-convert the search string to a regexp used by regexp search functions.
-The property `isearch-message-prefix' put on this function specifies the
-prefix string displayed in the search message.")
+If the value is a function (e.g. `isearch-symbol-regexp'), it is
+called to convert a plain search string to a regexp used by
+regexp search functions.
+The symbol property `isearch-message-prefix' put on this function
+specifies the prefix string displayed in the search message.")
+;; We still support setting this to t for backwards compatibility.
+(define-obsolete-variable-alias 'isearch-word
+  'isearch-regexp-function "25.1")
 
 (defvar isearch-lax-whitespace t
   "If non-nil, a space will match a sequence of whitespace chars.
@@ -840,7 +843,7 @@ See the command `isearch-forward-symbol' for more 
information."
 (put 'character-fold-to-regexp 'isearch-message-prefix "char-fold ")
 (defvar character-fold-search)
 
-(defun isearch-mode (forward &optional regexp op-fun recursive-edit word)
+(defun isearch-mode (forward &optional regexp op-fun recursive-edit 
regexp-function)
   "Start Isearch minor mode.
 It is called by the function `isearch-forward' and other related functions.
 
@@ -856,16 +859,16 @@ does not return to the calling function until the search 
is completed.
 To behave this way it enters a recursive-edit and exits it when done
 isearching.
 
-The arg WORD, if t, does incremental search for a sequence of words,
-ignoring punctuation.  If the value is a function, it is called to
-convert the search string to a regexp used by regexp search functions."
+The arg REGEXP-FUNCTION, if non-nil, should be a function.  It is
+used to set the value of `isearch-regexp-function'."
 
   ;; Initialize global vars.
   (setq isearch-forward forward
        isearch-regexp regexp
-       isearch-word (or word (and character-fold-search
-                                   (not regexp)
-                                   'character-fold-to-regexp))
+       isearch-regexp-function (or regexp-function
+                                    (and character-fold-search
+                                         (not regexp)
+                                         'character-fold-to-regexp))
        isearch-op-fun op-fun
        isearch-last-case-fold-search isearch-case-fold-search
        isearch-case-fold-search case-fold-search
@@ -1029,7 +1032,7 @@ NOPUSH is t and EDIT is t."
 
   (if isearch-resume-in-command-history
       (let ((command `(isearch-resume ,isearch-string ,isearch-regexp
-                                     ,isearch-word ,isearch-forward
+                                     ,isearch-regexp-function ,isearch-forward
                                      ,isearch-message
                                      ',isearch-case-fold-search)))
        (unless (equal (car command-history) command)
@@ -1131,7 +1134,7 @@ REGEXP if non-nil says use the regexp search ring."
                  (success isearch-success)
                  (forward isearch-forward)
                  (other-end isearch-other-end)
-                 (word isearch-word)
+                 (word isearch-regexp-function)
                  (error isearch-error)
                  (wrapped isearch-wrapped)
                  (barrier isearch-barrier)
@@ -1157,7 +1160,7 @@ REGEXP if non-nil says use the regexp search ring."
        isearch-success (isearch--state-success cmd)
        isearch-forward (isearch--state-forward cmd)
        isearch-other-end (isearch--state-other-end cmd)
-       isearch-word (isearch--state-word cmd)
+       isearch-regexp-function (isearch--state-word cmd)
        isearch-error (isearch--state-error cmd)
        isearch-wrapped (isearch--state-wrapped cmd)
        isearch-barrier (isearch--state-barrier cmd)
@@ -1213,7 +1216,7 @@ If MSG is non-nil, use variable `isearch-message', 
otherwise `isearch-string'."
   "Exit Isearch mode, run BODY, and reinvoke the pending search.
 You can update the global isearch variables by setting new values to
 `isearch-new-string', `isearch-new-message', `isearch-new-forward',
-`isearch-new-word', `isearch-new-case-fold'."
+`isearch-new-regexp-function', `isearch-new-case-fold'."
   ;; This code is very hairy for several reasons, explained in the code.
   ;; Mainly, isearch-mode must be terminated while editing and then restarted.
   ;; If there were a way to catch any change of buffer from the minibuffer,
@@ -1230,7 +1233,7 @@ You can update the global isearch variables by setting 
new values to
              (isearch-new-string isearch-string)
              (isearch-new-message isearch-message)
              (isearch-new-forward isearch-forward)
-             (isearch-new-word isearch-word)
+             (isearch-new-regexp-function isearch-regexp-function)
              (isearch-new-case-fold isearch-case-fold-search)
 
              (isearch-regexp isearch-regexp)
@@ -1296,13 +1299,13 @@ You can update the global isearch variables by setting 
new values to
                          isearch-regexp
                          isearch-op-fun
                          nil
-                         isearch-word)
+                         isearch-regexp-function)
 
            ;; Copy new local values to isearch globals
            (setq isearch-string isearch-new-string
                  isearch-message isearch-new-message
                  isearch-forward isearch-new-forward
-                 isearch-word isearch-new-word
+                 isearch-regexp-function isearch-new-regexp-function
                  isearch-case-fold-search isearch-new-case-fold))
 
          ;; Empty isearch-string means use default.
@@ -1493,7 +1496,7 @@ Use `isearch-exit' to quit without signaling."
   ;; The status stack is left unchanged.
   (interactive)
   (setq isearch-regexp (not isearch-regexp))
-  (if isearch-regexp (setq isearch-word nil))
+  (if isearch-regexp (setq isearch-regexp-function nil))
   (setq isearch-success t isearch-adjusted t)
   (isearch-update))
 
@@ -1501,26 +1504,30 @@ Use `isearch-exit' to quit without signaling."
   "Toggle word searching on or off."
   ;; The status stack is left unchanged.
   (interactive)
-  (setq isearch-word (if (eq isearch-word t) nil t))
-  (if isearch-word (setq isearch-regexp nil))
+  (setq isearch-regexp-function
+        (if (memq isearch-regexp-function '(t word-search-regexp))
+                                    nil #'word-search-regexp))
+  (when isearch-regexp-function (setq isearch-regexp nil))
   (setq isearch-success t isearch-adjusted t)
   (isearch-update))
 
 (defun isearch-toggle-symbol ()
   "Toggle symbol searching on or off."
   (interactive)
-  (setq isearch-word (unless (eq isearch-word 'isearch-symbol-regexp)
-                      'isearch-symbol-regexp))
-  (if isearch-word (setq isearch-regexp nil))
+  (setq isearch-regexp-function
+        (unless (eq isearch-regexp-function #'isearch-symbol-regexp)
+          'isearch-symbol-regexp))
+  (when isearch-regexp-function (setq isearch-regexp nil))
   (setq isearch-success t isearch-adjusted t)
   (isearch-update))
 
 (defun isearch-toggle-character-fold ()
   "Toggle character folding in searching on or off."
   (interactive)
-  (setq isearch-word (unless (eq isearch-word #'character-fold-to-regexp)
-                       #'character-fold-to-regexp))
-  (if isearch-word (setq isearch-regexp nil))
+  (setq isearch-regexp-function
+        (unless (eq isearch-regexp-function #'character-fold-to-regexp)
+          #'character-fold-to-regexp))
+  (when isearch-regexp-function (setq isearch-regexp nil))
   (setq isearch-success t isearch-adjusted t)
   (isearch-update))
 
@@ -1718,6 +1725,13 @@ the beginning or the end of the string need not match a 
symbol boundary."
   (let ((search-spaces-regexp search-whitespace-regexp))
     (re-search-backward regexp bound noerror count)))
 
+(dolist (old '(re-search-forward-lax-whitespace search-backward-lax-whitespace
+               search-forward-lax-whitespace 
re-search-backward-lax-whitespace))
+  (make-obsolete old
+                 "instead, use (let ((search-spaces-regexp 
search-whitespace-regexp))
+               (re-search-... ...))"
+                 "25.1"))
+
 
 (defun isearch-query-replace (&optional arg regexp-flag)
   "Start `query-replace' with string to replace from last search string.
@@ -1767,12 +1781,12 @@ replacements from Isearch is `M-s w ... M-%'."
      (query-replace-read-to
       isearch-string
       (concat "Query replace"
-              (isearch--describe-word-mode (or delimited isearch-word) t)
+              (isearch--describe-regexp-mode (or delimited 
isearch-regexp-function) t)
               (if isearch-regexp " regexp" "")
              (if backward " backward" "")
              (if (and transient-mark-mode mark-active) " in region" ""))
       isearch-regexp)
-     t isearch-regexp (or delimited isearch-word) nil nil
+     t isearch-regexp (or delimited isearch-regexp-function) nil nil
      (if (and transient-mark-mode mark-active) (region-beginning))
      (if (and transient-mark-mode mark-active) (region-end))
      backward))
@@ -1799,9 +1813,9 @@ characters in that string."
   (interactive
    (let* ((perform-collect (consp current-prefix-arg))
          (regexp (cond
-                  ((functionp isearch-word)
-                   (funcall isearch-word isearch-string))
-                  (isearch-word (word-search-regexp isearch-string))
+                  ((functionp isearch-regexp-function)
+                   (funcall isearch-regexp-function isearch-string))
+                  (isearch-regexp-function (word-search-regexp isearch-string))
                   (isearch-regexp isearch-string)
                   (t (regexp-quote isearch-string)))))
      (list regexp
@@ -1850,9 +1864,9 @@ and reads its face argument using 
`hi-lock-read-face-name'."
     (isearch-done nil t)
     (isearch-clean-overlays))
   (require 'hi-lock nil t)
-  (let ((regexp (cond ((functionp isearch-word)
-                      (funcall isearch-word isearch-string))
-                     (isearch-word (word-search-regexp isearch-string))
+  (let ((regexp (cond ((functionp isearch-regexp-function)
+                       (funcall isearch-regexp-function isearch-string))
+                     (isearch-regexp-function (word-search-regexp 
isearch-string))
                      (isearch-regexp isearch-string)
                      ((if (and (eq isearch-case-fold-search t)
                                search-upper-case)
@@ -2057,9 +2071,9 @@ With argument, add COUNT copies of the character."
                       (setq case-fold-search
                             (isearch-no-upper-case-p isearch-string 
isearch-regexp)))
                   (looking-at (cond
-                               ((functionp isearch-word)
-                                (funcall isearch-word isearch-string t))
-                               (isearch-word (word-search-regexp 
isearch-string t))
+                               ((functionp isearch-regexp-function)
+                                (funcall isearch-regexp-function 
isearch-string t))
+                               (isearch-regexp-function (word-search-regexp 
isearch-string t))
                                (isearch-regexp isearch-string)
                                (t (regexp-quote isearch-string)))))
               (error nil))
@@ -2514,20 +2528,22 @@ If there is no completion possible, say so and continue 
searching."
             (isearch-message-suffix c-q-hack)))
     (if c-q-hack m (let ((message-log-max nil)) (message "%s" m)))))
 
-(defun isearch--describe-word-mode (word-mode &optional space-before)
-  "Make a string for describing WORD-MODE.
-If SPACE-BEFORE is non-nil,  put a space before, instead of after,
+(defun isearch--describe-regexp-mode (regexp-function &optional space-before)
+  "Make a string for describing REGEXP-FUNCTION.
+If SPACE-BEFORE is non-nil, put a space before, instead of after,
 the word mode."
   (let ((description
-         (cond ((and (symbolp word-mode)
-                     (get word-mode 'isearch-message-prefix))
-                (get word-mode 'isearch-message-prefix))
-               (word-mode "word ")
+         (cond ((and (symbolp regexp-function)
+                     (get regexp-function 'isearch-message-prefix))
+                (get regexp-function 'isearch-message-prefix))
+               (regexp-function "word ")
                (t ""))))
     (if space-before
         ;; Move space from the end to the beginning.
         (replace-regexp-in-string "\\(.*\\) \\'" " \\1" description)
       description)))
+(define-obsolete-function-alias 'isearch--describe-word-mode
+  'isearch--describe-regexp-mode "25.1")
 
 (defun isearch-message-prefix (&optional ellipsis nonincremental)
   ;; If about to search, and previous search regexp was invalid,
@@ -2556,7 +2572,7 @@ the word mode."
                           (if np (setq prefix (concat np prefix)))))
                       isearch-filter-predicate)
                      prefix)
-                   (isearch--describe-word-mode isearch-word)
+                   (isearch--describe-regexp-mode isearch-regexp-function)
                    (if isearch-regexp "regexp " "")
                   (cond
                    (multi-isearch-file-list "multi-file ")
@@ -2600,38 +2616,34 @@ search for the first occurrence of STRING or its 
translation.")
 Can be changed via `isearch-search-fun-function' for special needs."
   (funcall (or isearch-search-fun-function 'isearch-search-fun-default)))
 
+(defun isearch--lax-regexp-function-p ()
+  "Non-nil if next regexp-function call should be lax."
+  (not (or isearch-nonincremental
+           (null (car isearch-cmds))
+           (eq (length isearch-string)
+               (length (isearch--state-string
+                        (car isearch-cmds)))))))
+
 (defun isearch-search-fun-default ()
   "Return default functions to use for the search."
-  (cond
-   (isearch-word
-    (lambda (string &optional bound noerror count)
-      ;; Use lax versions to not fail at the end of the word while
-      ;; the user adds and removes characters in the search string
-      ;; (or when using nonincremental word isearch)
-      (let ((lax (not (or isearch-nonincremental
-                         (null (car isearch-cmds))
-                         (eq (length isearch-string)
-                             (length (isearch--state-string
-                                       (car isearch-cmds))))))))
-       (funcall
-        (if isearch-forward #'re-search-forward #'re-search-backward)
-        (if (functionp isearch-word)
-            (funcall isearch-word string lax)
-          (word-search-regexp string lax))
-        bound noerror count))))
-   ((and isearch-regexp isearch-regexp-lax-whitespace
-        search-whitespace-regexp)
-    (if isearch-forward
-       're-search-forward-lax-whitespace
-      're-search-backward-lax-whitespace))
-   (isearch-regexp
-    (if isearch-forward 're-search-forward 're-search-backward))
-   ((and isearch-lax-whitespace search-whitespace-regexp)
-    (if isearch-forward
-       'search-forward-lax-whitespace
-      'search-backward-lax-whitespace))
-   (t
-    (if isearch-forward 'search-forward 'search-backward))))
+  (lambda (string &optional bound noerror count)
+    ;; Use lax versions to not fail at the end of the word while
+    ;; the user adds and removes characters in the search string
+    ;; (or when using nonincremental word isearch)
+    (let ((search-spaces-regexp (when (cond
+                                       (isearch-regexp 
isearch-regexp-lax-whitespace)
+                                       (t isearch-lax-whitespace))
+                                  search-whitespace-regexp)))
+      (funcall
+       (if isearch-forward #'re-search-forward #'re-search-backward)
+       (cond (isearch-regexp-function
+              (let ((lax (isearch--lax-regexp-function-p)))
+                (if (functionp isearch-regexp-function)
+                    (funcall isearch-regexp-function string lax)
+                  (word-search-regexp string lax))))
+             (isearch-regexp string)
+             (t (regexp-quote string)))
+       bound noerror count))))
 
 (defun isearch-search-string (string bound noerror)
   "Search for the first occurrence of STRING or its translation.
@@ -2721,7 +2733,7 @@ update the match data, and return point."
       ((and (not isearch-regexp)
            (string-match "\\`Regular expression too big" isearch-error))
        (cond
-       (isearch-word
+       (isearch-regexp-function
         (setq isearch-error "Too many words"))
        ((and isearch-lax-whitespace search-whitespace-regexp)
         (setq isearch-error "Too many spaces for whitespace matching"))))))
@@ -2964,7 +2976,7 @@ since they have special meaning in a regexp."
 ;;  - `isearch-string' is expected to contain the current search
 ;;    string as entered by the user;
 ;;  - the type of the current search is expected to be given by
-;;    `isearch-word' and `isearch-regexp';
+;;    `isearch-regexp-function' and `isearch-regexp';
 ;;  - the direction of the current search is expected to be given by
 ;;    `isearch-forward';
 ;;  - the variable `isearch-error' is expected to be true
@@ -2985,7 +2997,9 @@ since they have special meaning in a regexp."
 (defvar isearch-lazy-highlight-regexp nil)
 (defvar isearch-lazy-highlight-lax-whitespace nil)
 (defvar isearch-lazy-highlight-regexp-lax-whitespace nil)
-(defvar isearch-lazy-highlight-word nil)
+(defvar isearch-lazy-highlight-regexp-function nil)
+(define-obsolete-variable-alias 'isearch-lazy-highlight-word
+  'isearch-lazy-highlight-regexp-function "25.1")
 (defvar isearch-lazy-highlight-forward nil)
 (defvar isearch-lazy-highlight-error nil)
 
@@ -3024,8 +3038,8 @@ by other Emacs features."
                          isearch-case-fold-search))
                 (not (eq isearch-lazy-highlight-regexp
                          isearch-regexp))
-                (not (eq isearch-lazy-highlight-word
-                         isearch-word))
+                (not (eq isearch-lazy-highlight-regexp-function
+                         isearch-regexp-function))
                 (not (eq isearch-lazy-highlight-lax-whitespace
                          isearch-lax-whitespace))
                 (not (eq isearch-lazy-highlight-regexp-lax-whitespace
@@ -3065,7 +3079,7 @@ by other Emacs features."
          isearch-lazy-highlight-regexp       isearch-regexp
          isearch-lazy-highlight-lax-whitespace   isearch-lax-whitespace
          isearch-lazy-highlight-regexp-lax-whitespace 
isearch-regexp-lax-whitespace
-         isearch-lazy-highlight-word         isearch-word
+         isearch-lazy-highlight-regexp-function  isearch-regexp-function
          isearch-lazy-highlight-forward      isearch-forward)
       (unless (equal isearch-string "")
        (setq isearch-lazy-highlight-timer
@@ -3078,7 +3092,7 @@ Attempt to do the search exactly the way the pending 
Isearch would."
   (condition-case nil
       (let ((case-fold-search isearch-lazy-highlight-case-fold-search)
            (isearch-regexp isearch-lazy-highlight-regexp)
-           (isearch-word isearch-lazy-highlight-word)
+           (isearch-regexp-function isearch-lazy-highlight-regexp-function)
            (isearch-lax-whitespace
             isearch-lazy-highlight-lax-whitespace)
            (isearch-regexp-lax-whitespace
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 63dbe40..42f48c7 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -2267,8 +2267,8 @@ See `menu-bar-mode' for more information."
   "Popup the given menu and call the selected option.
 MENU can be a keymap, an easymenu-style menu or a list of keymaps as for
 `x-popup-menu'.
-The menu is shown at the place where POSITION specifies. About
-the form of POSITION, see `popup-menu-normalize-position'.
+The menu is shown at the place where POSITION specifies.
+For the form of POSITION, see `popup-menu-normalize-position'.
 PREFIX is the prefix argument (if any) to pass to the command.
 FROM-MENU-BAR, if non-nil, means we are dropping one of menu-bar's menus."
   (let* ((map (cond
@@ -2337,9 +2337,9 @@ FROM-MENU-BAR, if non-nil, means we are dropping one of 
menu-bar's menus."
 
 (defun popup-menu-normalize-position (position)
   "Convert the POSITION to the form which `popup-menu' expects internally.
-POSITION can an event, a posn- value, a value having
+POSITION can be an event, a posn- value, a value having the
 form ((XOFFSET YOFFSET) WINDOW), or nil.
-If nil, the current mouse position is used."
+If nil, the current mouse position is used, or nil if there is no mouse."
   (pcase position
     ;; nil -> mouse cursor position
     (`nil
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 2814d02..6123750 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -92,18 +92,21 @@
 ;;; Completion table manipulation
 
 ;; New completion-table operation.
-(defun completion-boundaries (string table pred suffix)
-  "Return the boundaries of the completions returned by TABLE for STRING.
+(defun completion-boundaries (string collection pred suffix)
+  "Return the boundaries of text on which COLLECTION will operate.
 STRING is the string on which completion will be performed.
 SUFFIX is the string after point.
+If COLLECTION is a function, it is called with 3 arguments: STRING,
+PRED, and a cons cell of the form (boundaries . SUFFIX).
+
 The result is of the form (START . END) where START is the position
 in STRING of the beginning of the completion field and END is the position
 in SUFFIX of the end of the completion field.
 E.g. for simple completion tables, the result is always (0 . (length SUFFIX))
 and for file names the result is the positions delimited by
 the closest directory separators."
-  (let ((boundaries (if (functionp table)
-                        (funcall table string pred
+  (let ((boundaries (if (functionp collection)
+                        (funcall collection string pred
                                  (cons 'boundaries suffix)))))
     (if (not (eq (car-safe boundaries) 'boundaries))
         (setq boundaries nil))
diff --git a/lisp/mpc.el b/lisp/mpc.el
index bc7d473..af1aac9 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -44,7 +44,6 @@
 ;; - visual feedback for drag'n'drop
 ;; - display/set `repeat' and `random' state (and maybe also `crossfade').
 ;; - allow multiple *mpc* sessions in the same Emacs to control different mpds.
-;; - look for .folder.png (freedesktop) or folder.jpg (XP) as well.
 ;; - fetch album covers and lyrics from the web?
 ;; - improve MPC-Status: better volume control, add a way to show/hide the
 ;;   rest, plus add the buttons currently in the toolbar.
@@ -92,7 +91,9 @@
 ;; UI-commands       : mpc-
 ;; internal          : mpc--
 
-(eval-when-compile (require 'cl-lib))
+(eval-when-compile
+  (require 'cl-lib)
+  (require 'subr-x))
 
 (defgroup mpc ()
   "Client for the Music Player Daemon (mpd)."
@@ -795,6 +796,22 @@ The songs are returned as alists."
   ;; (setq mpc-queue-back nil mpc-queue nil)
   )
 
+(defun mpc-cmd-consume (&optional arg)
+  "Set consume mode state."
+  (mpc-proc-cmd (list "consume" arg) #'mpc-status-refresh))
+
+(defun mpc-cmd-random (&optional arg)
+  "Set random (shuffle) mode state."
+  (mpc-proc-cmd (list "random" arg) #'mpc-status-refresh))
+
+(defun mpc-cmd-repeat (&optional arg)
+  "Set repeat mode state."
+  (mpc-proc-cmd (list "repeat" arg) #'mpc-status-refresh))
+
+(defun mpc-cmd-single (&optional arg)
+  "Set single mode state."
+  (mpc-proc-cmd (list "single" arg) #'mpc-status-refresh))
+
 (defun mpc-cmd-pause (&optional arg callback)
   "Pause or resume playback of the queue of songs."
   (let ((cb callback))
@@ -1009,27 +1026,30 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
                                                (substring time (match-end 0))
                                              time)))))
                     (`Cover
-                     (let* ((dir (file-name-directory (cdr (assq 'file info))))
-                            (cover (concat dir "cover.jpg"))
-                            (file (with-demoted-errors "MPC: %s"
-                                    (mpc-file-local-copy cover)))
-                            image)
+                     (let ((dir (file-name-directory
+                                 (mpc-file-local-copy (cdr (assq 'file 
info))))))
                        ;; (debug)
                        (push `(equal ',dir (file-name-directory (cdr (assq 
'file info)))) pred)
-                       (if (null file)
-                           ;; Make sure we return something on which we can
-                           ;; place the `mpc-pred' property, as
-                           ;; a negative-cache.  We could also use
-                           ;; a default cover.
-                           (progn (setq size nil) " ")
-                         (if (null size) (setq image (create-image file))
-                           (let ((tempfile (make-temp-file "mpc" nil ".jpg")))
-                             (call-process "convert" nil nil nil
-                                           "-scale" size file tempfile)
-                             (setq image (create-image tempfile))
-                             (mpc-tempfiles-add image tempfile)))
-                         (setq size nil)
-                         (propertize dir 'display image))))
+                       (if-let ((covers '(".folder.png" "cover.jpg" 
"folder.jpg"))
+                                (cover (cl-loop for file in (directory-files 
dir)
+                                                if (member (downcase file) 
covers)
+                                                return (concat dir file)))
+                                (file (with-demoted-errors "MPC: %s"
+                                        (mpc-file-local-copy cover))))
+                           (let (image)
+                             (if (null size) (setq image (create-image file))
+                               (let ((tempfile (make-temp-file "mpc" nil 
".jpg")))
+                                 (call-process "convert" nil nil nil
+                                               "-scale" size file tempfile)
+                                 (setq image (create-image tempfile))
+                                 (mpc-tempfiles-add image tempfile)))
+                             (setq size nil)
+                             (propertize dir 'display image))
+                         ;; Make sure we return something on which we can
+                         ;; place the `mpc-pred' property, as
+                         ;; a negative-cache.  We could also use
+                         ;; a default cover.
+                         (progn (setq size nil) " "))))
                     (_ (let ((val (cdr (assq tag info))))
                          ;; For Streaming URLs, there's no other info
                          ;; than the URL in `file'.  Pretend it's in `Title'.
@@ -1086,8 +1106,7 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
 ;;; The actual UI code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defvar mpc-mode-map
-  (let ((map (make-keymap)))
-    (suppress-keymap map)
+  (let ((map (make-sparse-keymap)))
     ;; (define-key map "\e" 'mpc-stop)
     (define-key map "q" 'mpc-quit)
     (define-key map "\r" 'mpc-select)
@@ -1106,11 +1125,28 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
     ;; is applied elsewhere :-(
     ;; (define-key map [(double mouse-2)] 'mpc-play-at-point)
     (define-key map "p" 'mpc-pause)
+    (define-key map "s" 'mpc-toggle-play)
+    (define-key map ">" 'mpc-next)
+    (define-key map "<" 'mpc-prev)
+    (define-key map "g" nil)
     map))
 
 (easy-menu-define mpc-mode-menu mpc-mode-map
   "Menu for MPC.el."
   '("MPC.el"
+    ["Play/Pause" mpc-toggle-play]      ;FIXME: Add one of ⏯/▶/⏸ in there?
+    ["Next Track" mpc-next]             ;FIXME: Add ⇥ there?
+    ["Previous Track" mpc-prev]         ;FIXME: Add ⇤ there?
+    "--"
+    ["Repeat Playlist" mpc-toggle-repeat :style toggle
+     :selected (member '(repeat . "1") mpc-status)]
+    ["Shuffle Playlist" mpc-toggle-shuffle :style toggle
+     :selected (member '(random . "1") mpc-status)]
+    ["Repeat Single Track" mpc-toggle-single :style toggle
+     :selected (member '(single . "1") mpc-status)]
+    ["Consume Mode" mpc-toggle-consume :style toggle
+     :selected (member '(consume . "1") mpc-status)]
+    "--"
     ["Add new browser" mpc-tagbrowser]
     ["Update DB" mpc-update]
     ["Quit" mpc-quit]))
@@ -1154,10 +1190,9 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
      :help "Append to the playlist")
     map))
 
-(define-derived-mode mpc-mode fundamental-mode "MPC"
+(define-derived-mode mpc-mode special-mode "MPC"
   "Major mode for the features common to all buffers of MPC."
   (buffer-disable-undo)
-  (setq buffer-read-only t)
   (if (boundp 'tool-bar-map)            ; not if --without-x
       (setq-local tool-bar-map mpc-tool-bar-map))
   (setq-local truncate-lines t))
@@ -1260,7 +1295,7 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
   (let ((ol (make-overlay
              (line-beginning-position) (line-beginning-position 2))))
     (overlay-put ol 'mpc-select t)
-    (overlay-put ol 'face 'region)
+    (overlay-put ol 'face 'highlight)
     (overlay-put ol 'evaporate t)
     (push ol mpc-select)))
 
@@ -1559,7 +1594,7 @@ when constructing the set of constraints."
           (move-overlay mpc-tagbrowser-all-ol
                         (point) (line-beginning-position 2))
         (let ((ol (make-overlay (point) (line-beginning-position 2))))
-          (overlay-put ol 'face 'region)
+          (overlay-put ol 'face 'highlight)
           (overlay-put ol 'evaporate t)
           (setq-local mpc-tagbrowser-all-ol ol))))))
 
@@ -1821,7 +1856,8 @@ A value of t means the main playlist.")
         (mpc-volume-widget
          (string-to-number (cdr (assq 'volume mpc-status)))))
   (let ((status-buf (mpc-proc-buffer (mpc-proc) 'status)))
-    (when status-buf (with-current-buffer status-buf 
(force-mode-line-update)))))
+    (when (buffer-live-p status-buf)
+      (with-current-buffer status-buf (force-mode-line-update)))))
 
 (defvar mpc-volume-step 5)
 
@@ -1879,7 +1915,6 @@ A value of t means the main playlist.")
 
 (defvar mpc-songs-mode-map
   (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map mpc-mode-map)
     (define-key map [remap mpc-select] 'mpc-songs-jump-to)
     map))
 
@@ -1957,7 +1992,7 @@ This is used so that they can be compared with `eq', 
which is needed for
             ;; I punt on it and just use file-name sorting, which does the
             ;; right thing if your library is properly arranged.
             (dolist (song (if dontsort active
-                            (sort active
+                            (sort (copy-sequence active)
                                   (lambda (song1 song2)
                                     (let ((cmp (mpc-compare-strings
                                                 (cdr (assq 'file song1))
@@ -2327,6 +2362,30 @@ This is used so that they can be compared with `eq', 
which is needed for
     (mpc-status-stop)
     (if proc (delete-process proc))))
 
+(defun mpc-toggle-consume ()
+  "Toggle consume mode: removing played songs from the playlist."
+  (interactive)
+  (mpc-cmd-consume
+   (if (string= "0" (cdr (assq 'consume (mpc-cmd-status)))) "1" "0")))
+
+(defun mpc-toggle-repeat ()
+  "Toggle repeat mode."
+  (interactive)
+  (mpc-cmd-repeat
+   (if (string= "0" (cdr (assq 'repeat (mpc-cmd-status)))) "1" "0")))
+
+(defun mpc-toggle-single ()
+  "Toggle single mode."
+  (interactive)
+  (mpc-cmd-single
+   (if (string= "0" (cdr (assq 'single (mpc-cmd-status)))) "1" "0")))
+
+(defun mpc-toggle-shuffle ()
+  "Toggle shuffling of the playlist (random mode)."
+  (interactive)
+  (mpc-cmd-random
+   (if (string= "0" (cdr (assq 'random (mpc-cmd-status)))) "1" "0")))
+
 (defun mpc-stop ()
   "Stop playing the current queue of songs."
   (interactive)
@@ -2344,6 +2403,16 @@ This is used so that they can be compared with `eq', 
which is needed for
   (interactive)
   (mpc-cmd-pause "0"))
 
+(defun mpc-toggle-play ()
+  "Toggle between play and pause.
+If stopped, start playback."
+  (interactive)
+  (if (member (cdr (assq 'state (mpc-cmd-status))) '("stop"))
+      (mpc-cmd-play)
+    (if (member (cdr (assq 'state (mpc-cmd-status))) '("pause"))
+        (mpc-resume)
+      (mpc-pause))))
+
 (defun mpc-play ()
   "Start playing whatever is selected."
   (interactive)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index d44890f..bda4e0c 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -627,7 +627,6 @@ the like."
 
 (defvar eww-mode-map
   (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map special-mode-map)
     (define-key map "g" 'eww-reload) ;FIXME: revert-buffer-function instead!
     (define-key map "G" 'eww)
     (define-key map [?\t] 'shr-next-link)
@@ -1583,8 +1582,6 @@ If CHARSET is nil then use UTF-8."
 
 (defvar eww-bookmark-mode-map
   (let ((map (make-sparse-keymap)))
-    (suppress-keymap map)
-    (define-key map "q" 'quit-window)
     (define-key map [(control k)] 'eww-bookmark-kill)
     (define-key map [(control y)] 'eww-bookmark-yank)
     (define-key map "\r" 'eww-bookmark-browse)
@@ -1601,13 +1598,12 @@ If CHARSET is nil then use UTF-8."
          :active eww-bookmark-kill-ring]))
     map))
 
-(define-derived-mode eww-bookmark-mode nil "eww bookmarks"
+(define-derived-mode eww-bookmark-mode special-mode "eww bookmarks"
   "Mode for listing bookmarks.
 
 \\{eww-bookmark-mode-map}"
   (buffer-disable-undo)
-  (setq buffer-read-only t
-       truncate-lines t))
+  (setq truncate-lines t))
 
 ;;; History code
 
@@ -1670,8 +1666,6 @@ If CHARSET is nil then use UTF-8."
 
 (defvar eww-history-mode-map
   (let ((map (make-sparse-keymap)))
-    (suppress-keymap map)
-    (define-key map "q" 'quit-window)
     (define-key map "\r" 'eww-history-browse)
 ;;    (define-key map "n" 'next-error-no-select)
 ;;    (define-key map "p" 'previous-error-no-select)
@@ -1684,13 +1678,12 @@ If CHARSET is nil then use UTF-8."
          :active (get-text-property (line-beginning-position) 'eww-history)]))
     map))
 
-(define-derived-mode eww-history-mode nil "eww history"
+(define-derived-mode eww-history-mode special-mode "eww history"
   "Mode for listing eww-histories.
 
 \\{eww-history-mode-map}"
   (buffer-disable-undo)
-  (setq buffer-read-only t
-       truncate-lines t))
+  (setq truncate-lines t))
 
 ;;; eww buffers list
 
@@ -1795,8 +1788,6 @@ If CHARSET is nil then use UTF-8."
 
 (defvar eww-buffers-mode-map
   (let ((map (make-sparse-keymap)))
-    (suppress-keymap map)
-    (define-key map "q" 'quit-window)
     (define-key map [(control k)] 'eww-buffer-kill)
     (define-key map "\r" 'eww-buffer-select)
     (define-key map "n" 'eww-buffer-show-next)
@@ -1812,13 +1803,12 @@ If CHARSET is nil then use UTF-8."
          :active (get-text-property (line-beginning-position) 'eww-buffer)]))
     map))
 
-(define-derived-mode eww-buffers-mode nil "eww buffers"
+(define-derived-mode eww-buffers-mode special-mode "eww buffers"
   "Mode for listing buffers.
 
 \\{eww-buffers-mode-map}"
   (buffer-disable-undo)
-  (setq buffer-read-only t
-       truncate-lines t))
+  (setq truncate-lines t))
 
 ;;; Desktop support
 
diff --git a/lisp/net/shr-color.el b/lisp/net/shr-color.el
index 482f829..f8d358c 100644
--- a/lisp/net/shr-color.el
+++ b/lisp/net/shr-color.el
@@ -211,7 +211,7 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but 
\"123\" to \"123\"."
   "Convert X Y H to RGB value."
   (when (< h 0) (incf h))
   (when (> h 1) (decf h))
-  (cond ((< h (/ 1 6.0)) (+ x (* (- y x) h 6)))
+  (cond ((< h (/ 6.0)) (+ x (* (- y x) h 6)))
         ((< h 0.5) y)
         ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6)))
         (t x)))
@@ -223,9 +223,9 @@ This will convert \"80 %\" to 204, \"100 %\" to 255 but 
\"123\" to \"123\"."
         (setq m2 (* l (+ s 1)))
         (setq m2 (- (+ l s) (* l s))))
     (setq m1 (- (* l 2) m2))
-    (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 1 3.0)))
+    (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 3.0)))
          (shr-color-hue-to-rgb m1 m2 h)
-         (shr-color-hue-to-rgb m1 m2 (- h (/ 1 3.0))))))
+         (shr-color-hue-to-rgb m1 m2 (- h (/ 3.0))))))
 
 (defun shr-color->hexadecimal (color)
   "Convert any color format to hexadecimal representation.
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 9116e50..58deaea 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -463,7 +463,7 @@ size, and full-buffer size."
                                    ;; Adjust the window width for when
                                    ;; the user disables the fringes,
                                    ;; which causes the display engine
-                                   ;; usurp one coplumn for the
+                                   ;; to usurp one column for the
                                    ;; continuation glyph.
                                    (if (and (null shr-width)
                                             (or (zerop (fringe-columns 'right))
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 595e0ef..88dea6a 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -36,6 +36,7 @@
 (require 'tramp)
 
 ;; Pacify byte-compiler.
+(defvar directory-listing-before-filename-regexp)
 (defvar directory-sep-char)
 
 ;;;###tramp-autoload
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index e645195..7157ac2 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -105,12 +105,6 @@
   (unless (boundp 'remote-file-name-inhibit-cache)
     (defvar remote-file-name-inhibit-cache nil))
 
-  ;; `directory-listing-before-filename-regexp' does not exist in
-  ;; XEmacs.  Since we use it only in tramp-adb.el, it doesn't harm to
-  ;; declare it here.
-  (unless (boundp 'directory-listing-before-filename-regexp)
-      (defvar directory-listing-before-filename-regexp nil))
-
   ;; For not existing functions, or functions with a changed argument
   ;; list, there are compiler warnings.  We want to avoid them in
   ;; cases we know what we do.
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index b7b0a1c..177ccfc 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -47,7 +47,7 @@
 ;; discovered during development time, is given in respective
 ;; comments.
 
-;; The customer option `tramp-gvfs-methods' contains the list of
+;; The custom option `tramp-gvfs-methods' contains the list of
 ;; supported connection methods.  Per default, these are "dav",
 ;; "davs", "obex", "sftp" and "synce".  Note that with "obex" it might
 ;; be necessary to pair with the other bluetooth device, if it hasn't
@@ -81,7 +81,7 @@
 ;; "synce" method), or from the zeroconf daemon (for the "dav",
 ;; "davs", and "sftp" methods).  The zeroconf daemon is pre-configured
 ;; to discover services in the "local" domain.  If another domain
-;; shall be used for discovering services, the customer option
+;; shall be used for discovering services, the custom option
 ;; `tramp-gvfs-zeroconf-domain' can be set accordingly.
 
 ;; Restrictions:
@@ -791,6 +791,7 @@ file names."
   (ignore-errors
     ;; Don't modify `last-coding-system-used' by accident.
     (let ((last-coding-system-used last-coding-system-used)
+         (process-environment (cons "LC_MESSAGES=C" process-environment))
          dirp res-symlink-target res-numlinks res-uid res-gid res-access
          res-mod res-change res-size res-filemodes res-inode res-device)
       (with-parsed-tramp-file-name filename nil
@@ -809,7 +810,7 @@ file names."
              (goto-char (point-min))
              (setq res-symlink-target
                    (if (re-search-forward
-                        "standard::symlink-target:\\s-+\\(\\S-+\\)" nil t)
+                        "standard::symlink-target:\\s-+\\(.*\\)$" nil t)
                        (match-string 1)))
              ;; ... number links
              (goto-char (point-min))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 7d24b54..1753c73 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2457,16 +2457,17 @@ The method used must be an out-of-band method."
        (setq source (if t1
                         (tramp-make-copy-program-file-name v)
                       (shell-quote-argument filename))
-             target (funcall
+          target (if t2
+                     (tramp-make-copy-program-file-name v)
+                   (shell-quote-argument
+                    (funcall
                      (if (and (file-directory-p filename)
                               (string-equal
                                (file-name-nondirectory filename)
                                (file-name-nondirectory newname)))
                          'file-name-directory
                        'identity)
-                     (if t2
-                         (tramp-make-copy-program-file-name v)
-                       (shell-quote-argument newname))))
+                     newname))))
 
        ;; Check for host and port number.  We cannot use
        ;; `tramp-file-name-port', because this returns also
@@ -4153,7 +4154,8 @@ process to set up.  VEC specifies the connection."
 
     ;; Disable tab and echo expansion.
     (tramp-message vec 5 "Setting up remote shell environment")
-    (tramp-send-command vec "stty tab0 -inlcr -onlcr -echo kill '^U' erase 
'^H'" t)
+    (tramp-send-command
+     vec "stty tab0 -inlcr -onlcr -echo kill '^U' erase '^H'" t)
     ;; Check whether the echo has really been disabled.  Some
     ;; implementations, like busybox of embedded GNU/Linux, don't
     ;; support disabling.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index df64f49..30a7269 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -485,7 +485,7 @@ names from FILE for completion.  The following predefined 
FUNCTIONs exists:
  * `tramp-parse-netrc'       for \"~/.netrc\" like files.
  * `tramp-parse-putty'       for PuTTY registered sessions.
 
-FUNCTION can also be a customer defined function.  For more details see
+FUNCTION can also be a user defined function.  For more details see
 the info pages.")
 
 (defconst tramp-echo-mark-marker "_echo"
@@ -4048,6 +4048,9 @@ Return the local name of the temporary file."
   "Like `make-auto-save-file-name' for Tramp files.
 Returns a file name in `tramp-auto-save-directory' for autosaving
 this file, if that variable is non-nil."
+  (when (stringp tramp-auto-save-directory)
+    (setq tramp-auto-save-directory
+         (expand-file-name tramp-auto-save-directory)))
   ;; Create directory.
   (unless (or (null tramp-auto-save-directory)
              (file-exists-p tramp-auto-save-directory))
@@ -4411,8 +4414,6 @@ Only works for Bourne-like shells."
 
 ;;; TODO:
 
-;; * Rewrite `tramp-shell-quote-argument' to abstain from using
-;;   `shell-quote-argument'.
 ;; * In Emacs 21, `insert-directory' shows total number of bytes used
 ;;   by the files in that directory.  Add this here.
 ;; * Avoid screen blanking when hitting `g' in dired.  (Eli Tziperman)
diff --git a/lisp/obsolete/longlines.el b/lisp/obsolete/longlines.el
index 7cb13ce..bfde826 100644
--- a/lisp/obsolete/longlines.el
+++ b/lisp/obsolete/longlines.el
@@ -464,7 +464,7 @@ This is called by `window-configuration-change-hook'."
 
 (defun longlines-search-function ()
   (cond
-   ((or isearch-word isearch-regexp) (isearch-search-fun-default))
+   ((or isearch-regexp-function isearch-regexp) (isearch-search-fun-default))
    (isearch-forward #'longlines-search-forward)
    (t #'longlines-search-backward)))
 
diff --git a/lisp/obsolete/vc-arch.el b/lisp/obsolete/vc-arch.el
index e6540ce..bdb6975 100644
--- a/lisp/obsolete/vc-arch.el
+++ b/lisp/obsolete/vc-arch.el
@@ -310,10 +310,6 @@ Only the value `maybe' can be trusted :-(."
                    'up-to-date
                  'edited)))))))))
 
-;; dir-status-files called from vc-dir, which loads vc,
-;; which loads vc-dispatcher.
-(declare-function vc-exec-after "vc-dispatcher" (code))
-
 (defun vc-arch-dir-status-files (dir _files callback)
   "Run `tla inventory' for DIR and pass results to CALLBACK.
 CALLBACK expects (ENTRIES &optional MORE-TO-COME); see
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index f214015..5a4f383 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1751,11 +1751,18 @@ This performs fontification according to 
`js--class-styles'."
   "Return non-nil if point is on a JavaScript operator, other than a comma."
   (save-match-data
     (and (looking-at js--indent-operator-re)
-         (or (not (looking-at ":"))
+         (or (not (eq (char-after) ?:))
              (save-excursion
                (and (js--re-search-backward "[?:{]\\|\\_<case\\_>" nil t)
-                    (looking-at "?")))))))
-
+                    (eq (char-after) ??))))
+         (not (and
+               (eq (char-after) ?*)
+               (looking-at (concat "\\* *" js--name-re " *("))
+               (save-excursion
+                 (goto-char (1- (match-end 0)))
+                 (let (forward-sexp-function) (forward-sexp))
+                 (js--forward-syntactic-ws)
+                 (eq (char-after) ?{)))))))
 
 (defun js--continued-expression-p ()
   "Return non-nil if the current line continues an expression."
diff --git a/lisp/replace.el b/lisp/replace.el
index 3a908ac..d6590c5 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2013,7 +2013,7 @@ It is called with three arguments, as if it were
   ;; outside of this function because then another I-search
   ;; used after `recursive-edit' might override them.
   (let* ((isearch-regexp regexp-flag)
-        (isearch-word (or delimited-flag
+        (isearch-regexp-function (or delimited-flag
                            (and replace-character-fold
                                 (not regexp-flag)
                                 #'character-fold-to-regexp)))
@@ -2046,7 +2046,7 @@ It is called with three arguments, as if it were
   (if query-replace-lazy-highlight
       (let ((isearch-string search-string)
            (isearch-regexp regexp-flag)
-           (isearch-word delimited-flag)
+           (isearch-regexp-function delimited-flag)
            (isearch-lax-whitespace
             replace-lax-whitespace)
            (isearch-regexp-lax-whitespace
diff --git a/lisp/select.el b/lisp/select.el
index 74b48d1..2d2ac5f 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -235,7 +235,7 @@ The value nil is the same as the list (UTF8_STRING 
COMPOUND_TEXT STRING)."
 
 (defun gui-get-primary-selection ()
   "Return the PRIMARY selection, or the best emulation thereof."
-  (or (gui-get-selection 'PRIMARY)
+  (or (gui--selection-value-internal 'PRIMARY)
       (and (fboundp 'w32-get-selection-value)
            (eq (framep (selected-frame)) 'w32)
            ;; MS-Windows emulates PRIMARY in x-get-selection, but only
diff --git a/lisp/server.el b/lisp/server.el
index 5a67f12..59fd973 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1491,13 +1491,12 @@ specifically for the clients and did not exist before 
their request for it."
 
 (defun server-kill-emacs-query-function ()
   "Ask before exiting Emacs if it has live clients."
-  (or (not server-clients)
-      (let (live-client)
-       (dolist (proc server-clients)
-         (when (memq t (mapcar 'buffer-live-p (process-get
-                                               proc 'buffers)))
-           (setq live-client t)))
-        live-client)
+  (or (not (let (live-client)
+             (dolist (proc server-clients)
+               (when (memq t (mapcar 'buffer-live-p (process-get
+                                                     proc 'buffers)))
+                 (setq live-client t)))
+             live-client))
       (yes-or-no-p "This Emacs session has clients; exit anyway? ")))
 
 (defun server-kill-buffer ()
diff --git a/lisp/subr.el b/lisp/subr.el
index e176907..ea926ae 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2711,7 +2711,11 @@ Note: :data and :device are currently not supported on 
Windows."
 (declare-function w32-shell-dos-semantics "w32-fns" nil)
 
 (defun shell-quote-argument (argument)
-  "Quote ARGUMENT for passing as argument to an inferior shell."
+  "Quote ARGUMENT for passing as argument to an inferior shell.
+
+This function is designed to work with the syntax of your system's
+standard shell, and might produce incorrect results with unusual shells.
+See Info node `(elisp)Security Considerations'."
   (cond
    ((eq system-type 'ms-dos)
     ;; Quote using double quotes, but escape any existing quotes in
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 6641523..84efa7a 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -306,12 +306,28 @@ If the symbols for the current master file do not exist, 
they are created."
   (let
       ((master
         (cond
-         ((fboundp 'TeX-master-file) ; AUCTeX is loaded.  Use its mechanism.
+        ;; Test if we're in a subfile using the subfiles document
+        ;; class, e.g., \documentclass[main.tex]{subfiles}.  It's
+        ;; argument is the main file, however it's not really the
+        ;; master file in `TeX-master-file' or `tex-main-file's
+        ;; sense.  It should be used for references but not for
+        ;; compilation, thus subfiles use a setting of
+        ;; `TeX-master'/`tex-main-file' being themselves.
+        ((save-excursion
+            (goto-char (point-min))
+            (re-search-forward
+             "^[[:space:]]*\\\\documentclass\\[\\([[:word:].]+\\)\\]{subfiles}"
+             nil t))
+          (match-string-no-properties 1))
+         ;; AUCTeX is loaded.  Use its mechanism.
+         ((fboundp 'TeX-master-file)
           (condition-case nil
               (TeX-master-file t)
             (error (buffer-file-name))))
-         ((fboundp 'tex-main-file) (tex-main-file)) ; Emacs LaTeX mode
-         ((boundp 'TeX-master)       ; The variable is defined - let's use it.
+         ;; Emacs LaTeX mode
+         ((fboundp 'tex-main-file) (tex-main-file))
+         ;; Check the `TeX-master' variable.
+         ((boundp 'TeX-master)
           (cond
            ((eq TeX-master t)
             (buffer-file-name))
@@ -322,6 +338,7 @@ If the symbols for the current master file do not exist, 
they are created."
            (t
             (setq TeX-master (read-file-name "Master file: "
                                              nil nil t nil)))))
+         ;; Check the `tex-main-file' variable.
          ((boundp 'tex-main-file)
           ;; This is the variable from the default TeX modes.
           (cond
@@ -331,8 +348,9 @@ If the symbols for the current master file do not exist, 
they are created."
            (t
             ;; In this case, the buffer is its own master.
             (buffer-file-name))))
+         ;; We know nothing about master file.  Assume this is a
+         ;; master file.
          (t
-          ;; Know nothing about master file.  Assume this is a master file.
           (buffer-file-name)))))
     (cond
      ((null master)
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index 9b2711d..40f2516 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -331,7 +331,6 @@ in the repository root directory of FILE."
   "Value of `compilation-error-regexp-alist' in *vc-bzr* buffers.")
 
 ;; To be called via vc-pull from vc.el, which requires vc-dispatcher.
-(declare-function vc-exec-after "vc-dispatcher" (code))
 (declare-function vc-set-async-update "vc-dispatcher" (process-buffer))
 (declare-function vc-compilation-mode "vc-dispatcher" (backend))
 
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el
index 5f5807f..c0a199d 100644
--- a/lisp/vc/vc-cvs.el
+++ b/lisp/vc/vc-cvs.el
@@ -543,8 +543,6 @@ Will fail unless you have administrative privileges on the 
repo."
 ;;;
 
 (declare-function vc-rcs-print-log-cleanup "vc-rcs" ())
-;; Follows vc-cvs-command, which uses vc-do-command from vc-dispatcher.
-(declare-function vc-exec-after "vc-dispatcher" (code))
 
 (defun vc-cvs-print-log (files buffer &optional _shortlog _start-revision 
limit)
   "Print commit log associated with FILES into specified BUFFER.
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index eb03a8b..9b15e64 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -932,7 +932,7 @@ If it is a file, return the corresponding cons for the file 
itself."
 
 (defun vc-dir-resynch-file (&optional fname)
   "Update the entries for FNAME in any directory buffers that list it."
-  (let ((file (or fname (expand-file-name buffer-file-name)))
+  (let ((file (expand-file-name (or fname buffer-file-name)))
         (drop '()))
     (save-current-buffer
       ;; look for a vc-dir buffer that might show this file.
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index b557032..0e33896 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -461,8 +461,6 @@ or an empty string if none."
 
 ;; Follows vc-git-command (or vc-do-async-command), which uses vc-do-command
 ;; from vc-dispatcher.
-(declare-function vc-exec-after "vc-dispatcher" (code))
-;; Follows vc-exec-after.
 (declare-function vc-set-async-update "vc-dispatcher" (process-buffer))
 
 (defun vc-git-dir-status-goto-stage (stage files update-function)
@@ -1364,11 +1362,15 @@ This command shares argument histories with \\[rgrep] 
and \\[grep]."
 
 (defun vc-git-stash-apply-at-point ()
   (interactive)
-  (vc-git-stash-apply (format "address@hidden" (vc-git-stash-get-at-point 
(point)))))
+  (let (vc-dir-buffers) ; Small optimization.
+    (vc-git-stash-apply (format "address@hidden" (vc-git-stash-get-at-point 
(point)))))
+  (vc-dir-refresh))
 
 (defun vc-git-stash-pop-at-point ()
   (interactive)
-  (vc-git-stash-pop (format "address@hidden" (vc-git-stash-get-at-point 
(point)))))
+  (let (vc-dir-buffers) ; Likewise.
+    (vc-git-stash-pop (format "address@hidden" (vc-git-stash-get-at-point 
(point)))))
+  (vc-dir-refresh))
 
 (defun vc-git-stash-menu (e)
   (interactive "e")
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 4957398..c4d6092 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -620,8 +620,6 @@ REV is the revision to check out into WORKFILE."
 
 ;; Follows vc-hg-command (or vc-do-async-command), which uses vc-do-command
 ;; from vc-dispatcher.
-(declare-function vc-exec-after "vc-dispatcher" (code))
-;; Follows vc-exec-after.
 (declare-function vc-set-async-update "vc-dispatcher" (process-buffer))
 
 (defun vc-hg-dir-status-files (dir files update-function)
diff --git a/lisp/vc/vc-mtn.el b/lisp/vc/vc-mtn.el
index b56a08f..3197d60 100644
--- a/lisp/vc/vc-mtn.el
+++ b/lisp/vc/vc-mtn.el
@@ -138,10 +138,6 @@ switches."
             ((match-end 2) (push (list (match-string 3) 'added) result))))
     (funcall update-function result)))
 
-;; dir-status-files called from vc-dir, which loads vc,
-;; which loads vc-dispatcher.
-(declare-function vc-exec-after "vc-dispatcher" (code))
-
 (defun vc-mtn-dir-status-files (dir _files update-function)
   (vc-mtn-command (current-buffer) 'async dir "status")
   (vc-run-delayed
diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el
index 4ef63a2..2ec65a1 100644
--- a/lisp/vc/vc-svn.el
+++ b/lisp/vc/vc-svn.el
@@ -208,10 +208,6 @@ switches."
          (setq result (cons (list filename state) result)))))
     (funcall callback result)))
 
-;; dir-status-files called from vc-dir, which loads vc,
-;; which loads vc-dispatcher.
-(declare-function vc-exec-after "vc-dispatcher" (code))
-
 (autoload 'vc-expand-dirs "vc")
 
 (defun vc-svn-dir-status-files (_dir files callback)
diff --git a/lwlib/lwlib-widget.h b/lwlib/lwlib-widget.h
index 92ae7e6..6ec6d27 100644
--- a/lwlib/lwlib-widget.h
+++ b/lwlib/lwlib-widget.h
@@ -23,6 +23,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifndef LWLIB_WIDGET_H
 #define LWLIB_WIDGET_H
 
+#include "../src/lisp.h"
+
 typedef enum
 {
   NO_CHANGE = 0,
@@ -96,7 +98,7 @@ typedef struct _widget_value
   /* Whether we should free the toolkit data slot when freeing the
      widget_value itself.  */
   bool free_toolkit_data;
-#endif  
+#endif
 
 } widget_value;
 
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 40e82f6..50ef974 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -253,9 +253,10 @@ AC_DEFUN([gl_PROG_AR_RANLIB],
 [
   dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
   dnl as "cc", and GCC as "gcc". They have different object file formats and
-  dnl library formats. In particular, the GNU binutils programs ar, ranlib
+  dnl library formats. In particular, the GNU binutils programs ar and ranlib
   dnl produce libraries that work only with gcc, not with cc.
   AC_REQUIRE([AC_PROG_CC])
+  AC_BEFORE([$0], [AM_PROG_AR])
   AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
     [
       AC_EGREP_CPP([Amsterdam],
@@ -267,25 +268,37 @@ Amsterdam
         [gl_cv_c_amsterdam_compiler=yes],
         [gl_cv_c_amsterdam_compiler=no])
     ])
-  if test -z "$AR"; then
-    if test $gl_cv_c_amsterdam_compiler = yes; then
+
+  dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not
+  dnl building with __ACK__.
+  if test $gl_cv_c_amsterdam_compiler = yes; then
+    if test -z "$AR"; then
       AR='cc -c.a'
-      if test -z "$ARFLAGS"; then
-        ARFLAGS='-o'
-      fi
-    else
-      dnl Use the Automake-documented default values for AR and ARFLAGS,
-      dnl but prefer ${host}-ar over ar (useful for cross-compiling).
-      AC_CHECK_TOOL([AR], [ar], [ar])
-      if test -z "$ARFLAGS"; then
-        ARFLAGS='cr'
-      fi
     fi
-  else
     if test -z "$ARFLAGS"; then
-      ARFLAGS='cr'
+      ARFLAGS='-o'
     fi
+  else
+    dnl AM_PROG_AR was added in automake v1.11.2.  AM_PROG_AR does not AC_SUBST
+    dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
+    dnl script on-demand, if not specified by ./configure of course).
+    dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above
+    dnl will be ignored.  Also, pay attention to call AM_PROG_AR in else block
+    dnl because AM_PROG_AR is written so it could re-set AR variable even for
+    dnl __ACK__.  It may seem like its easier to avoid calling the macro here,
+    dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good
+    dnl default value and automake should usually know them).
+    m4_ifdef([AM_PROG_AR], [AM_PROG_AR], [:])
+  fi
+
+  dnl In case the code above has not helped with setting AR/ARFLAGS, use
+  dnl Automake-documented default values for AR and ARFLAGS, but prefer
+  dnl ${host}-ar over ar (useful for cross-compiling).
+  AC_CHECK_TOOL([AR], [ar], [ar])
+  if test -z "$ARFLAGS"; then
+    ARFLAGS='cr'
   fi
+
   AC_SUBST([AR])
   AC_SUBST([ARFLAGS])
   if test -z "$RANLIB"; then
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index c48d2e5..349c0dc 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -37,7 +37,11 @@ AC_DEFUN([gl_EARLY],
   m4_pattern_allow([^gl_ES$])dnl a valid locale name
   m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
   m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
+
+  # Pre-early section.
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([gl_PROG_AR_RANLIB])
+
   # Code from module absolute-header:
   # Code from module acl-permissions:
   # Code from module alloca-opt:
@@ -67,7 +71,6 @@ AC_DEFUN([gl_EARLY],
   # Code from module euidaccess:
   # Code from module execinfo:
   # Code from module extensions:
-  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   # Code from module extern-inline:
   # Code from module faccessat:
   # Code from module fcntl:
diff --git a/nt/INSTALL b/nt/INSTALL
index 3bcb496..e1d9e06 100644
--- a/nt/INSTALL
+++ b/nt/INSTALL
@@ -178,6 +178,10 @@ build will run on Windows 9X and newer systems).
   command "mingw-get remove msys-texinfo", or mark "msys-texinfo" for
   removal in the mingw-get GUI, then select Installation->Apply Changes.)
 
+  (Similarly, we recommend to refrain from installing the MinGW
+  Automake and Autoconf packages; instead, install their MSYS builds
+  available from the ezwinports site, see below.)
+
   At this point, you should be ready to configure and build Emacs in
   its basic configuration.  Skip to the "Generating the configure
   script" section for the build instructions.  If you want to build it
diff --git a/src/ChangeLog.3 b/src/ChangeLog.3
index d7c0a2f..5e99a27 100644
--- a/src/ChangeLog.3
+++ b/src/ChangeLog.3
@@ -1642,7 +1642,7 @@
        * keymap.c (current_minor_maps): BLOCK_INPUT while calling realloc
        and malloc.
        * search.c: Since the regexp routines can malloc, BLOCK_INPUT
-       while runing them.  #include blockinput.h.
+       while running them.  #include blockinput.h.
        * sysdep.c: #include blockinput.h.  Call xfree and xmalloc instead
        of free and malloc.  BLOCK_INPUT around routines which we know
        will call malloc.
diff --git a/src/alloc.c b/src/alloc.c
index 5fc40d1..7c33687 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -32,9 +32,10 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #endif
 
 #include "lisp.h"
-#include "process.h"
+#include "dispextern.h"
 #include "intervals.h"
 #include "puresize.h"
+#include "systime.h"
 #include "character.h"
 #include "buffer.h"
 #include "window.h"
@@ -179,11 +180,6 @@ static ptrdiff_t pure_size;
 
 static ptrdiff_t pure_bytes_used_before_overflow;
 
-/* True if P points into pure space.  */
-
-#define PURE_POINTER_P(P)                                      \
-  ((uintptr_t) (P) - (uintptr_t) purebeg <= pure_size)
-
 /* Index in pure at which next pure Lisp object will be allocated..  */
 
 static ptrdiff_t pure_bytes_used_lisp;
@@ -406,6 +402,28 @@ ALIGN (void *ptr, int alignment)
   return (void *) ROUNDUP ((uintptr_t) ptr, alignment);
 }
 
+/* Extract the pointer hidden within A, if A is not a symbol.
+   If A is a symbol, extract the hidden pointer's offset from lispsym,
+   converted to void *.  */
+
+static void *
+XPNTR_OR_SYMBOL_OFFSET (Lisp_Object a)
+{
+  intptr_t i = USE_LSB_TAG ? XLI (a) - XTYPE (a) : XLI (a) & VALMASK;
+  return (void *) i;
+}
+
+/* Extract the pointer hidden within A.  */
+
+static void *
+XPNTR (Lisp_Object a)
+{
+  void *p = XPNTR_OR_SYMBOL_OFFSET (a);
+  if (SYMBOLP (a))
+    p = (intptr_t) p + (char *) lispsym;
+  return p;
+}
+
 static void
 XFLOAT_INIT (Lisp_Object f, double n)
 {
@@ -1587,9 +1605,7 @@ string_bytes (struct Lisp_String *s)
   ptrdiff_t nbytes =
     (s->size_byte < 0 ? s->size & ~ARRAY_MARK_FLAG : s->size_byte);
 
-  if (!PURE_POINTER_P (s)
-      && s->data
-      && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s)))
+  if (!PURE_P (s) && s->data && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s)))
     emacs_abort ();
   return nbytes;
 }
@@ -4463,9 +4479,6 @@ live_buffer_p (struct mem_node *m, void *p)
 static void
 mark_maybe_object (Lisp_Object obj)
 {
-  void *po;
-  struct mem_node *m;
-
 #if USE_VALGRIND
   if (valgrind_p)
     VALGRIND_MAKE_MEM_DEFINED (&obj, sizeof (obj));
@@ -4474,12 +4487,12 @@ mark_maybe_object (Lisp_Object obj)
   if (INTEGERP (obj))
     return;
 
-  po = (void *) XPNTR (obj);
-  m = mem_find (po);
+  void *po = XPNTR (obj);
+  struct mem_node *m = mem_find (po);
 
   if (m != MEM_NIL)
     {
-      bool mark_p = 0;
+      bool mark_p = false;
 
       switch (XTYPE (obj))
        {
@@ -4860,14 +4873,11 @@ valid_pointer_p (void *p)
 int
 valid_lisp_object_p (Lisp_Object obj)
 {
-  void *p;
-  struct mem_node *m;
-
   if (INTEGERP (obj))
     return 1;
 
-  p = (void *) XPNTR (obj);
-  if (PURE_POINTER_P (p))
+  void *p = XPNTR (obj);
+  if (PURE_P (p))
     return 1;
 
   if (SYMBOLP (obj) && c_symbol_p (p))
@@ -4876,7 +4886,7 @@ valid_lisp_object_p (Lisp_Object obj)
   if (p == &buffer_defaults || p == &buffer_local_symbols)
     return 2;
 
-  m = mem_find (p);
+  struct mem_node *m = mem_find (p);
 
   if (m == MEM_NIL)
     {
@@ -5155,7 +5165,9 @@ Does not copy symbols.  Copies strings without text 
properties.  */)
 static Lisp_Object
 purecopy (Lisp_Object obj)
 {
-  if (PURE_POINTER_P (XPNTR (obj)) || INTEGERP (obj) || SUBRP (obj))
+  if (INTEGERP (obj)
+      || (! SYMBOLP (obj) && PURE_P (XPNTR_OR_SYMBOL_OFFSET (obj)))
+      || SUBRP (obj))
     return obj;    /* Already pure.  */
 
   if (STRINGP (obj) && XSTRING (obj)->intervals)
@@ -5976,7 +5988,7 @@ mark_object (Lisp_Object arg)
  loop:
 
   po = XPNTR (obj);
-  if (PURE_POINTER_P (po))
+  if (PURE_P (po))
     return;
 
   last_marked[last_marked_index++] = obj;
@@ -6213,7 +6225,7 @@ mark_object (Lisp_Object arg)
            break;
          default: emacs_abort ();
          }
-       if (!PURE_POINTER_P (XSTRING (ptr->name)))
+       if (!PURE_P (XSTRING (ptr->name)))
          MARK_STRING (XSTRING (ptr->name));
        MARK_INTERVAL_TREE (string_intervals (ptr->name));
        /* Inner loop to mark next symbol in this bucket, if any.  */
@@ -6360,7 +6372,7 @@ survives_gc_p (Lisp_Object obj)
       emacs_abort ();
     }
 
-  return survives_p || PURE_POINTER_P ((void *) XPNTR (obj));
+  return survives_p || PURE_P (XPNTR (obj));
 }
 
 
diff --git a/src/atimer.c b/src/atimer.c
index 8a1a48b..976b990 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -22,7 +22,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "syssignal.h"
 #include "systime.h"
-#include "blockinput.h"
 #include "atimer.h"
 #include <unistd.h>
 
diff --git a/src/buffer.c b/src/buffer.c
index 0b15ca1..f4c7e81 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -30,7 +30,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <verify.h>
 
 #include "lisp.h"
+#include "coding.h"
 #include "intervals.h"
+#include "systime.h"
 #include "window.h"
 #include "commands.h"
 #include "character.h"
@@ -38,7 +40,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "region-cache.h"
 #include "indent.h"
 #include "blockinput.h"
-#include "keyboard.h"
 #include "keymap.h"
 #include "frame.h"
 
@@ -4579,8 +4580,6 @@ evaporate_overlays (ptrdiff_t pos)
 #include <fcntl.h>
 #endif
 
-#include "coding.h"
-
 
 /* Memory is allocated in regions which are mapped using mmap(2).
    The current implementation lets the system select mapped
diff --git a/src/buffer.h b/src/buffer.h
index a0410d4..f80530a 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -18,9 +18,15 @@ 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_BUFFER_H
+#define EMACS_BUFFER_H
+
 #include <sys/types.h>
 #include <time.h>
 
+#include "character.h"
+#include "lisp.h"
+
 INLINE_HEADER_BEGIN
 
 /* Accessing the parameters of the current buffer.  */
@@ -1377,3 +1383,5 @@ lowercasep (int c)
 INLINE int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); }
 
 INLINE_HEADER_END
+
+#endif /* EMACS_BUFFER_H */
diff --git a/src/callint.c b/src/callint.c
index 12d116d..76ee13e 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -23,10 +23,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "character.h"
 #include "buffer.h"
-#include "commands.h"
 #include "keyboard.h"
 #include "window.h"
-#include "keymap.h"
 
 static Lisp_Object preserved_fns;
 
diff --git a/src/callproc.c b/src/callproc.c
index e38844e..bb21c35 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -44,19 +44,14 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #endif /* MSDOS */
 
 #include "commands.h"
-#include "character.h"
 #include "buffer.h"
-#include "ccl.h"
 #include "coding.h"
-#include "composite.h"
 #include <epaths.h>
 #include "process.h"
 #include "syssignal.h"
-#include "systty.h"
 #include "syswait.h"
 #include "blockinput.h"
 #include "frame.h"
-#include "termhooks.h"
 
 #ifdef MSDOS
 #include "msdos.h"
@@ -1665,7 +1660,7 @@ syms_of_callproc (void)
   DEFVAR_LISP ("shell-file-name", Vshell_file_name,
               doc: /* File name to load inferior shells from.
 Initialized from the SHELL environment variable, or to a system-dependent
-default if SHELL is not set.  */);
+default if SHELL is unset.  See Info node `(elisp)Security Considerations'.  
*/);
 
   DEFVAR_LISP ("exec-path", Vexec_path,
               doc: /* List of directories to search programs to run in 
subprocesses.
diff --git a/src/casetab.c b/src/casetab.c
index b086abc..28da885 100644
--- a/src/casetab.c
+++ b/src/casetab.c
@@ -21,7 +21,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include "lisp.h"
-#include "character.h"
 #include "buffer.h"
 
 Lisp_Object Vascii_downcase_table;
diff --git a/src/category.c b/src/category.c
index 400116f..5c7cf07 100644
--- a/src/category.c
+++ b/src/category.c
@@ -33,9 +33,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "character.h"
 #include "buffer.h"
-#include "charset.h"
 #include "category.h"
-#include "keymap.h"
 
 /* This setter is used only in this file, so it can be private.  */
 static void
diff --git a/src/category.h b/src/category.h
index ef784c8..02f9a19 100644
--- a/src/category.h
+++ b/src/category.h
@@ -22,6 +22,8 @@ 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_CATEGORY_H
+#define EMACS_CATEGORY_H
 
 /* We introduce here three types of object: category, category set,
    and category table.
@@ -53,6 +55,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
    The second extra slot is a version number of the category table.
    But, for the moment, we are not using this slot.  */
 
+#include "lisp.h"
+
 INLINE_HEADER_BEGIN
 
 #define CATEGORYP(x) RANGED_INTEGERP (0x20, x, 0x7E)
@@ -116,3 +120,5 @@ CHAR_HAS_CATEGORY (int ch, int category)
 extern bool word_boundary_p (int, int);
 
 INLINE_HEADER_END
+
+#endif /* EMACS_CATEGORY_H */
diff --git a/src/ccl.h b/src/ccl.h
index 7b72dc7..fdce437 100644
--- a/src/ccl.h
+++ b/src/ccl.h
@@ -26,8 +26,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifndef EMACS_CCL_H
 #define EMACS_CCL_H
 
-#include "character.h" /* For MAX_MULTIBYTE_LENGTH */
-
 /* Macros for exit status of CCL program.  */
 #define CCL_STAT_SUCCESS       0 /* Terminated successfully.  */
 #define CCL_STAT_SUSPEND_BY_SRC        1 /* Terminated by empty input.  */
diff --git a/src/character.c b/src/character.c
index f51d971..3e2bf1e 100644
--- a/src/character.c
+++ b/src/character.c
@@ -38,7 +38,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "character.h"
 #include "buffer.h"
-#include "charset.h"
 #include "composite.h"
 #include "disptab.h"
 
diff --git a/src/character.h b/src/character.h
index 67d4bca..871c1c3 100644
--- a/src/character.h
+++ b/src/character.h
@@ -24,6 +24,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #define EMACS_CHARACTER_H
 
 #include <verify.h>
+#include "lisp.h"
 
 INLINE_HEADER_BEGIN
 
diff --git a/src/charset.c b/src/charset.c
index eeebf17..04e81bb 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -38,7 +38,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "character.h"
 #include "charset.h"
 #include "coding.h"
-#include "disptab.h"
 #include "buffer.h"
 
 /*** GENERAL NOTES on CODED CHARACTER SETS (CHARSETS) ***
diff --git a/src/charset.h b/src/charset.h
index f657598..d2daf2b 100644
--- a/src/charset.h
+++ b/src/charset.h
@@ -28,6 +28,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #define EMACS_CHARSET_H
 
 #include <verify.h>
+#include "lisp.h"
 
 INLINE_HEADER_BEGIN
 
diff --git a/src/chartab.c b/src/chartab.c
index 274bb60..ec618f3 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -23,7 +23,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "character.h"
 #include "charset.h"
-#include "ccl.h"
 
 /* 64/16/32/128 */
 
diff --git a/src/cm.c b/src/cm.c
index 474f280..f0aa56d 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -22,9 +22,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 
 #include "lisp.h"
-#include "frame.h"
 #include "cm.h"
-#include "termhooks.h"
 #include "termchar.h"
 #include "tparam.h"
 
diff --git a/src/cm.h b/src/cm.h
index 829abc0..1ade6d1 100644
--- a/src/cm.h
+++ b/src/cm.h
@@ -16,6 +16,9 @@ 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_CM_H
+#define EMACS_CM_H
+
 /* Holds the minimum and maximum costs for the parameterized capabilities.  */
 struct parmcap
   {
@@ -166,3 +169,5 @@ extern void cmcostinit (struct tty_display_info *);
 extern void cmgoto (struct tty_display_info *, int, int);
 extern void Wcm_clear (struct tty_display_info *);
 extern int Wcm_init (struct tty_display_info *);
+
+#endif /* EMACS_CM_H */
diff --git a/src/cmds.c b/src/cmds.c
index 39c5af9..0afc023 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -25,10 +25,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "character.h"
 #include "buffer.h"
 #include "syntax.h"
-#include "window.h"
 #include "keyboard.h"
 #include "keymap.h"
-#include "dispextern.h"
 #include "frame.h"
 
 static int internal_self_insert (int, EMACS_INT);
diff --git a/src/coding.c b/src/coding.c
index c5099a7..0b42a36 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -297,8 +297,6 @@ encode_coding_XXX (struct coding_system *coding)
 #include "ccl.h"
 #include "composite.h"
 #include "coding.h"
-#include "window.h"
-#include "frame.h"
 #include "termhooks.h"
 
 Lisp_Object Vcoding_system_hash_table;
diff --git a/src/coding.h b/src/coding.h
index c73a9cc..2bf51c4 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -26,6 +26,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifndef EMACS_CODING_H
 #define EMACS_CODING_H
 
+#include "lisp.h"
+
 /* Index to arguments of Fdefine_coding_system_internal.  */
 
 enum define_coding_system_arg_index
diff --git a/src/commands.h b/src/commands.h
index 19cd2e4..e938334 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -16,6 +16,10 @@ 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_COMMANDS_H
+#define EMACS_COMMANDS_H
+
+#include "lisp.h"
 
 #define Ctl(c) ((c)&037)
 
@@ -39,3 +43,5 @@ extern Lisp_Object unread_switch_frame;
 /* Nonzero if input is coming from the keyboard.  */
 
 #define INTERACTIVE (NILP (Vexecuting_kbd_macro) && !noninteractive)
+
+#endif /* EMACS_COMMANDS_H */
diff --git a/src/composite.c b/src/composite.c
index 88cef22..0f729bc 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -26,13 +26,12 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "character.h"
+#include "composite.h"
 #include "buffer.h"
 #include "coding.h"
 #include "intervals.h"
-#include "window.h"
 #include "frame.h"
 #include "dispextern.h"
-#include "font.h"
 #include "termhooks.h"
 
 
diff --git a/src/data.c b/src/data.c
index b85d8a7..5382b01 100644
--- a/src/data.c
+++ b/src/data.c
@@ -32,9 +32,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "buffer.h"
 #include "keyboard.h"
 #include "frame.h"
-#include "syssignal.h"
-#include "termhooks.h"  /* For FRAME_KBOARD reference in y-or-n-p.  */
-#include "font.h"
 #include "keymap.h"
 
 static void swap_in_symval_forwarding (struct Lisp_Symbol *,
@@ -2603,6 +2600,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, 
Lisp_Object *args)
       accum = 0;
       break;
     case Amult:
+    case Adiv:
       accum = 1;
       break;
     case Alogand:
@@ -2658,7 +2656,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, 
Lisp_Object *args)
            accum *= next;
          break;
        case Adiv:
-         if (!argnum)
+         if (! (argnum || nargs == 1))
            accum = next;
          else
            {
@@ -2727,7 +2725,7 @@ float_arith_driver (double accum, ptrdiff_t argnum, enum 
arithop code,
          accum *= next;
          break;
        case Adiv:
-         if (!argnum)
+         if (! (argnum || nargs == 1))
            accum = next;
          else
            {
@@ -2782,9 +2780,11 @@ usage: (* &rest NUMBERS-OR-MARKERS)  */)
 }
 
 DEFUN ("/", Fquo, Squo, 1, MANY, 0,
-       doc: /* Return first argument divided by all the remaining arguments.
+       doc: /* Divide number by divisors and return the result.
+With two or more arguments, return first argument divided by the rest.
+With one argument, return 1 divided by the argument.
 The arguments must be numbers or markers.
-usage: (/ DIVIDEND &rest DIVISORS)  */)
+usage: (/ NUMBER &rest DIVISORS)  */)
   (ptrdiff_t nargs, Lisp_Object *args)
 {
   ptrdiff_t argnum;
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 181c7d0..ce0465d 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -23,7 +23,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <dbus/dbus.h>
 
 #include "lisp.h"
-#include "frame.h"
 #include "termhooks.h"
 #include "keyboard.h"
 #include "process.h"
diff --git a/src/decompress.c b/src/decompress.c
index 460d4fe..d0c0018 100644
--- a/src/decompress.c
+++ b/src/decompress.c
@@ -23,7 +23,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <zlib.h>
 
 #include "lisp.h"
-#include "character.h"
 #include "buffer.h"
 
 #include <verify.h>
diff --git a/src/dired.c b/src/dired.c
index 3486e49..84bf247 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -39,10 +39,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "systime.h"
-#include "character.h"
 #include "buffer.h"
-#include "commands.h"
-#include "charset.h"
 #include "coding.h"
 #include "regex.h"
 #include "blockinput.h"
diff --git a/src/dispnew.c b/src/dispnew.c
index cde59fd..5be757d 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -28,7 +28,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 /* cm.h must come after dispextern.h on Windows.  */
 #include "dispextern.h"
 #include "cm.h"
-#include "character.h"
 #include "buffer.h"
 #include "keyboard.h"
 #include "frame.h"
@@ -36,12 +35,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "window.h"
 #include "commands.h"
 #include "disptab.h"
-#include "indent.h"
-#include "intervals.h"
 #include "blockinput.h"
-#include "process.h"
-
 #include "syssignal.h"
+#include "systime.h"
 #include "tparam.h"
 
 #ifdef HAVE_WINDOW_SYSTEM
@@ -55,7 +51,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <errno.h>
 
 #include <fpending.h>
-#include <timespec.h>
 
 #ifdef WINDOWSNT
 #include "w32.h"
diff --git a/src/disptab.h b/src/disptab.h
index 7afc862..3a319c4 100644
--- a/src/disptab.h
+++ b/src/disptab.h
@@ -18,6 +18,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 /* Access the slots of a display-table, according to their purpose.  */
 
+#ifndef EMACS_DISPTAB_H
+#define EMACS_DISPTAB_H
+
+#include "lisp.h"
+
 #define DISP_TABLE_P(obj)                                                  \
   (CHAR_TABLE_P (obj)                                                      \
    && EQ (XCHAR_TABLE (obj)->purpose, Qdisplay_table)                      \
@@ -92,3 +97,5 @@ extern struct Lisp_Char_Table *buffer_display_table (void);
 
 #define SET_GLYPH_FROM_CHAR(glyph, c) \
   SET_GLYPH (glyph, c, DEFAULT_FACE_ID)
+
+#endif /* EMACS_DISPTAB_H */
diff --git a/src/doc.c b/src/doc.c
index 68d4367..694c159 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -31,9 +31,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "character.h"
+#include "coding.h"
 #include "buffer.h"
 #include "disptab.h"
-#include "keyboard.h"
 #include "keymap.h"
 
 /* Buffer used for reading from documentation file.  */
diff --git a/src/editfns.c b/src/editfns.c
index 12e5ca8..050eb2a 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -52,11 +52,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <strftime.h>
 #include <verify.h>
 
+#include "composite.h"
 #include "intervals.h"
 #include "character.h"
 #include "buffer.h"
 #include "coding.h"
-#include "frame.h"
 #include "window.h"
 #include "blockinput.h"
 
diff --git a/src/emacs.c b/src/emacs.c
index 85a5a82..825b3c1 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -22,6 +22,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include <errno.h>
+#include <fcntl.h>
 #include <stdio.h>
 
 #include <sys/types.h>
@@ -59,7 +60,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
 
-#include "commands.h"
+#include "coding.h"
 #include "intervals.h"
 #include "character.h"
 #include "buffer.h"
@@ -68,7 +69,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifdef HAVE_XWIDGETS
 # include "xwidget.h"
 #endif
-#include "systty.h"
 #include "atimer.h"
 #include "blockinput.h"
 #include "syssignal.h"
diff --git a/src/emacsgtkfixed.h b/src/emacsgtkfixed.h
index 7364d90..3e5bee4 100644
--- a/src/emacsgtkfixed.h
+++ b/src/emacsgtkfixed.h
@@ -23,6 +23,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include <gtk/gtk.h>
 
+struct frame;
+
 G_BEGIN_DECLS
 
 struct frame;
diff --git a/src/fileio.c b/src/fileio.c
index 3155ef0..428093b 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -43,7 +43,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <c-ctype.h>
 
 #include "lisp.h"
-#include "intervals.h"
+#include "composite.h"
 #include "character.h"
 #include "buffer.h"
 #include "coding.h"
@@ -51,7 +51,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "blockinput.h"
 #include "region-cache.h"
 #include "frame.h"
-#include "dispextern.h"
 
 #ifdef WINDOWSNT
 #define NOMINMAX 1
diff --git a/src/filelock.c b/src/filelock.c
index cad6f83..7f9b6e7 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -45,10 +45,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <c-ctype.h>
 
 #include "lisp.h"
-#include "character.h"
 #include "buffer.h"
 #include "coding.h"
-#include "systime.h"
 #ifdef WINDOWSNT
 #include <share.h>
 #include <sys/socket.h>        /* for fcntl */
diff --git a/src/fns.c b/src/fns.c
index b31bd81..f545066 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -21,25 +21,16 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include <unistd.h>
-#include <time.h>
-
 #include <intprops.h>
 #include <vla.h>
 
 #include "lisp.h"
-#include "commands.h"
 #include "character.h"
 #include "coding.h"
+#include "composite.h"
 #include "buffer.h"
-#include "keyboard.h"
-#include "keymap.h"
 #include "intervals.h"
-#include "frame.h"
 #include "window.h"
-#include "blockinput.h"
-#if defined (HAVE_X_WINDOWS)
-#include "xterm.h"
-#endif
 
 static void sort_vector_copy (Lisp_Object, ptrdiff_t,
                              Lisp_Object [restrict], Lisp_Object [restrict]);
@@ -2875,9 +2866,9 @@ The value is actually the tail of PLIST whose car is 
PROP.  */)
 {
   while (CONSP (plist) && !EQ (XCAR (plist), prop))
     {
-      QUIT;
       plist = XCDR (plist);
       plist = CDR (plist);
+      QUIT;
     }
   return plist;
 }
diff --git a/src/font.c b/src/font.c
index a52a653..016b7e0 100644
--- a/src/font.c
+++ b/src/font.c
@@ -36,6 +36,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "composite.h"
 #include "fontset.h"
 #include "font.h"
+#include "termhooks.h"
 
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
@@ -3981,7 +3982,10 @@ copy_font_spec (Lisp_Object font)
   pcdr = spec->props + FONT_EXTRA_INDEX;
   for (tail = AREF (font, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail))
     if (!EQ (XCAR (XCAR (tail)), QCfont_entity))
-      *pcdr = Fcons (XCAR (tail), Qnil), pcdr = xcdr_addr (*pcdr);
+      {
+        *pcdr = Fcons (Fcons (XCAR (XCAR (tail)), CDR (XCAR (tail))), Qnil);
+        pcdr = xcdr_addr (*pcdr);
+      }
 
   XSETFONT (new_spec, spec);
   return new_spec;
diff --git a/src/font.h b/src/font.h
index 43e67e9..1d13e1c 100644
--- a/src/font.h
+++ b/src/font.h
@@ -22,8 +22,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifndef EMACS_FONT_H
 #define EMACS_FONT_H
 
-#include "ccl.h"
-#include "frame.h"
+struct composition_it;
+struct face;
+struct glyph_string;
 
 INLINE_HEADER_BEGIN
 
diff --git a/src/fontset.c b/src/fontset.c
index e735989..9429d79 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -30,19 +30,13 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "blockinput.h"
 #include "character.h"
-#include "buffer.h"
 #include "charset.h"
-#include "ccl.h"
-#include "keyboard.h"
 #include "frame.h"
 #include "dispextern.h"
-#include "intervals.h"
 #include "fontset.h"
-#include "window.h"
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
-#include "termhooks.h"
 #include "font.h"
 
 /* FONTSET
diff --git a/src/fontset.h b/src/fontset.h
index 6103944..aa69051 100644
--- a/src/fontset.h
+++ b/src/fontset.h
@@ -26,6 +26,10 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifndef EMACS_FONTSET_H
 #define EMACS_FONTSET_H
 
+#include "lisp.h"
+
+struct face;
+
 extern void free_face_fontset (struct frame *, struct face *);
 extern int face_for_char (struct frame *, struct face *, int,
                           ptrdiff_t, Lisp_Object);
diff --git a/src/frame.c b/src/frame.c
index 77ead08..78f8ff7 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -26,7 +26,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <c-ctype.h>
 
 #include "lisp.h"
-#include "character.h"
 
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
@@ -34,7 +33,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "buffer.h"
 /* These help us bind and responding to switch-frame events.  */
-#include "commands.h"
 #include "keyboard.h"
 #include "frame.h"
 #include "blockinput.h"
@@ -42,7 +40,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "termhooks.h"
 #include "dispextern.h"
 #include "window.h"
-#include "font.h"
 #ifdef HAVE_WINDOW_SYSTEM
 #include "fontset.h"
 #endif
@@ -184,16 +181,17 @@ frame_inhibit_resize (struct frame *f, bool horizontal, 
Lisp_Object parameter)
 {
   Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
   bool inhibit
-    = ((f->after_make_frame
-       && (EQ (frame_inhibit_implied_resize, Qt)
-           || (CONSP (frame_inhibit_implied_resize)
-               && !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))))
-       || (horizontal
-          && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullheight))
-       || (!horizontal
-          && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullwidth))
-       || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f));
-
+    = (f->after_make_frame
+       ? (EQ (frame_inhibit_implied_resize, Qt)
+         || (CONSP (frame_inhibit_implied_resize)
+             && !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))
+         || (horizontal
+             && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullheight))
+         || (!horizontal
+             && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullwidth))
+         || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
+       : ((horizontal && f->inhibit_horizontal_resize)
+         || (!horizontal && f->inhibit_vertical_resize)));
   if (inhibit && !FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f))
     frame_size_history_add
       (f, Qframe_inhibit_resize, 0, 0,
@@ -425,17 +423,15 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
 
   if (inhibit >= 2 && inhibit <= 4)
     /* When INHIBIT is in [2..4] inhibit if the "old" window sizes stay
-       within the limits and either frame_inhibit_resize tells us to do
-       so or INHIBIT equals 4.  */
+       within the limits and either resizing is inhibited or INHIBIT
+       equals 4.  */
     {
-      inhibit_horizontal = ((windows_width >= min_windows_width
-                            && (inhibit == 4
-                                || frame_inhibit_resize (f, true, parameter)))
-                           ? true : false);
-      inhibit_vertical = ((windows_height >= min_windows_height
-                          && (inhibit == 4
-                              || frame_inhibit_resize (f, false, parameter)))
-                         ? true : false);
+      inhibit_horizontal = (windows_width >= min_windows_width
+                            && (inhibit == 4
+                                || frame_inhibit_resize (f, true, parameter)));
+      inhibit_vertical = (windows_height >= min_windows_height
+                          && (inhibit == 4
+                              || frame_inhibit_resize (f, false, parameter)));
     }
   else
     /* Otherwise inhibit if INHIBIT equals 5.  */
@@ -634,6 +630,10 @@ make_frame (bool mini_p)
   f->garbaged = true;
   f->can_x_set_window_size = false;
   f->after_make_frame = false;
+  f->inhibit_horizontal_resize = false;
+  f->inhibit_vertical_resize = false;
+  f->tool_bar_redisplayed = false;
+  f->tool_bar_resized = false;
   f->column_width = 1;  /* !FRAME_WINDOW_P value.  */
   f->line_height = 1;  /* !FRAME_WINDOW_P value.  */
 #ifdef HAVE_WINDOW_SYSTEM
@@ -2303,6 +2303,8 @@ otherwise used with utter care to avoid that running 
functions on
 {
   struct frame *f = decode_live_frame (frame);
   f->after_make_frame = !NILP (made);
+  f->inhibit_horizontal_resize = false;
+  f->inhibit_vertical_resize = false;
   return made;
 }
 
@@ -3166,15 +3168,33 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
       prop = parms[i];
       val = values[i];
 
-      if (EQ (prop, Qwidth) && RANGED_INTEGERP (0, val, INT_MAX))
+      if (EQ (prop, Qwidth))
         {
-         width_change = 1;
-          width = XFASTINT (val) * FRAME_COLUMN_WIDTH (f) ;
+         if (RANGED_INTEGERP (0, val, INT_MAX))
+           {
+             width = XFASTINT (val) * FRAME_COLUMN_WIDTH (f) ;
+             width_change = true;
+           }
+         else if (CONSP (val) && EQ (XCAR (val), Qtext_pixels)
+                  && RANGED_INTEGERP (0, XCDR (val), INT_MAX))
+           {
+             width = XFASTINT (XCDR (val));
+             width_change = true;
+           }
         }
-      else if (EQ (prop, Qheight) && RANGED_INTEGERP (0, val, INT_MAX))
+      else if (EQ (prop, Qheight))
         {
-         height_change = 1;
-          height = XFASTINT (val) * FRAME_LINE_HEIGHT (f);
+         if (RANGED_INTEGERP (0, val, INT_MAX))
+           {
+             height = XFASTINT (val) * FRAME_LINE_HEIGHT (f);
+             height_change = true;
+           }
+         else if (CONSP (val) && EQ (XCAR (val), Qtext_pixels)
+                  && RANGED_INTEGERP (0, XCDR (val), INT_MAX))
+           {
+             height = XFASTINT (XCDR (val));
+             height_change = true;
+           }
         }
       else if (EQ (prop, Qtop))
        top = val;
@@ -3262,28 +3282,15 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
     XSETFRAME (frame, f);
 
     if ((width_change && width != FRAME_TEXT_WIDTH (f))
-       || (height_change && height != FRAME_TEXT_HEIGHT (f))
-       || (f->can_x_set_window_size && (f->new_height || f->new_width)))
-      {
-       /* If necessary provide default values for HEIGHT and WIDTH.  Do
-          that here since otherwise a size change implied by an
-          intermittent font change may get lost as in Bug#17142.  */
-       if (!width_change)
-         width = ((f->can_x_set_window_size && f->new_width)
-                  ? (f->new_pixelwise
-                     ? f->new_width
-                     : (f->new_width * FRAME_COLUMN_WIDTH (f)))
-                  : FRAME_TEXT_WIDTH (f));
-
-       if (!height_change)
-         height = ((f->can_x_set_window_size && f->new_height)
-                   ? (f->new_pixelwise
-                      ? f->new_height
-                      : (f->new_height * FRAME_LINE_HEIGHT (f)))
-                   : FRAME_TEXT_HEIGHT (f));
-
-       Fset_frame_size (frame, make_number (width), make_number (height), Qt);
-      }
+       || (height_change && height != FRAME_TEXT_HEIGHT (f)))
+      /* We could consider checking f->after_make_frame here, but I
+        don't have the faintest idea why the following is needed at
+        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))) **/
+      adjust_frame_size (f, width_change ? width : -1,
+                        height_change ? height : -1, 1, 0, 
Qx_set_frame_parameters);
 
     if ((!NILP (left) || !NILP (top))
        && ! (left_no_change && top_no_change)
@@ -3641,6 +3648,10 @@ x_set_font (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
   /* Attempt to hunt down bug#16028.  */
   SET_FRAME_GARBAGED (f);
 
+  /* This is important if we are called by some Lisp as part of
+     redisplaying the frame, see redisplay_internal.  */
+  f->fonts_changed = true;
+
   recompute_basic_faces (f);
 
   do_pending_window_change (0);
@@ -4552,7 +4563,7 @@ 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)
+x_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;
@@ -4571,44 +4582,11 @@ x_figure_window_size (struct frame *f, Lisp_Object 
parms, bool toolbar_p)
   f->top_pos = 0;
   f->left_pos = 0;
 
-  /* Ensure that earlier new_width and new_height settings won't
-     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);
-  if (!EQ (width, Qunbound) || !EQ (height, Qunbound))
-    {
-      if (!EQ (width, Qunbound))
-       {
-         CHECK_NUMBER (width);
-         if (! (0 <= XINT (width) && XINT (width) <= INT_MAX))
-           xsignal1 (Qargs_out_of_range, width);
-
-         SET_FRAME_WIDTH (f, XINT (width) * FRAME_COLUMN_WIDTH (f));
-       }
-
-      if (!EQ (height, Qunbound))
-       {
-         CHECK_NUMBER (height);
-         if (! (0 <= XINT (height) && XINT (height) <= INT_MAX))
-           xsignal1 (Qargs_out_of_range, height);
-
-         SET_FRAME_HEIGHT (f, XINT (height) * FRAME_LINE_HEIGHT (f));
-       }
-
-      user_size = x_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;
-    }
-
-  /* Add a tool bar height to the initial frame height so that the user
-     gets a text display area of the size he specified with -g or via
-     .Xdefaults.  Later changes of the tool bar height don't change the
-     frame size.  This is done so that users can create tall Emacs
-     frames without having to guess how tall the tool bar will get.  */
+  /* Calculate a tool bar height so that the user gets a text display
+     area of the size he specified with -g or via .Xdefaults.  Later
+     changes of the tool bar height don't change the frame size.  This
+     is done so that users can create tall Emacs frames without having
+     to guess how tall the tool bar will get.  */
   if (toolbar_p && FRAME_TOOL_BAR_LINES (f))
     {
       if (frame_default_tool_bar_height)
@@ -4634,6 +4612,65 @@ x_figure_window_size (struct frame *f, Lisp_Object 
parms, bool toolbar_p)
        }
     }
 
+  /* Ensure that earlier new_width and new_height settings won't
+     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);
+  if (!EQ (width, Qunbound) || !EQ (height, Qunbound))
+    {
+      if (!EQ (width, Qunbound))
+       {
+         if (CONSP (width) && EQ (XCAR (width), Qtext_pixels))
+           {
+             CHECK_NUMBER (XCDR (width));
+             if ((XINT (XCDR (width)) < 0 || XINT (XCDR (width)) > INT_MAX))
+               xsignal1 (Qargs_out_of_range, XCDR (width));
+
+             SET_FRAME_WIDTH (f, XINT (XCDR (width)));
+             f->inhibit_horizontal_resize = true;
+             *x_width = XINT (XCDR (width));
+           }
+         else
+           {
+             CHECK_NUMBER (width);
+             if ((XINT (width) < 0 || XINT (width) > INT_MAX))
+               xsignal1 (Qargs_out_of_range, width);
+
+             SET_FRAME_WIDTH (f, XINT (width) * FRAME_COLUMN_WIDTH (f));
+           }
+       }
+
+      if (!EQ (height, Qunbound))
+       {
+         if (CONSP (height) && EQ (XCAR (height), Qtext_pixels))
+           {
+             CHECK_NUMBER (XCDR (height));
+             if ((XINT (XCDR (height)) < 0 || XINT (XCDR (height)) > INT_MAX))
+               xsignal1 (Qargs_out_of_range, XCDR (height));
+
+             SET_FRAME_HEIGHT (f, XINT (XCDR (height)));
+             f->inhibit_vertical_resize = true;
+             *x_height = XINT (XCDR (height));
+           }
+         else
+           {
+             CHECK_NUMBER (height);
+             if ((XINT (height) < 0) || (XINT (height) > INT_MAX))
+               xsignal1 (Qargs_out_of_range, height);
+
+             SET_FRAME_HEIGHT (f, XINT (height) * FRAME_LINE_HEIGHT (f));
+           }
+       }
+
+      user_size = x_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);
@@ -4852,6 +4889,7 @@ syms_of_frame (void)
   DEFSYM (Qonly, "only");
   DEFSYM (Qnone, "none");
   DEFSYM (Qwidth, "width");
+  DEFSYM (Qtext_pixels, "text-pixels");
   DEFSYM (Qgeometry, "geometry");
   DEFSYM (Qicon_left, "icon-left");
   DEFSYM (Qicon_top, "icon-top");
@@ -4909,7 +4947,9 @@ syms_of_frame (void)
   DEFSYM (Qadjust_frame_size_1, "adjust-frame-size-1");
   DEFSYM (Qadjust_frame_size_2, "adjust-frame-size-2");
   DEFSYM (Qadjust_frame_size_3, "adjust-frame-size-3");
+  DEFSYM (Qx_set_frame_parameters, "x-set-frame-parameters");
   DEFSYM (QEmacsFrameResize, "EmacsFrameResize");
+  DEFSYM (Qset_frame_size, "set-frame-size");
   DEFSYM (Qframe_inhibit_resize, "frame-inhibit-resize");
   DEFSYM (Qx_set_fullscreen, "x-set-fullscreen");
   DEFSYM (Qx_check_fullscreen, "x-check-fullscreen");
@@ -4917,13 +4957,16 @@ syms_of_frame (void)
   DEFSYM (Qxg_frame_set_char_size_1, "xg-frame-set-char-size-1");
   DEFSYM (Qxg_frame_set_char_size_2, "xg-frame-set-char-size-2");
   DEFSYM (Qxg_frame_set_char_size_3, "xg-frame-set-char-size-3");
+  DEFSYM (Qx_set_window_size_1, "x-set-window-size-1");
+  DEFSYM (Qx_set_window_size_2, "x-set-window-size-2");
+  DEFSYM (Qx_set_window_size_3, "x-set-window-size-3");
   DEFSYM (Qxg_change_toolbar_position, "xg-change-toolbar-position");
   DEFSYM (Qx_net_wm_state, "x-net-wm-state");
   DEFSYM (Qx_handle_net_wm_state, "x-handle-net-wm-state");
   DEFSYM (Qtb_size_cb, "tb-size-cb");
   DEFSYM (Qupdate_frame_tool_bar, "update-frame-tool-bar");
   DEFSYM (Qfree_frame_tool_bar, "free-frame-tool-bar");
-
+  DEFSYM (Qx_set_menu_bar_lines, "x-set-menu-bar-lines");
   DEFSYM (Qchange_frame_size, "change-frame-size");
   DEFSYM (Qxg_frame_set_char_size, "xg-frame-set-char-size");
   DEFSYM (Qset_window_configuration, "set-window-configuration");
@@ -4952,6 +4995,9 @@ syms_of_frame (void)
   DEFSYM (Qleft_fringe, "left-fringe");
   DEFSYM (Qline_spacing, "line-spacing");
   DEFSYM (Qmenu_bar_lines, "menu-bar-lines");
+  DEFSYM (Qupdate_frame_menubar, "update-frame-menubar");
+  DEFSYM (Qfree_frame_menubar_1, "free-frame-menubar-1");
+  DEFSYM (Qfree_frame_menubar_2, "free-frame-menubar-2");
   DEFSYM (Qmouse_color, "mouse-color");
   DEFSYM (Qname, "name");
   DEFSYM (Qright_divider_width, "right-divider-width");
diff --git a/src/frame.h b/src/frame.h
index af0dadb..e7d3aab 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -16,14 +16,9 @@ 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/>.  */
 
-/* Don't multiply include: dispextern.h includes macterm.h which
-   includes frame.h some emacs source includes both dispextern.h and
-   frame.h.  */
-
 #ifndef EMACS_FRAME_H
 #define EMACS_FRAME_H
 
-#include "dispextern.h"
 #include "termhooks.h"
 #include "window.h"
 
@@ -335,6 +330,14 @@ struct frame
   /* Set to true after this frame was made by `make-frame'.  */
   bool_bf after_make_frame : 1;
 
+  /* Whether the tool bar height change should be taken into account.  */
+  bool_bf tool_bar_redisplayed : 1;
+  bool_bf tool_bar_resized : 1;
+
+  /* Inhibit implied resize before after_make_frame is set.  */
+  bool_bf inhibit_horizontal_resize : 1;
+  bool_bf inhibit_vertical_resize : 1;
+
   /* Non-zero if this frame's faces need to be recomputed.  */
   bool_bf face_change : 1;
 
@@ -1375,7 +1378,7 @@ extern void x_set_horizontal_scroll_bars (struct frame *, 
Lisp_Object, Lisp_Obje
 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);
+extern long x_figure_window_size (struct frame *, Lisp_Object, bool, int *, 
int *);
 
 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
 
diff --git a/src/fringe.c b/src/fringe.c
index fcc5207..632fa0b 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -26,7 +26,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "frame.h"
 #include "window.h"
 #include "dispextern.h"
-#include "character.h"
 #include "buffer.h"
 #include "blockinput.h"
 #include "termhooks.h"
diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index df3aa59..4326b77 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -22,13 +22,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <cairo-ft.h>
 
 #include "lisp.h"
-#include "dispextern.h"
 #include "xterm.h"
-#include "frame.h"
 #include "blockinput.h"
-#include "character.h"
-#include "charset.h"
-#include "fontset.h"
 #include "font.h"
 #include "ftfont.h"
 
diff --git a/src/ftfont.c b/src/ftfont.c
index 15a8159..fb1addb 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -28,13 +28,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "dispextern.h"
-#include "frame.h"
-#include "blockinput.h"
 #include "character.h"
 #include "charset.h"
-#include "coding.h"
 #include "composite.h"
-#include "fontset.h"
 #include "font.h"
 #include "ftfont.h"
 
diff --git a/src/ftxfont.c b/src/ftxfont.c
index cd2bf3e..99b06f2 100644
--- a/src/ftxfont.c
+++ b/src/ftxfont.c
@@ -24,13 +24,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <X11/Xlib.h>
 
 #include "lisp.h"
-#include "dispextern.h"
 #include "xterm.h"
 #include "frame.h"
 #include "blockinput.h"
-#include "character.h"
-#include "charset.h"
-#include "fontset.h"
 #include "font.h"
 
 /* FTX font driver.  */
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index 69f635d..2057f88 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -23,10 +23,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <gio/gio.h>
 #include "lisp.h"
 #include "coding.h"
-#include "frame.h"
 #include "termhooks.h"
 #include "keyboard.h"
-#include "process.h"
 
 
 /* This is a list, elements are triples (DESCRIPTOR FILE FLAGS CALLBACK)  */
diff --git a/src/gnutls.h b/src/gnutls.h
index fd69682..9c804b8 100644
--- a/src/gnutls.h
+++ b/src/gnutls.h
@@ -23,6 +23,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 
+#include "lisp.h"
+
 /* This limits the attempts to handshake per process (connection).  */
 #define GNUTLS_EMACS_HANDSHAKES_LIMIT 100
 
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 34e81b5..701bcab 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -26,20 +26,18 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <c-ctype.h>
 
 #include "lisp.h"
+#include "dispextern.h"
+#include "frame.h"
+#include "systime.h"
 #include "xterm.h"
 #include "blockinput.h"
-#include "syssignal.h"
 #include "window.h"
-#include "buffer.h"
 #include "gtkutil.h"
 #include "termhooks.h"
 #include "keyboard.h"
-#include "charset.h"
 #include "coding.h"
-#include "font.h"
 
 #include <gdk/gdkkeysyms.h>
-#include "xsettings.h"
 
 #ifdef HAVE_XFT
 #include <X11/Xft/Xft.h>
@@ -951,6 +949,8 @@ xg_frame_set_char_size (struct frame *f, int width, int 
height)
       totalwidth /= scale;
     }
 
+  x_wm_set_size_hint (f, 0, 0);
+
   /* Resize the top level widget so rows and columns remain constant.
 
      When the frame is fullheight and we only want to change the width
@@ -964,41 +964,34 @@ 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_number (gheight),
-               make_number (totalheight)));
+        list2 (make_number (gheight), make_number (totalheight)));
 
       gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
-                        gwidth,
-                        totalheight);
+                        gwidth, totalheight);
     }
   else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f))
     {
       frame_size_history_add
        (f, Qxg_frame_set_char_size_2, width, height,
-        list2 (make_number (gwidth),
-               make_number (totalwidth)));
+        list2 (make_number (gwidth), make_number (totalwidth)));
 
       gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
-                        totalwidth,
-                        gheight);
+                        totalwidth, gheight);
     }
   else
     {
       frame_size_history_add
        (f, Qxg_frame_set_char_size_3, width, height,
-        list2 (make_number (totalwidth),
-               make_number (totalheight)));
+        list2 (make_number (totalwidth), make_number (totalheight)));
 
       gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
-                        totalwidth,
-                        totalheight);
+                        totalwidth, totalheight);
       fullscreen = Qnil;
     }
 
   SET_FRAME_GARBAGED (f);
   cancel_mouse_face (f);
 
-  x_wm_set_size_hint (f, 0, 0);
   /* We can not call change_frame_size for a mapped frame,
      we can not set pixel width/height either.  The window manager may
      override our resize request, XMonad does this all the time.
@@ -1399,7 +1392,8 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool 
user_position)
 
   hint_flags |= GDK_HINT_BASE_SIZE;
   /* Use one row/col here so base_height/width does not become zero.
-     Gtk+ and/or Unity on Ubuntu 12.04 can't handle it.  */
+     Gtk+ and/or Unity on Ubuntu 12.04 can't handle it.
+     Obviously this makes the row/col value displayed off by 1.  */
   base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 1) + FRAME_TOOLBAR_WIDTH (f);
   base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 1)
     + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
@@ -4998,9 +4992,23 @@ update_frame_tool_bar (struct frame *f)
       gtk_widget_show_all (x->toolbar_widget);
       if (xg_update_tool_bar_sizes (f))
        {
+         int inhibit
+           = ((f->after_make_frame
+               && !f->tool_bar_resized
+               && (EQ (frame_inhibit_implied_resize, Qt)
+                   || (CONSP (frame_inhibit_implied_resize)
+                       && !NILP (Fmemq (Qtool_bar_lines,
+                                        frame_inhibit_implied_resize))))
+               /* This will probably fail to DTRT in the
+                  fullheight/-width cases.  */
+               && NILP (get_frame_param (f, Qfullscreen)))
+              ? 0
+              : 2);
+
          frame_size_history_add (f, Qupdate_frame_tool_bar, 0, 0, Qnil);
-         adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+         adjust_frame_size (f, -1, -1, inhibit, 0, Qtool_bar_lines);
        }
+      f->tool_bar_resized = f->tool_bar_redisplayed;
     }
 
   unblock_input ();
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 34338db..0dbb4a1 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -25,7 +25,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include <gtk/gtk.h>
 #include "../lwlib/lwlib-widget.h"
-#include "frame.h"
 #include "xterm.h"
 
 /* Minimum and maximum values used for GTK scroll bars  */
diff --git a/src/image.c b/src/image.c
index c702782..928eb5c 100644
--- a/src/image.c
+++ b/src/image.c
@@ -18,7 +18,9 @@ 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 "sysstdio.h"
+
+#include <fcntl.h>
+#include <stdio.h>
 #include <unistd.h>
 
 /* Include this before including <setjmp.h> to work around bugs with
@@ -38,7 +40,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "blockinput.h"
 #include "systime.h"
 #include <epaths.h>
-#include "character.h"
 #include "coding.h"
 #include "termhooks.h"
 #include "font.h"
@@ -2292,7 +2293,19 @@ x_find_image_fd (Lisp_Object file, int *pfd)
   /* Try to find FILE in data-directory/images, then x-bitmap-file-path.  */
   fd = openp (search_path, file, Qnil, &file_found,
              pfd ? Qt : make_number (R_OK), false);
-  if (fd < 0)
+  if (fd >= 0 || fd == -2)
+    {
+      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.  */
+         fd = emacs_open (SSDATA (file_found), O_RDONLY | O_BINARY, 0);
+       }
+    }
+  else /* fd < 0, but not -2 */
     return Qnil;
   if (pfd)
     *pfd = fd;
diff --git a/src/indent.c b/src/indent.c
index 330065b..04837f8 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -26,10 +26,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "category.h"
 #include "composite.h"
 #include "indent.h"
-#include "keyboard.h"
 #include "frame.h"
 #include "window.h"
-#include "termchar.h"
 #include "disptab.h"
 #include "intervals.h"
 #include "dispextern.h"
diff --git a/src/indent.h b/src/indent.h
index cece9e4..037fd74 100644
--- a/src/indent.h
+++ b/src/indent.h
@@ -16,6 +16,11 @@ 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_INDENT_H
+#define EMACS_INDENT_H
+
+#include "lisp.h"
+
 struct position
   {
     ptrdiff_t bufpos;
@@ -51,3 +56,5 @@ bool disptab_matches_widthtab (struct Lisp_Char_Table 
*disptab,
 /* Recompute BUF's width table, using the display table DISPTAB.  */
 void recompute_width_table (struct buffer *buf,
                             struct Lisp_Char_Table *disptab);
+
+#endif /* EMACS_INDENT_H */
diff --git a/src/inotify.c b/src/inotify.c
index be8c1dd..d1a80bb 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -25,8 +25,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "coding.h"
 #include "process.h"
 #include "keyboard.h"
-#include "character.h"
-#include "frame.h" /* Required for termhooks.h.  */
 #include "termhooks.h"
 
 #include <errno.h>
diff --git a/src/insdel.c b/src/insdel.c
index a977b79..24807b1 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -23,11 +23,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <intprops.h>
 
 #include "lisp.h"
+#include "composite.h"
 #include "intervals.h"
 #include "character.h"
 #include "buffer.h"
 #include "window.h"
-#include "blockinput.h"
 #include "region-cache.h"
 
 static void insert_from_string_1 (Lisp_Object, ptrdiff_t, ptrdiff_t, ptrdiff_t,
diff --git a/src/intervals.c b/src/intervals.c
index 1c8dd41..c272bae 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -43,10 +43,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <intprops.h>
 #include "lisp.h"
 #include "intervals.h"
-#include "character.h"
 #include "buffer.h"
 #include "puresize.h"
-#include "keyboard.h"
 #include "keymap.h"
 
 /* Test for membership, allowing for t (actually any non-cons) to mean the
diff --git a/src/intervals.h b/src/intervals.h
index 30fb4b1..96e8205 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -16,7 +16,8 @@ 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 "dispextern.h"
+#ifndef EMACS_INTERVALS_H
+#define EMACS_INTERVALS_H
 
 INLINE_HEADER_BEGIN
 
@@ -292,6 +293,6 @@ extern int text_property_stickiness (Lisp_Object prop, 
Lisp_Object pos,
 
 extern void syms_of_textprop (void);
 
-#include "composite.h"
-
 INLINE_HEADER_END
+
+#endif /* EMACS_INTERVALS_H */
diff --git a/src/keyboard.c b/src/keyboard.c
index 461c642..84d7812 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -20,10 +20,10 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
-#include "sysstdio.h"
 #include <sys/stat.h>
 
 #include "lisp.h"
+#include "coding.h"
 #include "termchar.h"
 #include "termopts.h"
 #include "frame.h"
@@ -34,13 +34,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "commands.h"
 #include "character.h"
 #include "buffer.h"
-#include "disptab.h"
 #include "dispextern.h"
 #include "syntax.h"
 #include "intervals.h"
 #include "keymap.h"
 #include "blockinput.h"
-#include "puresize.h"
 #include "systime.h"
 #include "atimer.h"
 #include "process.h"
diff --git a/src/keyboard.h b/src/keyboard.h
index 0402e0a..98bc86b 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -17,7 +17,9 @@ 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 "systime.h"           /* for struct timespec, Time */
+#ifndef EMACS_KEYBOARD_H
+#define EMACS_KEYBOARD_H
+
 #include "coding.h"             /* for ENCODE_UTF_8 and ENCODE_SYSTEM */
 #include "termhooks.h"
 
@@ -483,3 +485,5 @@ extern const char *const lispy_function_keys[];
 #endif
 
 INLINE_HEADER_END
+
+#endif /* EMACS_KEYBOARD_H */
diff --git a/src/keymap.c b/src/keymap.c
index 81091f0..c988d12 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -46,9 +46,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "commands.h"
 #include "character.h"
 #include "buffer.h"
-#include "charset.h"
 #include "keyboard.h"
-#include "frame.h"
 #include "termhooks.h"
 #include "blockinput.h"
 #include "puresize.h"
diff --git a/src/keymap.h b/src/keymap.h
index 215dd3f..e7a3b0a 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -19,6 +19,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifndef KEYMAP_H
 #define KEYMAP_H
 
+#include "lisp.h"
+
 /* The maximum byte size consumed by push_key_description.
    All callers should assure that at least this size of memory is
    allocated at the place pointed by the second argument.
diff --git a/src/lisp.h b/src/lisp.h
index d72fb87..a57837f 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -351,8 +351,6 @@ error !;
 #define lisp_h_XCONS(a) \
    (eassert (CONSP (a)), (struct Lisp_Cons *) XUNTAG (a, Lisp_Cons))
 #define lisp_h_XHASH(a) XUINT (a)
-#define lisp_h_XPNTR(a) \
-   (SYMBOLP (a) ? XSYMBOL (a) : (void *) ((intptr_t) (XLI (a) & VALMASK)))
 #ifndef GC_CHECK_CONS_LIST
 # define lisp_h_check_cons_list() ((void) 0)
 #endif
@@ -397,7 +395,6 @@ error !;
 # define XCDR(c) lisp_h_XCDR (c)
 # define XCONS(a) lisp_h_XCONS (a)
 # define XHASH(a) lisp_h_XHASH (a)
-# define XPNTR(a) lisp_h_XPNTR (a)
 # ifndef GC_CHECK_CONS_LIST
 #  define check_cons_list() lisp_h_check_cons_list ()
 # endif
@@ -922,9 +919,6 @@ XUNTAG (Lisp_Object a, int type)
 
 #endif /* ! USE_LSB_TAG */
 
-/* Extract the pointer hidden within A.  */
-LISP_MACRO_DEFUN (XPNTR, void *, (Lisp_Object a), (a))
-
 /* Extract A's value as an unsigned integer.  */
 INLINE EMACS_UINT
 XUINT (Lisp_Object a)
diff --git a/src/lread.c b/src/lread.c
index bceec4b..a98fa61 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -31,6 +31,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <math.h>
 #include <stat-time.h>
 #include "lisp.h"
+#include "dispextern.h"
 #include "intervals.h"
 #include "character.h"
 #include "buffer.h"
@@ -39,7 +40,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <epaths.h>
 #include "commands.h"
 #include "keyboard.h"
-#include "frame.h"
+#include "systime.h"
 #include "termhooks.h"
 #include "blockinput.h"
 
diff --git a/src/macros.c b/src/macros.c
index 1bf2cd7..d963838 100644
--- a/src/macros.c
+++ b/src/macros.c
@@ -22,9 +22,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "macros.h"
-#include "commands.h"
-#include "character.h"
-#include "buffer.h"
 #include "window.h"
 #include "keyboard.h"
 
diff --git a/src/macros.h b/src/macros.h
index eab8041..46150ad 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -16,6 +16,10 @@ 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_MACROS_H
+#define EMACS_MACROS_H
+
+#include "lisp.h"
 
 /* Number of successful iterations so far
    for innermost keyboard macro.
@@ -42,3 +46,5 @@ extern void finalize_kbd_macro_chars (void);
 /* Store a character into kbd macro being defined */
 
 extern void store_kbd_macro_char (Lisp_Object);
+
+#endif /* EMACS_MACROS_H */
diff --git a/src/menu.c b/src/menu.c
index dc82809..74df43f 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -23,13 +23,14 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <limits.h> /* for INT_MAX */
 
 #include "lisp.h"
+#include "character.h"
+#include "coding.h"
 #include "keyboard.h"
 #include "keymap.h"
 #include "frame.h"
 #include "window.h"
 #include "termhooks.h"
 #include "blockinput.h"
-#include "dispextern.h"
 #include "buffer.h"
 
 #ifdef USE_X_TOOLKIT
diff --git a/src/menu.h b/src/menu.h
index de586a5..e89e93e 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -19,7 +19,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifndef MENU_H
 #define MENU_H
 
-#include "systime.h" /* for Time */
 #include "../lwlib/lwlib-widget.h"
 
 /* Bit fields used by terminal-specific menu_show_hook.  */
diff --git a/src/minibuf.c b/src/minibuf.c
index 4e5c17d..31b6946 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -25,17 +25,12 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <binary-io.h>
 
 #include "lisp.h"
-#include "commands.h"
 #include "character.h"
 #include "buffer.h"
-#include "dispextern.h"
 #include "keyboard.h"
 #include "frame.h"
 #include "window.h"
-#include "syntax.h"
-#include "intervals.h"
 #include "keymap.h"
-#include "termhooks.h"
 #include "systty.h"
 
 /* List of buffers for use as minibuffers.
@@ -1595,8 +1590,11 @@ PROMPT is a string to prompt with; normally it ends in a 
colon and a space.
 COLLECTION can be a list of strings, an alist, an obarray or a hash table.
 COLLECTION can also be a function to do the completion itself.
 PREDICATE limits completion to a subset of COLLECTION.
-See `try-completion' and `all-completions' for more details
- on completion, COLLECTION, and PREDICATE.
+See `try-completion', `all-completions', `test-completion',
+and `completion-boundaries', for more details on completion,
+COLLECTION, and PREDICATE.  See also Info nodes `(elisp)Basic Completion'
+for the details about completion, and `(elisp)Programmed Completion' for
+expectations from COLLECTION when it's a function.
 
 REQUIRE-MATCH can take the following values:
 - t means that the user is not allowed to exit unless
diff --git a/src/nsfns.m b/src/nsfns.m
index ad71a50..43002ca 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -679,7 +679,23 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
         }
     }
 
-  x_set_window_size (f, 0, f->text_cols, f->text_lines, 0);
+  {
+    int inhibit
+      = ((f->after_make_frame
+         && !f->tool_bar_resized
+         && (EQ (frame_inhibit_implied_resize, Qt)
+             || (CONSP (frame_inhibit_implied_resize)
+                 && !NILP (Fmemq (Qtool_bar_lines,
+                                  frame_inhibit_implied_resize))))
+         /* This will probably fail to DTRT in the
+            fullheight/-width cases.  */
+         && NILP (get_frame_param (f, Qfullscreen)))
+        ? 0
+        : 2);
+
+    frame_size_history_add (f, Qupdate_frame_tool_bar, 0, 0, Qnil);
+    adjust_frame_size (f, -1, -1, inhibit, 0, Qtool_bar_lines);
+  }
 }
 
 
@@ -1082,6 +1098,7 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   Lisp_Object parent;
   struct kboard *kb;
   static int desc_ctr = 1;
+  int x_width = 0, x_height = 0;
 
   /* x_get_arg modifies parms.  */
   parms = Fcopy_alist (parms);
@@ -1268,7 +1285,7 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
                        RES_TYPE_STRING);
 
   parms = get_geometry_from_preferences (dpyinfo, parms);
-  window_prompting = x_figure_window_size (f, parms, 1);
+  window_prompting = x_figure_window_size (f, parms, true, &x_width, 
&x_height);
 
   tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !EQ (tem, Qnil));
@@ -1322,6 +1339,11 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   /* Allow x_set_window_size, now.  */
   f->can_x_set_window_size = true;
 
+  if (x_width > 0)
+    SET_FRAME_WIDTH (f, x_width);
+  if (x_height > 0)
+    SET_FRAME_HEIGHT (f, x_height);
+
   adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1,
                     Qx_create_frame_2);
 
diff --git a/src/nsterm.m b/src/nsterm.m
index 65d07b2..c4bfd7c 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1365,9 +1365,12 @@ x_set_window_size (struct frame *f,
     FRAME_TOOLBAR_HEIGHT (f) =
       NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
         - FRAME_NS_TITLEBAR_HEIGHT (f);
+#if 0
+      /* Only breaks things here, removed by martin 2015-09-30.  */
 #ifdef NS_IMPL_GNUSTEP
       FRAME_TOOLBAR_HEIGHT (f) -= 3;
 #endif
+#endif
     }
   else
     FRAME_TOOLBAR_HEIGHT (f) = 0;
@@ -1386,6 +1389,14 @@ x_set_window_size (struct frame *f,
  else
    wr.origin.y += orig_height - wr.size.height;
 
+ frame_size_history_add
+   (f, Qx_set_window_size_1, width, height,
+    list5 (Fcons (make_number (pixelwidth), make_number (pixelheight)),
+          Fcons (make_number (wr.size.width), make_number (wr.size.height)),
+          make_number (f->border_width),
+          make_number (FRAME_NS_TITLEBAR_HEIGHT (f)),
+          make_number (FRAME_TOOLBAR_HEIGHT (f))));
+
   [view setRows: rows andColumns: cols];
   [window setFrame: wr display: YES];
 
@@ -7741,8 +7752,9 @@ x_new_font (struct frame *f, Lisp_Object font_object, int 
fontset)
 
   /* Now make the frame display the given font.  */
   if (FRAME_NS_WINDOW (f) != 0 && ! [view isFullscreen])
-    x_set_window_size (f, false, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
-                       FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), true);
+    adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
+                      FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3,
+                      false, Qfont);
 
   return font_object;
 }
diff --git a/src/print.c b/src/print.c
index 21402fc..2443bba 100644
--- a/src/print.c
+++ b/src/print.c
@@ -24,19 +24,14 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "character.h"
+#include "coding.h"
 #include "buffer.h"
 #include "charset.h"
-#include "keyboard.h"
 #include "frame.h"
-#include "window.h"
 #include "process.h"
-#include "dispextern.h"
 #include "disptab.h"
-#include "termchar.h"
 #include "intervals.h"
 #include "blockinput.h"
-#include "termhooks.h"         /* For struct terminal.  */
-#include "font.h"
 
 #ifdef HAVE_XWIDGETS
 # include "xwidget.h"
@@ -46,6 +41,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <float.h>
 #include <ftoastr.h>
 
+struct terminal;
+
 /* Avoid actual stack overflow in print.  */
 static ptrdiff_t print_depth;
 
diff --git a/src/process.c b/src/process.c
index 55f31a0..dc93b86 100644
--- a/src/process.c
+++ b/src/process.c
@@ -103,13 +103,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "coding.h"
 #include "process.h"
 #include "frame.h"
-#include "termhooks.h"
 #include "termopts.h"
-#include "commands.h"
 #include "keyboard.h"
 #include "blockinput.h"
-#include "dispextern.h"
-#include "composite.h"
 #include "atimer.h"
 #include "sysselect.h"
 #include "syssignal.h"
diff --git a/src/process.h b/src/process.h
index 24bad45..9ee5a05 100644
--- a/src/process.h
+++ b/src/process.h
@@ -16,6 +16,9 @@ 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_PROCESS_H
+#define EMACS_PROCESS_H
+
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -243,3 +246,5 @@ extern Lisp_Object network_interface_info (Lisp_Object);
 extern Lisp_Object remove_slash_colon (Lisp_Object);
 
 INLINE_HEADER_END
+
+#endif /* EMACS_PROCESS_H */
diff --git a/src/puresize.h b/src/puresize.h
index c61b31f..f075624 100644
--- a/src/puresize.h
+++ b/src/puresize.h
@@ -16,6 +16,11 @@ 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_PURESIZE_H
+#define EMACS_PURESIZE_H
+
+#include "lisp.h"
+
 INLINE_HEADER_BEGIN
 
 /* Define PURESIZE, the number of bytes of pure Lisp code to leave space for.
@@ -92,3 +97,5 @@ CHECK_IMPURE (Lisp_Object obj, void *ptr)
 }
 
 INLINE_HEADER_END
+
+#endif /* EMACS_PURESIZE_H */
diff --git a/src/regex.h b/src/regex.h
index c89ca46..eaa7729 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -167,6 +167,7 @@ typedef unsigned long reg_syntax_t;
 extern reg_syntax_t re_syntax_options;
 
 #ifdef emacs
+# include "lisp.h"
 /* In Emacs, this is the string or buffer in which we
    are matching.  It is used for looking up syntax properties.  */
 extern Lisp_Object re_match_object;
diff --git a/src/region-cache.c b/src/region-cache.c
index 937f3d0..1383acd 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -23,7 +23,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 
 #include "lisp.h"
-#include "character.h"
 #include "buffer.h"
 #include "region-cache.h"
 
diff --git a/src/region-cache.h b/src/region-cache.h
index 1f336ce..2814df4 100644
--- a/src/region-cache.h
+++ b/src/region-cache.h
@@ -18,6 +18,8 @@ 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_REGION_CACHE_H
+#define EMACS_REGION_CACHE_H
 
 /* This code was written by Jim Blandy <address@hidden> to help
    GNU Emacs better support the gene editor written for the University
@@ -60,6 +62,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
    this region has property P" vs. "I don't know if this region has
    property P or not."  */
 
+struct buffer;
 
 /* Allocate, initialize and return a new, empty region cache.  */
 struct region_cache *new_region_cache (void);
@@ -105,3 +108,5 @@ extern int region_cache_forward (struct buffer *buf, struct 
region_cache *c,
 /* Likewise, except before POS rather than after POS.  */
 extern int region_cache_backward (struct buffer *buf, struct region_cache *c,
                                  ptrdiff_t pos, ptrdiff_t *next);
+
+#endif /* EMACS_REGION_CACHE_H */
diff --git a/src/scroll.c b/src/scroll.c
index 7f5b73b..2534ab0 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -25,9 +25,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "termchar.h"
 #include "dispextern.h"
-#include "keyboard.h"
 #include "frame.h"
-#include "window.h"
 #include "termhooks.h"
 
 /* All costs measured in characters.
diff --git a/src/search.c b/src/search.c
index 8c9714e..e39ba3d 100644
--- a/src/search.c
+++ b/src/search.c
@@ -22,13 +22,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include "lisp.h"
-#include "category.h"
 #include "character.h"
 #include "buffer.h"
 #include "syntax.h"
 #include "charset.h"
 #include "region-cache.h"
-#include "commands.h"
 #include "blockinput.h"
 #include "intervals.h"
 
diff --git a/src/sheap.c b/src/sheap.c
index 58a6a0b..df33353 100644
--- a/src/sheap.c
+++ b/src/sheap.c
@@ -20,24 +20,15 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
-
 #include "lisp.h"
-
 #include <unistd.h>
+#include <stdlib.h>            /* for exit */
 
-#ifdef __x86_64__
 #ifdef ENABLE_CHECKING
 #define STATIC_HEAP_SIZE       (28 * 1024 * 1024)
 #else
 #define STATIC_HEAP_SIZE       (19 * 1024 * 1024)
 #endif
-#else  /* x86 */
-#ifdef ENABLE_CHECKING
-#define STATIC_HEAP_SIZE       (18 * 1024 * 1024)
-#else
-#define STATIC_HEAP_SIZE       (13 * 1024 * 1024)
-#endif
-#endif /* x86 */
 
 int debug_sheap = 0;
 
diff --git a/src/sound.c b/src/sound.c
index 9a365c7..09ab48c 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -46,7 +46,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <errno.h>
 
 #include "lisp.h"
-#include "dispextern.h"
 #include "atimer.h"
 #include "syssignal.h"
 /* END: Common Includes */
diff --git a/src/syntax.c b/src/syntax.c
index 6bfb3b7..1dcb3a5 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -23,12 +23,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <sys/types.h>
 
 #include "lisp.h"
-#include "commands.h"
 #include "character.h"
 #include "buffer.h"
-#include "keymap.h"
 #include "regex.h"
-
 #include "syntax.h"
 #include "intervals.h"
 #include "category.h"
diff --git a/src/syntax.h b/src/syntax.h
index 34b652b..06ce0ec 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -18,6 +18,12 @@ 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_SYNTAX_H
+#define EMACS_SYNTAX_H
+
+#include "buffer.h"
+#include "lisp.h"
+
 INLINE_HEADER_BEGIN
 
 extern void update_syntax_table (ptrdiff_t, EMACS_INT, bool, Lisp_Object);
@@ -213,3 +219,5 @@ extern ptrdiff_t scan_words (ptrdiff_t, EMACS_INT);
 extern void SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object, ptrdiff_t, ptrdiff_t);
 
 INLINE_HEADER_END
+
+#endif /* EMACS_SYNTAX_H */
diff --git a/src/sysdep.c b/src/sysdep.c
index 836cc27..1af323e 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -93,13 +93,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "keyboard.h"
 #include "frame.h"
-#include "window.h"
 #include "termhooks.h"
 #include "termchar.h"
 #include "termopts.h"
-#include "dispextern.h"
 #include "process.h"
-#include "cm.h"  /* for reset_sys_modes */
+#include "cm.h"
 
 #ifdef WINDOWSNT
 #include <direct.h>
diff --git a/src/sysselect.h b/src/sysselect.h
index 54f90fb..d6c5d1c 100644
--- a/src/sysselect.h
+++ b/src/sysselect.h
@@ -23,6 +23,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <sys/select.h>
 #endif
 
+#include "lisp.h"
+
 /* The w32 build defines select stuff in w32.h, which is included
    where w32 needs it, but not where sysselect.h is included.  The w32
    definitions in w32.h are incompatible with the below.  */
diff --git a/src/syssignal.h b/src/syssignal.h
index 5c14479..ec60994 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -17,6 +17,9 @@ 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_SYSSIGNAL_H
+#define EMACS_SYSSIGNAL_H
+
 #include <signal.h>
 
 extern void init_signals (bool);
@@ -72,3 +75,5 @@ char const *safe_strsignal (int) ATTRIBUTE_CONST;
 #endif
 
 void deliver_process_signal (int, signal_handler_t);
+
+#endif /* EMACS_SYSSIGNAL_H */
diff --git a/src/sysstdio.h b/src/sysstdio.h
index c97c4f8..1668230 100644
--- a/src/sysstdio.h
+++ b/src/sysstdio.h
@@ -17,6 +17,9 @@ 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_SYSSTDIO_H
+#define EMACS_SYSSTDIO_H
+
 #include <fcntl.h>
 #include <stdio.h>
 
@@ -29,3 +32,5 @@ extern FILE *emacs_fopen (char const *, char const *);
 # define FOPEN_BINARY ""
 # define FOPEN_TEXT ""
 #endif
+
+#endif /* EMACS_SYSSTDIO_H */
diff --git a/src/systime.h b/src/systime.h
index 315f9d1..a7c182a 100644
--- a/src/systime.h
+++ b/src/systime.h
@@ -83,8 +83,8 @@ extern struct timeval make_timeval (struct timespec) 
ATTRIBUTE_CONST;
 extern void set_waiting_for_input (struct timespec *);
 
 /* When lisp.h is not included Lisp_Object is not defined (this can
-   happen when this files is used outside the src directory).  */
-#ifdef EMACS_LISP_H
+   happen when this file is used outside the src directory).  */
+#ifdef emacs
 
 /* Emacs uses the integer list (HI LO US PS) to represent the time
    (HI << LO_TIME_BITS) + LO + US / 1e6 + PS / 1e12.  */
diff --git a/src/systty.h b/src/systty.h
index 3a46156..1022455 100644
--- a/src/systty.h
+++ b/src/systty.h
@@ -16,6 +16,9 @@ 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_SYSTTY_H
+#define EMACS_SYSTTY_H
+
 /* Include the proper files.  */
 
 #ifndef DOS_NT
@@ -37,6 +40,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include <unistd.h>
 
+#include "lisp.h"
+
 
 /* Try to establish the correct character to disable terminal functions
    in a system-independent manner.  Note that USG (at least) define
@@ -85,3 +90,5 @@ extern int emacs_set_tty (int, struct emacs_tty *, bool) 
EXTERNALLY_VISIBLE;
 extern void suppress_echo_on_tty (int);
 extern int serial_open (Lisp_Object);
 extern void serial_configure (struct Lisp_Process *, Lisp_Object);
+
+#endif /* EMACS_SYSTTY_H */
diff --git a/src/term.c b/src/term.c
index 5acc473..9b1e7ca 100644
--- a/src/term.c
+++ b/src/term.c
@@ -44,8 +44,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "keymap.h"
 #include "blockinput.h"
 #include "syssignal.h"
-#include "systty.h"
-#include "intervals.h"
 #ifdef MSDOS
 #include "msdos.h"
 static int been_here = -1;
@@ -56,10 +54,6 @@ static int been_here = -1;
 #endif
 
 #include "cm.h"
-#ifdef HAVE_X_WINDOWS
-#include "xterm.h"
-#endif
-
 #include "menu.h"
 
 /* The name of the default console device.  */
diff --git a/src/termchar.h b/src/termchar.h
index d8066d7..06c0427 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -16,6 +16,10 @@ 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_TERMCHAR_H
+#define EMACS_TERMCHAR_H
+
+#include <stdio.h>
 #include "dispextern.h"
 
 /* Each termcap frame points to its own struct tty_output object in
@@ -230,3 +234,5 @@ extern struct tty_display_info *tty_list;
    : (emacs_abort (), (struct tty_display_info *) 0))
 
 #define CURTTY() FRAME_TTY (SELECTED_FRAME())
+
+#endif /* EMACS_TERMCHAR_H */
diff --git a/src/termhooks.h b/src/termhooks.h
index c0bab83..2fafcec 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -23,8 +23,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 /* Miscellanea.   */
 
+#include "lisp.h"
 #include "systime.h" /* for Time */
 
+struct glyph;
+
 INLINE_HEADER_BEGIN
 
 enum scroll_bar_part {
diff --git a/src/terminal.c b/src/terminal.c
index 80c6aa2..27594e5 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -21,11 +21,10 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 
 #include "lisp.h"
+#include "character.h"
 #include "frame.h"
 #include "termchar.h"
 #include "termhooks.h"
-#include "charset.h"
-#include "coding.h"
 #include "keyboard.h"
 
 #if HAVE_STRUCT_UNIPAIR_UNICODE
diff --git a/src/termopts.h b/src/termopts.h
index c54d392..c5cd563 100644
--- a/src/termopts.h
+++ b/src/termopts.h
@@ -17,9 +17,13 @@ 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_TERMOPTS_H
+#define EMACS_TERMOPTS_H
 
 /* Nonzero means use interrupt-driven input.  */
 extern bool interrupt_input;
 
 /* Nonzero while interrupts are temporarily deferred during redisplay.  */
 extern bool interrupts_deferred;
+
+#endif /* EMACS_TERMOPTS_H */
diff --git a/src/textprop.c b/src/textprop.c
index 6758d4d..1995ff6 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -21,7 +21,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "intervals.h"
-#include "character.h"
 #include "buffer.h"
 #include "window.h"
 
diff --git a/src/tparam.h b/src/tparam.h
index 59fc859..b391e89 100644
--- a/src/tparam.h
+++ b/src/tparam.h
@@ -17,6 +17,8 @@ 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_TPARAM_H
+#define EMACS_TPARAM_H
 
 /* Don't try to include termcap.h.  On some systems, configure finds a
    non-standard termcap.h that the main build won't find.  */
@@ -33,3 +35,5 @@ char *tparam (const char *, char *, int, int, int, int, int);
 extern char PC;
 extern char *BC;
 extern char *UP;
+
+#endif /* EMACS_TPARAM_H */
diff --git a/src/undo.c b/src/undo.c
index 750bc8a..e0924b2 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -21,10 +21,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include "lisp.h"
-#include "character.h"
 #include "buffer.h"
-#include "commands.h"
-#include "window.h"
 
 /* Last buffer for which undo information was recorded.  */
 /* BEWARE: This is not traced by the GC, so never dereference it!  */
diff --git a/src/unexcw.c b/src/unexcw.c
index be88578..9583598 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -21,7 +21,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <config.h>
 #include "unexec.h"
 #include "lisp.h"
-
+#include <string.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <a.out.h>
diff --git a/src/unexec.h b/src/unexec.h
index 343eb6d8..cdb2e80 100644
--- a/src/unexec.h
+++ b/src/unexec.h
@@ -1 +1,4 @@
+#ifndef EMACS_UNEXEC_H
+#define EMACS_UNEXEC_H
 void unexec (const char *, const char *);
+#endif /* EMACS_UNEXEC_H */
diff --git a/src/unexsol.c b/src/unexsol.c
index cfd515f..0f84099 100644
--- a/src/unexsol.c
+++ b/src/unexsol.c
@@ -6,9 +6,7 @@
 #include <dlfcn.h>
 
 #include "lisp.h"
-#include "character.h"
 #include "buffer.h"
-#include "charset.h"
 #include "coding.h"
 
 void
diff --git a/src/w32.c b/src/w32.c
index bb51496..15cfd92 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -67,7 +67,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #undef localtime
 
 #include "lisp.h"
-#include "epaths.h"    /* for SHELL */
+#include "epaths.h"    /* for PATH_EXEC */
 
 #include <pwd.h>
 #include <grp.h>
@@ -224,20 +224,22 @@ typedef struct _REPARSE_DATA_BUFFER {
 
 #include <iphlpapi.h>  /* should be after winsock2.h */
 
+#include <c-strcase.h>
+
 #include "w32.h"
 #include <dirent.h>
 #include "w32common.h"
-#include "w32heap.h"
 #include "w32select.h"
-#include "systime.h"
+#include "systime.h"           /* for current_timespec, struct timespec */
 #include "dispextern.h"                /* for xstrcasecmp */
 #include "coding.h"            /* for Vlocale_coding_system */
 
 #include "careadlinkat.h"
 #include "allocator.h"
 
-/* For serial_configure and serial_open.  */
+/* For Lisp_Process, serial_configure and serial_open.  */
 #include "process.h"
+#include "systty.h"
 
 typedef HRESULT (WINAPI * ShGetFolderPath_fn)
   (IN HWND, IN int, IN HANDLE, IN DWORD, OUT char *);
diff --git a/src/w32console.c b/src/w32console.c
index a38a558..ec54f83 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -28,22 +28,13 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <windows.h>
 
 #include "lisp.h"
-#include "character.h"
 #include "coding.h"
-#include "disptab.h"
-#include "frame.h"
-#include "window.h"
-#include "termhooks.h"
-#include "termchar.h"
-#include "dispextern.h"
+#include "termchar.h"  /* for FRAME_TTY */
 #include "menu.h"      /* for tty_menu_show */
 #include "w32term.h"
 #include "w32common.h" /* for os_subtype */
 #include "w32inevt.h"
 
-/* from window.c */
-extern Lisp_Object Frecenter (Lisp_Object);
-
 static void w32con_move_cursor (struct frame *f, int row, int col);
 static void w32con_clear_to_end (struct frame *f);
 static void w32con_clear_frame (struct frame *f);
@@ -297,7 +288,7 @@ w32con_write_glyphs (struct frame *f, register struct glyph 
*string,
 {
   DWORD r;
   WORD char_attr;
-  unsigned char *conversion_buffer;
+  LPCSTR conversion_buffer;
   struct coding_system *coding;
 
   if (len <= 0)
@@ -328,7 +319,7 @@ w32con_write_glyphs (struct frame *f, register struct glyph 
*string,
       if (n == len)
        /* This is the last run.  */
        coding->mode |= CODING_MODE_LAST_BLOCK;
-      conversion_buffer = encode_terminal_code (string, n, coding);
+      conversion_buffer = (LPCSTR) encode_terminal_code (string, n, coding);
       if (coding->produced > 0)
        {
          /* Set the attribute for these characters.  */
@@ -365,7 +356,7 @@ w32con_write_glyphs_with_face (struct frame *f, register 
int x, register int y,
                               register struct glyph *string, register int len,
                               register int face_id)
 {
-  unsigned char *conversion_buffer;
+  LPCSTR conversion_buffer;
   struct coding_system *coding;
 
   if (len <= 0)
@@ -380,7 +371,7 @@ w32con_write_glyphs_with_face (struct frame *f, register 
int x, register int y,
      they all have the same face.  So this _is_ the last block.  */
   coding->mode |= CODING_MODE_LAST_BLOCK;
 
-  conversion_buffer = encode_terminal_code (string, len, coding);
+  conversion_buffer = (LPCSTR) encode_terminal_code (string, len, coding);
   if (coding->produced > 0)
     {
       DWORD filled, written;
diff --git a/src/w32fns.c b/src/w32fns.c
index 99fd3ba..d92352a 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -35,24 +35,14 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "w32term.h"
 #include "frame.h"
 #include "window.h"
-#include "character.h"
 #include "buffer.h"
-#include "intervals.h"
-#include "dispextern.h"
 #include "keyboard.h"
 #include "blockinput.h"
-#include "epaths.h"
-#include "charset.h"
 #include "coding.h"
-#include "ccl.h"
-#include "fontset.h"
-#include "systime.h"
-#include "termhooks.h"
 
 #include "w32common.h"
 
 #ifdef WINDOWSNT
-#include "w32heap.h"
 #include <mbstring.h>
 #endif /* WINDOWSNT */
 
@@ -62,8 +52,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "w32.h"
 #endif
 
-#include "bitmaps/gray.xbm"
-
 #include <commctrl.h>
 #include <commdlg.h>
 #include <shellapi.h>
@@ -75,9 +63,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <imm.h>
 #include <windowsx.h>
 
-#include "font.h"
-#include "w32font.h"
-
 #ifndef FOF_NO_CONNECTED_ELEMENTS
 #define FOF_NO_CONNECTED_ELEMENTS 0x2000
 #endif
@@ -759,7 +744,7 @@ w32_color_map_lookup (const char *colorname)
 
       tem = XCAR (elt);
 
-      if (lstrcmpi (SDATA (tem), colorname) == 0)
+      if (lstrcmpi (SSDATA (tem), colorname) == 0)
        {
          ret = Fcdr (elt);
          break;
@@ -802,7 +787,7 @@ add_system_logical_colors_to_map (Lisp_Object 
*system_colors)
       strcpy (full_name_buffer, SYSTEM_COLOR_PREFIX);
 
       while (RegEnumValueA (colors_key, index, name_buffer, &name_size,
-                           NULL, NULL, color_buffer, &color_size)
+                           NULL, NULL, (LPBYTE)color_buffer, &color_size)
             == ERROR_SUCCESS)
        {
          int r, g, b;
@@ -1227,9 +1212,9 @@ x_decode_color (struct frame *f, Lisp_Object arg, int def)
 
   CHECK_STRING (arg);
 
-  if (strcmp (SDATA (arg), "black") == 0)
+  if (strcmp (SSDATA (arg), "black") == 0)
     return BLACK_PIX_DEFAULT (f);
-  else if (strcmp (SDATA (arg), "white") == 0)
+  else if (strcmp (SSDATA (arg), "white") == 0)
     return WHITE_PIX_DEFAULT (f);
 
   if ((FRAME_DISPLAY_INFO (f)->n_planes * FRAME_DISPLAY_INFO (f)->n_cbits) == 
1)
@@ -1237,7 +1222,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, SDATA (arg), &cdef, true))
+  if (w32_defined_color (f, SSDATA (arg), &cdef, true))
     return cdef.pixel;
 
   /* defined_color failed; return an ultimate default.  */
@@ -1299,8 +1284,10 @@ 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)
 {
+#if 0
   Cursor cursor, nontext_cursor, mode_cursor, hand_cursor;
   int count;
+#endif
   int mask_color;
 
   if (!EQ (Qnil, arg))
@@ -1733,11 +1720,9 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object 
value, Lisp_Object oldval)
 void
 x_change_tool_bar_height (struct frame *f, int height)
 {
-  Lisp_Object frame;
   int unit = FRAME_LINE_HEIGHT (f);
   int old_height = FRAME_TOOL_BAR_HEIGHT (f);
   int lines = (height + unit - 1) / unit;
-  int old_text_height = FRAME_TEXT_HEIGHT (f);
   Lisp_Object fullscreen;
 
   /* Make sure we redisplay all windows in this frame.  */
@@ -1761,14 +1746,24 @@ x_change_tool_bar_height (struct frame *f, int height)
 
   /* Recalculate toolbar height.  */
   f->n_tool_bar_rows = 0;
+  if (old_height == 0
+      && (!f->after_make_frame
+         || NILP (frame_inhibit_implied_resize)
+         || (CONSP (frame_inhibit_implied_resize)
+             && NILP (Fmemq (Qtool_bar_lines, frame_inhibit_implied_resize)))))
+    f->tool_bar_redisplayed = f->tool_bar_resized = false;
 
   adjust_frame_size (f, -1, -1,
-                    ((NILP (fullscreen = get_frame_param (f, Qfullscreen))
-                      || EQ (fullscreen, Qfullwidth)) ? 1
+                    ((!f->tool_bar_resized
+                      && (NILP (fullscreen =
+                                get_frame_param (f, Qfullscreen))
+                          || EQ (fullscreen, Qfullwidth))) ? 1
                      : (old_height == 0 || height == 0) ? 2
                      : 4),
                     false, Qtool_bar_lines);
 
+  f->tool_bar_resized = f->tool_bar_redisplayed;
+
   /* adjust_frame_size might not have done anything, garbage frame
      here.  */
   adjust_frame_glyphs (f);
@@ -1856,7 +1851,7 @@ x_set_name (struct frame *f, Lisp_Object name, bool 
explicit)
       /* Check for no change needed in this very common case
         before we do any consing.  */
       if (!strcmp (FRAME_DISPLAY_INFO (f)->w32_id_name,
-                  SDATA (f->name)))
+                  SSDATA (f->name)))
        return;
       name = build_string (FRAME_DISPLAY_INFO (f)->w32_id_name);
     }
@@ -2917,7 +2912,7 @@ get_wm_chars (HWND aWnd, int *buf, int buflen, int 
ignore_ctrl, int ctrl,
          /* Non-character payload in a WM_CHAR
             (Ctrl-something pressed, see above).  Ignore, and report.  */
          if (ctrl_cnt)
-           *ctrl_cnt++;
+           (*ctrl_cnt)++;
          continue;
        }
       /* Traditionally, Emacs would ignore the character payload of VK_NUMPAD*
@@ -2945,7 +2940,7 @@ get_wm_chars (HWND aWnd, int *buf, int buflen, int 
ignore_ctrl, int ctrl,
 #ifdef DBG_WM_CHARS
 #  define FPRINTF_WM_CHARS(ARG)        fprintf ARG
 #else
-#  define FPRINTF_WM_CHARS(ARG)        0
+#  define FPRINTF_WM_CHARS(ARG)        (void)0
 #endif
 
 /* This is a heuristic only.  This is supposed to track the state of the
@@ -3004,7 +2999,7 @@ deliver_wm_chars (int do_translate, HWND hwnd, UINT msg, 
UINT wParam,
     {
       W32Msg wmsg;
       DWORD console_modifiers = construct_console_modifiers ();
-      int *b = buf, strip_Alt = 1, strip_ExtraMods = 1, hairy = 0;
+      int *b = buf, strip_ExtraMods = 1, hairy = 0;
       char *type_CtrlAlt = NULL;
 
       /*  XXXX In fact, there may be another case when we need to do the same:
@@ -3132,25 +3127,25 @@ deliver_wm_chars (int do_translate, HWND hwnd, UINT 
msg, UINT wParam,
              && console_modifiers & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
            {
              type_CtrlAlt = "bB";   /* generic bindable Ctrl-Alt- modifiers */
-             if (console_modifiers & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
+             if ((console_modifiers & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
                  == (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
                 /* double-Ctrl:
                    e.g. AltGr-rCtrl on some layouts (in this order!) */
                type_CtrlAlt = "dD";
-             else if (console_modifiers
-                      & (LEFT_CTRL_PRESSED | LEFT_ALT_PRESSED)
+             else if ((console_modifiers
+                       & (LEFT_CTRL_PRESSED | LEFT_ALT_PRESSED))
                       == (LEFT_CTRL_PRESSED | LEFT_ALT_PRESSED))
                type_CtrlAlt = "lL"; /* Ctrl-Alt- modifiers on the left */
              else if (!NILP (Vw32_recognize_altgr)
-                      && (console_modifiers
-                          & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED))
+                      && ((console_modifiers
+                           & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)))
                          == (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED))
                type_CtrlAlt = "gG"; /* modifiers as in AltGr */
            }
          else if (wmsg.dwModifiers & (alt_modifier | meta_modifier)
-                  || (console_modifiers
-                      & (LEFT_WIN_PRESSED | RIGHT_WIN_PRESSED
-                         | APPS_PRESSED | SCROLLLOCK_ON)))
+                  || ((console_modifiers
+                       & (LEFT_WIN_PRESSED | RIGHT_WIN_PRESSED
+                          | APPS_PRESSED | SCROLLLOCK_ON))))
            {
              /* Pure Alt (or combination of Alt, Win, APPS, scrolllock.  */
              type_CtrlAlt = "aA";
@@ -4367,97 +4362,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
     case WM_WINDOWPOSCHANGING:
       /* Don't restrict the sizing of any kind of frames.  If the window
         manager doesn't, there's no reason to do it ourselves.  */
-#if 0
-       if (frame_resize_pixelwise || hwnd == tip_window)
-#endif
-         return 0;
-
-#if 0
-      /* Don't restrict the sizing of fullscreened frames, allowing them to be
-        flush with the sides of the screen.  */
-      f = x_window_to_frame (dpyinfo, hwnd);
-      if (f && FRAME_PREV_FSMODE (f) != FULLSCREEN_NONE)
-       return 0;
-
-      {
-       WINDOWPLACEMENT wp;
-       LPWINDOWPOS lppos = (WINDOWPOS *) lParam;
-
-       wp.length = sizeof (WINDOWPLACEMENT);
-       GetWindowPlacement (hwnd, &wp);
-
-       if (wp.showCmd != SW_SHOWMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED
-           && (lppos->flags & SWP_NOSIZE) == 0)
-         {
-           RECT rect;
-           int wdiff;
-           int hdiff;
-           DWORD font_width;
-           DWORD line_height;
-           DWORD internal_border;
-           DWORD vscrollbar_extra;
-           DWORD hscrollbar_extra;
-           RECT wr;
-
-           wp.length = sizeof (wp);
-           GetWindowRect (hwnd, &wr);
-
-           enter_crit ();
-
-           font_width = GetWindowLong (hwnd, WND_FONTWIDTH_INDEX);
-           line_height = GetWindowLong (hwnd, WND_LINEHEIGHT_INDEX);
-           internal_border = GetWindowLong (hwnd, WND_BORDER_INDEX);
-           vscrollbar_extra = GetWindowLong (hwnd, WND_VSCROLLBAR_INDEX);
-           hscrollbar_extra = GetWindowLong (hwnd, WND_HSCROLLBAR_INDEX);
-
-           leave_crit ();
-
-           memset (&rect, 0, sizeof (rect));
-           AdjustWindowRect (&rect, GetWindowLong (hwnd, GWL_STYLE),
-                             GetMenu (hwnd) != NULL);
-
-           /* Force width and height of client area to be exact
-              multiples of the character cell dimensions.  */
-           wdiff = (lppos->cx - (rect.right - rect.left)
-                    - 2 * internal_border - vscrollbar_extra)
-             % font_width;
-           hdiff = (lppos->cy - (rect.bottom - rect.top)
-                    - 2 * internal_border - hscrollbar_extra)
-             % line_height;
-
-           if (wdiff || hdiff)
-             {
-               /* For right/bottom sizing we can just fix the sizes.
-                  However for top/left sizing we will need to fix the X
-                  and Y positions as well.  */
-
-               int cx_mintrack = GetSystemMetrics (SM_CXMINTRACK);
-               int cy_mintrack = GetSystemMetrics (SM_CYMINTRACK);
-
-               lppos->cx = max (lppos->cx - wdiff, cx_mintrack);
-               lppos->cy = max (lppos->cy - hdiff, cy_mintrack);
-
-               if (wp.showCmd != SW_SHOWMAXIMIZED
-                   && (lppos->flags & SWP_NOMOVE) == 0)
-                 {
-                   if (lppos->x != wr.left || lppos->y != wr.top)
-                     {
-                       lppos->x += wdiff;
-                       lppos->y += hdiff;
-                     }
-                   else
-                     {
-                       lppos->flags |= SWP_NOMOVE;
-                     }
-                 }
-
-               return 0;
-             }
-         }
-      }
-
-      goto dflt;
-#endif
+      return 0;
 
     case WM_GETMINMAXINFO:
       /* Hack to allow resizing the Emacs frame above the screen size.
@@ -4908,12 +4813,6 @@ do_unwind_create_frame (Lisp_Object frame)
 }
 
 static void
-unwind_create_frame_1 (Lisp_Object val)
-{
-  inhibit_lisp_code = val;
-}
-
-static void
 x_default_font_parameter (struct frame *f, Lisp_Object parms)
 {
   struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
@@ -4976,6 +4875,7 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   struct w32_display_info *dpyinfo = NULL;
   Lisp_Object parent;
   struct kboard *kb;
+  int x_width = 0, x_height = 0;
 
   if (!FRAME_W32_P (SELECTED_FRAME ())
       && !FRAME_INITIAL_P (SELECTED_FRAME ()))
@@ -5198,7 +5098,7 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
 
   f->output_data.w32->current_cursor = f->output_data.w32->nontext_cursor;
 
-  window_prompting = x_figure_window_size (f, parameters, true);
+  window_prompting = x_figure_window_size (f, parameters, true, &x_width, 
&x_height);
 
   tem = x_get_arg (dpyinfo, parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || EQ (tem, Qt);
@@ -5232,8 +5132,10 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   /* Allow x_set_window_size, now.  */
   f->can_x_set_window_size = true;
 
-  adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, true,
-                    Qx_create_frame_2);
+  if (x_width > 0)
+    SET_FRAME_WIDTH (f, x_width);
+  if (x_height > 0)
+    SET_FRAME_HEIGHT (f, x_height);
 
   /* Tell the server what size and position, etc, we want, and how
      badly we want them.  This should be done after we have the menu
@@ -5242,6 +5144,9 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   x_wm_set_size_hint (f, window_prompting, false);
   unblock_input ();
 
+  adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, true,
+                    Qx_create_frame_2);
+
   /* 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.  */
@@ -5313,7 +5218,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, SDATA (color), &foo, false))
+  if (w32_defined_color (f, SSDATA (color), &foo, false))
     return Qt;
   else
     return Qnil;
@@ -5328,7 +5233,7 @@ DEFUN ("xw-color-values", Fxw_color_values, 
Sxw_color_values, 1, 2, 0,
 
   CHECK_STRING (color);
 
-  if (w32_defined_color (f, SDATA (color), &foo, false))
+  if (w32_defined_color (f, SSDATA (color), &foo, false))
     return list3i ((GetRValue (foo.pixel) << 8) | GetRValue (foo.pixel),
                   (GetGValue (foo.pixel) << 8) | GetGValue (foo.pixel),
                   (GetBValue (foo.pixel) << 8) | GetBValue (foo.pixel));
@@ -5833,8 +5738,7 @@ x_display_info_for_name (Lisp_Object name)
 
   validate_x_resource_name ();
 
-  dpyinfo = w32_term_init (name, (unsigned char *)0,
-                          SSDATA (Vx_resource_name));
+  dpyinfo = w32_term_init (name, NULL, SSDATA (Vx_resource_name));
 
   if (dpyinfo == 0)
     error ("Cannot connect to server %s", SDATA (name));
@@ -5853,7 +5757,7 @@ terminate Emacs if we can't open the connection.
 (In the Nextstep version, the last two arguments are currently ignored.)  */)
   (Lisp_Object display, Lisp_Object xrm_string, Lisp_Object must_succeed)
 {
-  unsigned char *xrm_option;
+  char *xrm_option;
   struct w32_display_info *dpyinfo;
 
   CHECK_STRING (display);
@@ -5895,9 +5799,9 @@ terminate Emacs if we can't open the connection.
   add_system_logical_colors_to_map (&Vw32_color_map);
 
   if (! NILP (xrm_string))
-    xrm_option = SDATA (xrm_string);
+    xrm_option = SSDATA (xrm_string);
   else
-    xrm_option = (unsigned char *) 0;
+    xrm_option = NULL;
 
   /* Use this general default value to start with.  */
   /* First remove .exe suffix from invocation-name - it looks ugly. */
@@ -5915,8 +5819,7 @@ terminate Emacs if we can't open the connection.
 
   /* This is what opens the connection and sets x_current_display.
      This also initializes many symbols, such as those used for input.  */
-  dpyinfo = w32_term_init (display, xrm_option,
-                          SSDATA (Vx_resource_name));
+  dpyinfo = w32_term_init (display, xrm_option, SSDATA (Vx_resource_name));
 
   if (dpyinfo == 0)
     {
@@ -6171,13 +6074,13 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
   struct frame *f;
   Lisp_Object frame;
   Lisp_Object name;
-  long window_prompting = 0;
   int width, height;
   ptrdiff_t count = SPECPDL_INDEX ();
   struct kboard *kb;
   bool face_change_before = face_change;
   Lisp_Object buffer;
   struct buffer *old_buffer;
+  int x_width = 0, x_height = 0;
 
   /* Use this general default value to start with until we know if
      this frame has a specified name.  */
@@ -6308,7 +6211,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
   f->output_data.w32->dwStyle = WS_BORDER | WS_POPUP | WS_DISABLED;
   f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
 
-  window_prompting = x_figure_window_size (f, parms, false);
+  x_figure_window_size (f, parms, true, &x_width, &x_height);
 
   /* No fringes on tip frame.  */
   f->fringe_cols = 0;
@@ -7070,9 +6973,9 @@ value of DIR as in previous invocations; this is standard 
Windows behavior.  */)
 
     /* We modify these in-place, so make copies for safety.  */
     dir = Fcopy_sequence (dir);
-    unixtodos_filename (SDATA (dir));
+    unixtodos_filename (SSDATA (dir));
     filename = Fcopy_sequence (filename);
-    unixtodos_filename (SDATA (filename));
+    unixtodos_filename (SSDATA (filename));
     if (SBYTES (filename) >= MAX_UTF8_PATH)
       report_file_error ("filename too long", default_filename);
     if (w32_unicode_filenames)
@@ -7295,7 +7198,7 @@ DEFUN ("system-move-file-to-trash", 
Fsystem_move_file_to_trash,
 
       encoded_file = ENCODE_FILE (filename);
 
-      path = map_w32_filename (SDATA (encoded_file), NULL);
+      path = map_w32_filename (SSDATA (encoded_file), NULL);
 
       /* The Unicode version of SHFileOperation is not supported on
         Windows 9X. */
@@ -7334,7 +7237,8 @@ DEFUN ("system-move-file-to-trash", 
Fsystem_move_file_to_trash,
          /* If a file cannot be represented in ANSI codepage, don't
             let them inadvertently delete other files because some
             characters are interpreted as a wildcards.  */
-         if (_mbspbrk (tmp_path_a, "?*"))
+         if (_mbspbrk ((unsigned char *)tmp_path_a,
+                       (const unsigned char *)"?*"))
            result = ERROR_FILE_NOT_FOUND;
          else
            {
@@ -7651,7 +7555,7 @@ a ShowWindow flag:
     }
   else
     {
-      char document_a[MAX_PATH], current_dir_a[MAX_PATH];
+      char current_dir_a[MAX_PATH];
       SHELLEXECUTEINFOA shexinfo_a;
       int codepage = codepage_for_filenames (NULL);
       int ldoc_a = pWideCharToMultiByte (codepage, 0, doc_w, -1, NULL, 0,
@@ -7752,7 +7656,7 @@ w32_parse_hot_key (Lisp_Object key)
       c = Fcar (c);
       if (!SYMBOLP (c))
        emacs_abort ();
-      vk_code = lookup_vk_code (SDATA (SYMBOL_NAME (c)));
+      vk_code = lookup_vk_code (SSDATA (SYMBOL_NAME (c)));
     }
   else if (INTEGERP (c))
     {
@@ -8010,7 +7914,6 @@ and width values are in pixels.
   int single_menu_bar_height, wrapped_menu_bar_height, menu_bar_height;
   int tool_bar_height = FRAME_TOOL_BAR_HEIGHT (f);
   int internal_border_width = FRAME_INTERNAL_BORDER_WIDTH (f);
-  bool fullboth = EQ (get_frame_param (f, Qfullscreen), Qfullboth);
 
   if (FRAME_INITIAL_P (f) || !FRAME_W32_P (f))
     return Qnil;
@@ -8356,7 +8259,7 @@ If the underlying system call fails, value is nil.  */)
     char rootname[MAX_UTF8_PATH];
     wchar_t rootname_w[MAX_PATH];
     char rootname_a[MAX_PATH];
-    char *name = SDATA (encoded);
+    char *name = SSDATA (encoded);
     BOOL result;
 
     /* find the root name of the volume if given */
@@ -8810,7 +8713,7 @@ w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId)
 
          event->uChar.UnicodeChar = buf[isdead - 1];
          isdead = WideCharToMultiByte (cpId, 0, buf, isdead,
-                                       ansi_code, 4, NULL, NULL);
+                                       (LPSTR)ansi_code, 4, NULL, NULL);
        }
       else
        isdead = 0;
diff --git a/src/w32font.c b/src/w32font.c
index 1c2f966..2b6f610 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -26,12 +26,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "w32term.h"
 #include "frame.h"
-#include "dispextern.h"
-#include "character.h"
-#include "charset.h"
-#include "coding.h"
-#include "fontset.h"
-#include "font.h"
+#include "coding.h"    /* for ENCODE_SYSTEM, DECODE_SYSTEM */
 #include "w32font.h"
 #ifdef WINDOWSNT
 #include "w32.h"
@@ -244,7 +239,7 @@ intern_font_name (char * string)
   Lisp_Object str = DECODE_SYSTEM (build_string (string));
   ptrdiff_t len = SCHARS (str);
   Lisp_Object obarray = check_obarray (Vobarray);
-  Lisp_Object tem = oblookup (obarray, SDATA (str), len, len);
+  Lisp_Object tem = oblookup (obarray, SSDATA (str), len, len);
   /* This code is similar to intern function from lread.c.  */
   return SYMBOLP (tem) ? tem : intern_driver (str, obarray, tem);
 }
@@ -1478,12 +1473,12 @@ add_font_entity_to_list (ENUMLOGFONTEX *logical_font,
      by a foundry, we accept raster fonts if the font name is found
      anywhere within the full name.  */
   if ((logical_font->elfLogFont.lfOutPrecision == OUT_STRING_PRECIS
-       && !strstr (logical_font->elfFullName,
+       && !strstr ((char *)logical_font->elfFullName,
                   logical_font->elfLogFont.lfFaceName))
       /* Check for well known substitutions that mess things up in the
         presence of Type-1 fonts of the same name.  */
       || (!check_face_name (&logical_font->elfLogFont,
-                           logical_font->elfFullName)))
+                           (char *)logical_font->elfFullName)))
     return 1;
 
   /* Make a font entity for the font.  */
@@ -1660,7 +1655,7 @@ registry_to_w32_charset (Lisp_Object charset)
   else if (EQ (charset, Qiso8859_1))
     return ANSI_CHARSET;
   else if (SYMBOLP (charset))
-    return x_to_w32_charset (SDATA (SYMBOL_NAME (charset)));
+    return x_to_w32_charset (SSDATA (SYMBOL_NAME (charset)));
   else
     return DEFAULT_CHARSET;
 }
@@ -1782,7 +1777,7 @@ w32_to_x_charset (int fncharset, char *matching)
             || !SYMBOLP (XCAR (XCDR (this_entry))))
           continue;
 
-        x_charset = SDATA (XCAR (this_entry));
+        x_charset = SSDATA (XCAR (this_entry));
         w32_charset = XCAR (XCDR (this_entry));
         codepage = XCDR (XCDR (this_entry));
 
@@ -1987,7 +1982,7 @@ fill_in_logfont (struct frame *f, LOGFONT *logfont, 
Lisp_Object font_spec)
       else if (SYMBOLP (tmp))
        {
          strncpy (logfont->lfFaceName,
-                  SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE);
+                  SSDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE);
          logfont->lfFaceName[LF_FACESIZE-1] = '\0';
        }
     }
@@ -2083,7 +2078,7 @@ list_all_matching_fonts (struct font_callback_data 
*match_data)
       if (NILP (family))
         continue;
       else if (SYMBOLP (family))
-        name = SDATA (ENCODE_SYSTEM (SYMBOL_NAME (family)));
+        name = SSDATA (ENCODE_SYSTEM (SYMBOL_NAME (family)));
       else
        continue;
 
diff --git a/src/w32heap.c b/src/w32heap.c
index 60afd1d..a74e7ad 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -52,7 +52,7 @@
 #include <sys/mman.h>
 #include "w32common.h"
 #include "w32heap.h"
-#include "lisp.h"  /* for VALMASK */
+#include "lisp.h"
 
 /* We chose to leave those declarations here.  They are used only in
    this file.  The RtlCreateHeap is available since XP.  It is located
diff --git a/src/w32inevt.c b/src/w32inevt.c
index ea2db26..db2e218 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -37,12 +37,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "keyboard.h"
 #include "frame.h"
-#include "dispextern.h"
-#include "window.h"
 #include "blockinput.h"
-#include "termhooks.h"
-#include "termchar.h"
-#include "w32heap.h"
+#include "termchar.h"  /* for Mouse_HLInfo, tty_display_info */
 #include "w32term.h"
 #include "w32inevt.h"
 
diff --git a/src/w32menu.c b/src/w32menu.c
index 40b8f5f..6af69f4 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -25,15 +25,10 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "keyboard.h"
-#include "keymap.h"
 #include "frame.h"
-#include "termhooks.h"
-#include "window.h"
 #include "blockinput.h"
-#include "character.h"
 #include "buffer.h"
-#include "charset.h"
-#include "coding.h"
+#include "coding.h"    /* for ENCODE_SYSTEM */
 #include "menu.h"
 
 /* This may include sys/types.h, and that somehow loses
@@ -54,8 +49,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <sys/types.h>
 #endif
 
-#include "dispextern.h"
-
 #include "w32common.h" /* for osinfo_cache */
 
 #undef HAVE_DIALOGS /* TODO: Implement native dialogs.  */
@@ -1104,14 +1097,14 @@ simple_dialog_show (struct frame *f, Lisp_Object 
contents, Lisp_Object header)
 
       if (STRINGP (temp))
        {
-         char *utf8_text = SDATA (ENCODE_UTF_8 (temp));
+         char *utf8_text = SSDATA (ENCODE_UTF_8 (temp));
          /* Be pessimistic about the number of characters needed.
             Remember characters outside the BMP will take more than
             one utf16 word, so we cannot simply use the character
             length of temp.  */
          int utf8_len = strlen (utf8_text);
          text = SAFE_ALLOCA ((utf8_len + 1) * sizeof (WCHAR));
-         utf8to16 (utf8_text, utf8_len, text);
+         utf8to16 ((unsigned char *)utf8_text, utf8_len, text);
        }
       else
        {
@@ -1140,7 +1133,7 @@ simple_dialog_show (struct frame *f, Lisp_Object 
contents, Lisp_Object header)
         encoding so questions representable by the system codepage
         are encoded properly.  */
       if (STRINGP (temp))
-       text = SDATA (ENCODE_SYSTEM (temp));
+       text = SSDATA (ENCODE_SYSTEM (temp));
       else
        text = "";
 
@@ -1353,7 +1346,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
       else
        utf16_string = SAFE_ALLOCA ((utf8_len + 1) * sizeof (WCHAR));
 
-      utf8to16 (out_string, utf8_len, utf16_string);
+      utf8to16 ((unsigned char *)out_string, utf8_len, utf16_string);
       return_value = unicode_append_menu (menu, fuFlags,
                                          item != NULL ? (UINT_PTR) item
                                            : (UINT_PTR) wv->call_data,
diff --git a/src/w32proc.c b/src/w32proc.c
index 62d6531..8a1e17e 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -29,6 +29,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <ctype.h>
 #include <io.h>
 #include <fcntl.h>
+#include <unistd.h>
 #include <signal.h>
 #include <sys/file.h>
 #include <mbstring.h>
@@ -59,12 +60,9 @@ extern BOOL WINAPI IsValidLocale (LCID, DWORD);
 #include "w32.h"
 #include "w32common.h"
 #include "w32heap.h"
-#include "systime.h"
-#include "syswait.h"
-#include "process.h"
+#include "syswait.h"   /* for WNOHANG */
 #include "syssignal.h"
 #include "w32term.h"
-#include "dispextern.h"                /* for xstrcasecmp */
 #include "coding.h"
 
 #define RVA_TO_PTR(var,section,filedata) \
@@ -1757,7 +1755,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char 
**envp)
          return -1;
        }
       program = ENCODE_FILE (full);
-      cmdname = SDATA (program);
+      cmdname = SSDATA (program);
     }
   else
     {
@@ -1779,7 +1777,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char 
**envp)
   /* We explicitly require that the command's file name be encodable
      in the current ANSI codepage, because we will be invoking it via
      the ANSI APIs.  */
-  if (_mbspbrk (cmdname_a, "?"))
+  if (_mbspbrk ((unsigned char *)cmdname_a, (const unsigned char *)"?"))
     {
       errno = ENOENT;
       return -1;
@@ -2179,7 +2177,7 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE 
*wfds, SELECT_TYPE *efds,
            cp = fd_info[i].cp;
            if (FD_ISSET (i, &owfds)
                && cp
-               && (fd_info[i].flags && FILE_CONNECT) == 0)
+               && (fd_info[i].flags & FILE_CONNECT) == 0)
              {
                DebPrint (("sys_select: fd %d is in wfds, but FILE_CONNECT is 
reset!\n", i));
                cp = NULL;
@@ -2881,7 +2879,7 @@ All path elements in FILENAME are converted to their 
short names.  */)
   filename = Fexpand_file_name (filename, Qnil);
 
   /* luckily, this returns the short version of each element in the path.  */
-  if (w32_get_short_filename (SDATA (ENCODE_FILE (filename)),
+  if (w32_get_short_filename (SSDATA (ENCODE_FILE (filename)),
                              shortname, MAX_PATH) == 0)
     return Qnil;
 
@@ -2911,7 +2909,7 @@ All path elements in FILENAME are converted to their long 
names.  */)
   /* first expand it.  */
   filename = Fexpand_file_name (filename, Qnil);
 
-  if (!w32_get_long_filename (SDATA (ENCODE_FILE (filename)), longname,
+  if (!w32_get_long_filename (SSDATA (ENCODE_FILE (filename)), longname,
                              MAX_UTF8_PATH))
     return Qnil;
 
@@ -3011,12 +3009,12 @@ such programs cannot be invoked by Emacs anyway.  */)
 
   program = Fexpand_file_name (program, Qnil);
   encoded_progname = ENCODE_FILE (program);
-  progname = SDATA (encoded_progname);
+  progname = SSDATA (encoded_progname);
   unixtodos_filename (progname);
   filename_to_ansi (progname, progname_a);
   /* Reject file names that cannot be encoded in the current ANSI
      codepage.  */
-  if (_mbspbrk (progname_a, "?"))
+  if (_mbspbrk ((unsigned char *)progname_a, (const unsigned char *)"?"))
     return Qunknown;
 
   if (w32_executable_type (progname_a, &is_dos_app, &is_cygwin_app,
diff --git a/src/w32reg.c b/src/w32reg.c
index 261cfcd..a4ce218 100644
--- a/src/w32reg.c
+++ b/src/w32reg.c
@@ -21,7 +21,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include "lisp.h"
-#include "w32term.h"
+#include "w32term.h"   /* for XrmDatabase, xrdb */
 #include "blockinput.h"
 
 #include <stdio.h>
@@ -73,7 +73,7 @@ w32_get_rdb_resource (char *rdb, const char *resource)
   return NULL;
 }
 
-static LPBYTE
+static char *
 w32_get_string_resource (const char *name, const char *class, DWORD dwexptype)
 {
   LPBYTE lpvalue = NULL;
@@ -134,7 +134,7 @@ 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 (lpvalue);
+  return (char *)lpvalue;
 }
 
 /* Retrieve the string resource specified by NAME with CLASS from
diff --git a/src/w32select.c b/src/w32select.c
index 3c554c6..3962ac6 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -76,11 +76,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "w32common.h" /* os_subtype */
 #include "w32term.h"   /* for all of the w32 includes */
-#include "keyboard.h"
+#include "keyboard.h"  /* for waiting_for_input */
 #include "blockinput.h"
-#include "charset.h"
 #include "coding.h"
-#include "composite.h"
 
 #ifdef CYGWIN
 #include <string.h>
@@ -513,7 +511,7 @@ setup_config (void)
   cfg_clipboard_type = CF_TEXT;
 
   /* Interpret the coding system symbol name */
-  coding_name = SDATA (SYMBOL_NAME (cfg_coding_system));
+  coding_name = SSDATA (SYMBOL_NAME (cfg_coding_system));
 
   /* "(.*-)?utf-16.*" -> CF_UNICODETEXT */
   cp = strstr (coding_name, "utf-16");
@@ -857,7 +855,7 @@ DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data,
       {
        int i;
 
-       nbytes = strlen (src);
+       nbytes = strlen ((char *)src);
 
        for (i = 0; i < nbytes; i++)
          {
diff --git a/src/w32term.c b/src/w32term.c
index 82b05bf..8317867 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -24,37 +24,27 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "blockinput.h"
 #include "w32term.h"
 
-#include "systty.h"
-#include "systime.h"
-
 #include <ctype.h>
 #include <errno.h>
 #include <sys/stat.h>
+#ifdef CYGWIN
+#include <fcntl.h>     /* for O_RDWR */
+#endif
 #include <imm.h>
 
-#include "charset.h"
-#include "character.h"
 #include "coding.h"
-#include "ccl.h"
 #include "frame.h"
-#include "dispextern.h"
 #include "fontset.h"
 #include "termhooks.h"
 #include "termopts.h"
 #include "termchar.h"
-#include "disptab.h"
 #include "buffer.h"
 #include "window.h"
 #include "keyboard.h"
-#include "intervals.h"
-#include "process.h"
-#include "atimer.h"
-#include "keymap.h"
-#include "menu.h"
+#include "menu.h"      /* for w32_menu_show */
 
 #ifdef WINDOWSNT
 #include "w32.h"       /* for filename_from_utf16, filename_from_ansi */
-#include "w32heap.h"
 #endif
 
 #ifndef WINDOWSNT
@@ -65,6 +55,10 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "font.h"
 #include "w32font.h"
+
+#if 0  /* TODO: stipple */
+#include "bitmaps/gray.xbm"
+#endif
 
 /* Fringe bitmaps.  */
 
@@ -1596,7 +1590,9 @@ w32_setup_relief_color (struct frame *f, struct relief 
*relief, double factor,
   unsigned long mask = GCForeground;
   COLORREF pixel;
   COLORREF background = di->relief_background;
+#if 0
   struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
+#endif
 
   /* TODO: Free colors (if using palette)? */
 
@@ -4350,8 +4346,6 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar 
*bar, W32Msg *msg,
        if (dragging)
          {
            SCROLLINFO si;
-           int start = bar->start;
-           int end = bar->end;
 
            si.cbSize = sizeof (si);
            si.fMask = SIF_POS;
@@ -4509,18 +4503,6 @@ x_scroll_bar_clear (struct frame *f)
       }
 }
 
-static void
-set_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
-{
-  register Lisp_Object old_alist_elt;
-
-  old_alist_elt = Fassq (prop, f->param_alist);
-  if (EQ (old_alist_elt, Qnil))
-    fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist));
-  else
-    Fsetcdr (old_alist_elt, val);
-}
-
 /* The main W32 event-reading loop - w32_read_socket.  */
 
 /* Record the last 100 characters stored
@@ -5159,7 +5141,7 @@ w32_read_socket (struct terminal *terminal,
          if (f && !FRAME_ICONIFIED_P (f) && msg.msg.wParam != SIZE_MINIMIZED)
            {
              RECT rect;
-             int rows, columns, width, height, text_width, text_height;
+             int /* rows, columns, */ width, height, text_width, text_height;
 
              if (GetClientRect (msg.msg.hwnd, &rect)
                  /* GetClientRect evidently returns (0, 0, 0, 0) if
@@ -6176,6 +6158,13 @@ x_set_window_size (struct frame *f, bool change_gravity,
 
   if (pixelwidth > 0 || pixelheight > 0)
     {
+      frame_size_history_add
+       (f, Qx_set_window_size_1, width, height,
+        list2 (Fcons (make_number (pixelwidth),
+                      make_number (pixelheight)),
+               Fcons (make_number (rect.right - rect.left),
+                      make_number (rect.bottom - rect.top))));
+
       my_set_window_pos (FRAME_W32_WINDOW (f), NULL,
                         0, 0,
                         rect.right - rect.left,
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index 8b3bf60..a8b5932 100644
--- a/src/w32uniscribe.c
+++ b/src/w32uniscribe.c
@@ -33,11 +33,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "w32term.h"
 #include "frame.h"
-#include "dispextern.h"
-#include "character.h"
-#include "charset.h"
 #include "composite.h"
-#include "fontset.h"
 #include "font.h"
 #include "w32font.h"
 
@@ -779,7 +775,6 @@ uniscribe_check_otf_1 (HDC context, Lisp_Object script, 
Lisp_Object lang,
   int max_tags = ARRAYELTS (tags);
   int ntags, i, ret = 0;
   HRESULT rslt;
-  Lisp_Object rest;
 
   *retval = 0;
 
diff --git a/src/w32xfns.c b/src/w32xfns.c
index 35e12fd..48da14d 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -20,16 +20,12 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <config.h>
 #include <signal.h>
 #include <stdio.h>
+#include <windows.h>
+#include <windowsx.h>
 
 #include "lisp.h"
-#include "keyboard.h"
 #include "frame.h"
-#include "window.h"
-#include "charset.h"
-#include "fontset.h"
-#include "blockinput.h"
 #include "w32term.h"
-#include "windowsx.h"
 
 #define myalloc(cb) GlobalAllocPtr (GPTR, cb)
 #define myfree(lp) GlobalFreePtr (lp)
diff --git a/src/widget.c b/src/widget.c
index 0986ba6..d0c3e60 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -29,17 +29,13 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
    */
 
 #include <config.h>
+#include "widget.h"
+
 #include <stdio.h>
 
 #include "lisp.h"
 #include "xterm.h"
-
-#include "keyboard.h"
 #include "frame.h"
-#include "window.h"
-
-#include "dispextern.h"
-#include "blockinput.h"
 
 #include <X11/StringDefs.h>
 #include <X11/IntrinsicP.h>
@@ -50,10 +46,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <X11/ShellP.h>
 #include "../lwlib/lwlib.h"
 
-#include "character.h"
-#include "font.h"
-
-
 static void EmacsFrameInitialize (Widget request, Widget new, ArgList dum1, 
Cardinal *dum2);
 static void EmacsFrameDestroy (Widget widget);
 static void EmacsFrameRealize (Widget widget, XtValueMask *mask, 
XSetWindowAttributes *attrs);
@@ -268,167 +260,26 @@ set_frame_size (EmacsFrame ew)
    */
 
   /* Hairily merged geometry */
-  int w = FRAME_COLS (ew->emacs_frame.frame);
-  int h = FRAME_LINES (ew->emacs_frame.frame);
-
+  struct frame *f = ew->emacs_frame.frame;
+  int w = FRAME_COLS (f);
+  int h = FRAME_LINES (f);
   Widget wmshell = get_wm_shell ((Widget) ew);
+  Dimension pixel_width, pixel_height;
   /* Each Emacs shell is now independent and top-level.  */
 
   if (! XtIsSubclass (wmshell, shellWidgetClass)) emacs_abort ();
 
-  /* We don't need this for the moment. The geometry is computed in
-     xfns.c.  */
-#if 0
-  /* If the EmacsFrame doesn't have a geometry but the shell does,
-     treat that as the geometry of the frame.  (Is this bogus?
-     I'm not sure.) */
-  if (ew->emacs_frame.geometry == 0)
-    XtVaGetValues (wmshell, XtNgeometry, &ew->emacs_frame.geometry, NULL);
-
-  /* If the Shell is iconic, then the EmacsFrame is iconic.  (Is
-     this bogus? I'm not sure.) */
-  if (!ew->emacs_frame.iconic)
-    XtVaGetValues (wmshell, XtNiconic, &ew->emacs_frame.iconic, NULL);
-
-
-  {
-    char *geom = 0;
-    XtVaGetValues (app_shell, XtNgeometry, &geom, NULL);
-    if (geom)
-      app_flags = XParseGeometry (geom, &app_x, &app_y, &app_w, &app_h);
-  }
-
-  if (ew->emacs_frame.geometry)
-    frame_flags = XParseGeometry (ew->emacs_frame.geometry,
-                                  &frame_x, &frame_y,
-                                  &frame_w, &frame_h);
-
-  if (first_frame_p)
-    {
-      /* If this is the first frame created:
-         ====================================
-
-         - Use the ApplicationShell's size/position, if specified.
-           (This is "Emacs.geometry", or the "-geometry" command line arg.)
-         - Else use the EmacsFrame's size/position.
-           (This is "*Frame-NAME.geometry")
-
-        - If the AppShell is iconic, the frame should be iconic.
-
-        AppShell comes first so that -geometry always applies to the first
-        frame created, even if there is an "every frame" entry in the
-        resource database.
-       */
-      if (app_flags & (XValue | YValue))
-       {
-         x = app_x; y = app_y;
-         flags |= (app_flags & (XValue | YValue | XNegative | YNegative));
-       }
-      else if (frame_flags & (XValue | YValue))
-       {
-         x = frame_x; y = frame_y;
-         flags |= (frame_flags & (XValue | YValue | XNegative | YNegative));
-       }
-
-      if (app_flags & (WidthValue | HeightValue))
-       {
-         w = app_w; h = app_h;
-         flags |= (app_flags & (WidthValue | HeightValue));
-       }
-      else if (frame_flags & (WidthValue | HeightValue))
-       {
-         w = frame_w; h = frame_h;
-         flags |= (frame_flags & (WidthValue | HeightValue));
-       }
-
-      /* If the AppShell is iconic, then the EmacsFrame is iconic. */
-      if (!ew->emacs_frame.iconic)
-       XtVaGetValues (app_shell, XtNiconic, &ew->emacs_frame.iconic, NULL);
+  char_to_pixel_size (ew, w, h, &pixel_width, &pixel_height);
+  ew->core.width = (frame_resize_pixelwise
+                   ? FRAME_PIXEL_WIDTH (f)
+                   : pixel_width);
+  ew->core.height = (frame_resize_pixelwise
+                    ? FRAME_PIXEL_HEIGHT (f)
+                    : pixel_height);
 
-      first_frame_p = False;
-    }
-  else
-    {
-      /* If this is not the first frame created:
-         ========================================
-
-         - use the EmacsFrame's size/position if specified
-         - Otherwise, use the ApplicationShell's size, but not position.
-
-         So that means that one can specify the position of the first frame
-         with "Emacs.geometry" or `-geometry'; but can only specify the
-        position of subsequent frames with "*Frame-NAME.geometry".
-
-        AppShell comes second so that -geometry does not apply to subsequent
-        frames when there is an "every frame" entry in the resource db,
-        but does apply to the first frame.
-       */
-      if (frame_flags & (XValue | YValue))
-       {
-         x = frame_x; y = frame_y;
-         flags |= (frame_flags & (XValue | YValue | XNegative | YNegative));
-       }
-
-      if (frame_flags & (WidthValue | HeightValue))
-       {
-         w = frame_w; h = frame_h;
-         flags |= (frame_flags & (WidthValue | HeightValue));
-       }
-      else if (app_flags & (WidthValue | HeightValue))
-       {
-         w = app_w;
-         h = app_h;
-         flags |= (app_flags & (WidthValue | HeightValue));
-       }
-    }
-#endif /* 0 */
-  {
-    Dimension pixel_width, pixel_height;
-
-    /* Take into account the size of the scrollbar.  Always use the
-       number of columns occupied by the scroll bar here otherwise we
-       might end up with a frame width that is not a multiple of the
-       frame's character width which is bad for vertically split
-       windows.  */
-
-#if 0 /* This can run Lisp code, and it is dangerous to give
-        out the frame to Lisp code before it officially exists.
-        This is handled in Fx_create_frame so not needed here.  */
-    change_frame_size (f, w, h, 1, 0, 0, 0);
-#endif
-    char_to_pixel_size (ew, w, h, &pixel_width, &pixel_height);
-    ew->core.width = pixel_width;
-    ew->core.height = pixel_height;
-
-#if 0 /* xfns.c takes care of this now.  */
-    /* If a position was specified, assign it to the shell widget.
-       (Else WM won't do anything with it.)
-     */
-    if (flags & (XValue | YValue))
-      {
-       /* the tricky things with the sign is to make sure that
-          -0 is printed -0. */
-       sprintf (shell_position, "=%c%d%c%d",
-                flags & XNegative ? '-' : '+', x < 0 ? -x : x,
-                flags & YNegative ? '-' : '+', y < 0 ? -y : y);
-       XtVaSetValues (wmshell, XtNgeometry, xstrdup (shell_position), NULL);
-      }
-    else if (flags & (WidthValue | HeightValue))
-      {
-       sprintf (shell_position, "=%dx%d", pixel_width, pixel_height);
-       XtVaSetValues (wmshell, XtNgeometry, xstrdup (shell_position), NULL);
-      }
-
-    /* If the geometry spec we're using has W/H components, mark the size
-       in the WM_SIZE_HINTS as user specified. */
-    if (flags & (WidthValue | HeightValue))
-      mark_shell_size_user_specified (wmshell);
-
-    /* Also assign the iconic status of the frame to the Shell, so that
-       the WM sees it. */
-    XtVaSetValues (wmshell, XtNiconic, ew->emacs_frame.iconic, NULL);
-#endif /* 0 */
-  }
+  frame_size_history_add
+    (f, Qset_frame_size, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
+     list2 (make_number (ew->core.width), make_number (ew->core.height)));
 }
 
 static void
@@ -486,16 +337,6 @@ update_various_frame_slots (EmacsFrame ew)
 {
   struct frame *f = ew->emacs_frame.frame;
 
-  /* Don't do that: It confuses the check in change_frame_size_1 whether
-     the pixel size of the frame changed due to a change of the internal
-     border width.  Bug#16736.  */
-  if (false)
-    {
-      struct x_output *x = f->output_data.x;
-      FRAME_PIXEL_HEIGHT (f) = ew->core.height + x->menubar_height;
-      FRAME_PIXEL_WIDTH (f) = ew->core.width;
-    }
-
   f->internal_border_width = ew->emacs_frame.internal_border_width;
 }
 
@@ -504,6 +345,7 @@ update_from_various_frame_slots (EmacsFrame ew)
 {
   struct frame *f = ew->emacs_frame.frame;
   struct x_output *x = f->output_data.x;
+
   ew->core.height = FRAME_PIXEL_HEIGHT (f) - x->menubar_height;
   ew->core.width = FRAME_PIXEL_WIDTH (f);
   ew->core.background_pixel = FRAME_BACKGROUND_PIXEL (f);
@@ -576,7 +418,10 @@ EmacsFrameResize (Widget widget)
 
   frame_size_history_add
     (f, QEmacsFrameResize, width, height,
-     list2 (make_number (ew->core.width), make_number (ew->core.height)));
+     list5 (make_number (ew->core.width), make_number (ew->core.height),
+           make_number (FRAME_TOP_MARGIN_HEIGHT (f)),
+           make_number (FRAME_SCROLL_BAR_AREA_HEIGHT (f)),
+           make_number (2 * FRAME_INTERNAL_BORDER_WIDTH (f))));
 
   change_frame_size (f, width, height, 0, 1, 0, 1);
 
@@ -596,11 +441,12 @@ EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry 
*request, XtWidgetGeome
 
   if (mask & (CWWidth | CWHeight))
     {
-      round_size_to_char (ew,
-                         (mask & CWWidth) ? request->width : ew->core.width,
-                         ((mask & CWHeight) ? request->height
-                          : ew->core.height),
-                         &ok_width, &ok_height);
+      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);
       if ((mask & CWWidth) && (ok_width != request->width))
        {
          result->request_mode |= CWWidth;
diff --git a/src/widget.h b/src/widget.h
index a782035..e2e19b0 100644
--- a/src/widget.h
+++ b/src/widget.h
@@ -21,6 +21,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifndef _EmacsFrame_h
 #define _EmacsFrame_h
 
+#include <X11/IntrinsicP.h>
+
 #define XtNminibuffer "minibuffer"
 #define XtCMinibuffer "Minibuffer"
 #define XtNunsplittable "unsplittable"
diff --git a/src/widgetprv.h b/src/widgetprv.h
index 6cbbbd6..dc01248 100644
--- a/src/widgetprv.h
+++ b/src/widgetprv.h
@@ -23,7 +23,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include <X11/IntrinsicP.h>
 #include <X11/CoreP.h>
-#include "widget.h"
 
 typedef struct {
   struct frame*        frame;          /* the *emacs* frame object */
diff --git a/src/window.c b/src/window.c
index a2d1538..d5bb210 100644
--- a/src/window.c
+++ b/src/window.c
@@ -23,11 +23,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 
 #include "lisp.h"
-#include "character.h"
 #include "buffer.h"
 #include "keyboard.h"
 #include "keymap.h"
-#include "menu.h"
 #include "frame.h"
 #include "window.h"
 #include "commands.h"
@@ -36,7 +34,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "disptab.h"
 #include "dispextern.h"
 #include "blockinput.h"
-#include "intervals.h"
 #include "termhooks.h"         /* For FRAME_TERMINAL.  */
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
diff --git a/src/xdisp.c b/src/xdisp.c
index c9eff50..976774b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -292,7 +292,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "atimer.h"
+#include "composite.h"
 #include "keyboard.h"
+#include "systime.h"
 #include "frame.h"
 #include "window.h"
 #include "termchar.h"
@@ -303,13 +305,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "indent.h"
 #include "commands.h"
 #include "keymap.h"
-#include "macros.h"
 #include "disptab.h"
 #include "termhooks.h"
 #include "termopts.h"
 #include "intervals.h"
 #include "coding.h"
-#include "process.h"
 #include "region-cache.h"
 #include "font.h"
 #include "fontset.h"
@@ -12393,6 +12393,7 @@ PIXELWISE non-nil means return the height of the tool 
bar in pixels.  */)
 static bool
 redisplay_tool_bar (struct frame *f)
 {
+  f->tool_bar_redisplayed = true;
 #if defined (USE_GTK) || defined (HAVE_NS)
 
   if (FRAME_EXTERNAL_TOOL_BAR (f))
@@ -13860,6 +13861,7 @@ redisplay_internal (void)
              bool gcscrollbars
                /* Only GC scrollbars when we redisplay the whole frame.  */
                = f->redisplay || !REDISPLAY_SOME_P ();
+             bool f_redisplay_flag = f->redisplay;
              /* Mark all the scroll bars to be removed; we'll redeem
                 the ones we want when we redisplay their windows.  */
              if (gcscrollbars && FRAME_TERMINAL (f)->condemn_scroll_bars_hook)
@@ -13903,6 +13905,20 @@ redisplay_internal (void)
                        goto retry_frame;
                    }
 
+                 /* If the frame's redisplay flag was not set before
+                    we went about redisplaying its windows, but it is
+                    set now, that means we employed some redisplay
+                    optimizations inside redisplay_windows, and
+                    bypassed producing some screen lines.  But if
+                    f->redisplay is now set, it might mean the old
+                    faces are no longer valid (e.g., if redisplaying
+                    some window called some Lisp which defined a new
+                    face or redefined an existing face), so trying to
+                    use them in update_frame will segfault.
+                    Therefore, we must redisplay this frame.  */
+                 if (!f_redisplay_flag && f->redisplay)
+                   goto retry_frame;
+
                  /* Prevent various kinds of signals during display
                     update.  stdio is not robust about handling
                     signals, which can cause an apparent I/O error.  */
@@ -13956,8 +13972,10 @@ redisplay_internal (void)
       /* Compare desired and current matrices, perform output.  */
 
     update:
-      /* If fonts changed, display again.  */
-      if (sf->fonts_changed)
+      /* If fonts changed, display again.  Likewise if redisplay_window_1
+        above caused some change (e.g., a change in faces) that requires
+        considering the entire frame again.  */
+      if (sf->fonts_changed || sf->redisplay)
        goto retry;
 
       /* Prevent freeing of realized faces, since desired matrices are
diff --git a/src/xfaces.c b/src/xfaces.c
index a3d122f..6bbd541 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -206,10 +206,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "character.h"
-#include "charset.h"
-#include "keyboard.h"
 #include "frame.h"
-#include "termhooks.h"
 
 #ifdef USE_MOTIF
 #include <Xm/Xm.h>
@@ -237,7 +234,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "dispextern.h"
 #include "blockinput.h"
 #include "window.h"
-#include "intervals.h"
 #include "termchar.h"
 
 #include "font.h"
diff --git a/src/xfns.c b/src/xfns.c
index fefd8e8..db87fcc 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -24,23 +24,15 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "xterm.h"
-#include "menu.h"
 #include "frame.h"
 #include "window.h"
-#include "character.h"
 #include "buffer.h"
-#include "intervals.h"
 #include "dispextern.h"
 #include "keyboard.h"
 #include "blockinput.h"
-#include <epaths.h>
 #include "charset.h"
 #include "coding.h"
-#include "fontset.h"
-#include "systime.h"
 #include "termhooks.h"
-#include "atimer.h"
-#include "termchar.h"
 #include "font.h"
 
 #include <sys/types.h>
@@ -1090,7 +1082,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
 #else /* not USE_X_TOOLKIT && not USE_GTK */
   FRAME_MENU_BAR_LINES (f) = nlines;
   FRAME_MENU_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f);
-  adjust_frame_size (f, -1, -1, 2, true, Qmenu_bar_lines);
+  adjust_frame_size (f, -1, -1, 2, true, Qx_set_menu_bar_lines);
   if (FRAME_X_WINDOW (f))
     x_clear_under_internal_border (f);
 
@@ -1212,14 +1204,24 @@ x_change_tool_bar_height (struct frame *f, int height)
 
   /* Recalculate toolbar height.  */
   f->n_tool_bar_rows = 0;
+  if (old_height == 0
+      && (!f->after_make_frame
+         || NILP (frame_inhibit_implied_resize)
+         || (CONSP (frame_inhibit_implied_resize)
+             && NILP (Fmemq (Qtool_bar_lines, frame_inhibit_implied_resize)))))
+    f->tool_bar_redisplayed = f->tool_bar_resized = false;
 
   adjust_frame_size (f, -1, -1,
-                    ((NILP (fullscreen = get_frame_param (f, Qfullscreen))
-                      || EQ (fullscreen, Qfullwidth)) ? 1
+                    ((!f->tool_bar_resized
+                      && (NILP (fullscreen =
+                                get_frame_param (f, Qfullscreen))
+                          || EQ (fullscreen, Qfullwidth))) ? 1
                      : (old_height == 0 || height == 0) ? 2
                      : 4),
                     false, Qtool_bar_lines);
 
+  f->tool_bar_resized = f->tool_bar_redisplayed;
+
   /* adjust_frame_size might not have done anything, garbage frame
      here.  */
   adjust_frame_glyphs (f);
@@ -3001,6 +3003,7 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   struct x_display_info *dpyinfo = NULL;
   Lisp_Object parent;
   struct kboard *kb;
+  int x_width = 0, x_height = 0;
 
   parms = Fcopy_alist (parms);
 
@@ -3275,7 +3278,7 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
                        FRAME_TOOL_BAR_POSITION (f), 0, 0, RES_TYPE_SYMBOL);
 
   /* Compute the size of the X window.  */
-  window_prompting = x_figure_window_size (f, parms, true);
+  window_prompting = x_figure_window_size (f, parms, true, &x_width, 
&x_height);
 
   tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || EQ (tem, Qt);
@@ -3317,12 +3320,6 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   x_default_parameter (f, parms, Qalpha, Qnil,
                       "alpha", "Alpha", RES_TYPE_NUMBER);
 
-  /* Consider frame official, now.  */
-  f->can_x_set_window_size = true;
-
-  adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, true,
-                    Qx_create_frame_2);
-
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
   /* Create the menu bar.  */
   if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
@@ -3341,6 +3338,14 @@ 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;
+
+  if (x_width > 0)
+    SET_FRAME_WIDTH (f, x_width);
+  if (x_height > 0)
+    SET_FRAME_HEIGHT (f, x_height);
+
   /* Tell the server what size and position, etc, we want, and how
      badly we want them.  This should be done after we have the menu
      bar so that its size can be taken into account.  */
@@ -3348,6 +3353,9 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   x_wm_set_size_hint (f, window_prompting, false);
   unblock_input ();
 
+  adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
+                    0, true, Qx_create_frame_2);
+
   /* 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.  */
@@ -5161,6 +5169,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
   bool face_change_before = face_change;
   Lisp_Object buffer;
   struct buffer *old_buffer;
+  int x_width = 0, x_height = 0;
 
   if (!dpyinfo->terminal->name)
     error ("Terminal is not live, can't create new frames on it");
@@ -5333,7 +5342,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
 
   f->output_data.x->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
 
-  x_figure_window_size (f, parms, false);
+  x_figure_window_size (f, parms, false, &x_width, &x_height);
 
   {
     XSetWindowAttributes attrs;
diff --git a/src/xfont.c b/src/xfont.c
index d5a7d64..671b105 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -24,15 +24,12 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <X11/Xlib.h>
 
 #include "lisp.h"
-#include "dispextern.h"
 #include "xterm.h"
 #include "frame.h"
 #include "blockinput.h"
 #include "character.h"
 #include "charset.h"
-#include "fontset.h"
 #include "font.h"
-#include "ccl.h"
 
 
 /* X core font driver.  */
diff --git a/src/xftfont.c b/src/xftfont.c
index 851edb6..956231e 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -25,14 +25,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <X11/Xft/Xft.h>
 
 #include "lisp.h"
-#include "dispextern.h"
 #include "xterm.h"
 #include "frame.h"
 #include "blockinput.h"
-#include "character.h"
 #include "charset.h"
 #include "composite.h"
-#include "fontset.h"
 #include "font.h"
 #include "ftfont.h"
 
diff --git a/src/xgselect.c b/src/xgselect.c
index 0b62d3e..55e1ffc 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -26,9 +26,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <glib.h>
 #include <errno.h>
 #include <stdbool.h>
-#include <timespec.h>
-#include "frame.h"
 #include "blockinput.h"
+#include "systime.h"
 
 /* `xg_select' is a `pselect' replacement.  Why do we need a separate function?
    1. Timeouts.  Glib and Gtk rely on timer events.  If we did pselect
diff --git a/src/xgselect.h b/src/xgselect.h
index ada2376..524fff7 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -21,9 +21,10 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #define XGSELECT_H
 
 #include "lisp.h"
-#include <time.h>
 #include "sysselect.h"
 
+struct timespec;
+
 extern int xg_select (int max_fds,
                      fd_set *rfds, fd_set *wfds, fd_set *efds,
                      struct timespec const *timeout,
diff --git a/src/xmenu.c b/src/xmenu.c
index 192ed89..be6e41d 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -36,14 +36,12 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "keyboard.h"
-#include "keymap.h"
 #include "frame.h"
+#include "systime.h"
 #include "termhooks.h"
 #include "window.h"
 #include "blockinput.h"
-#include "character.h"
 #include "buffer.h"
-#include "charset.h"
 #include "coding.h"
 #include "sysselect.h"
 
@@ -63,8 +61,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <sys/types.h>
 #endif
 
-#include "dispextern.h"
-
 #ifdef HAVE_X_WINDOWS
 /*  Defining HAVE_MULTILINGUAL_MENU would mean that the toolkit menu
     code accepts the Emacs internal encoding.  */
@@ -636,13 +632,7 @@ update_frame_menubar (struct frame *f)
   lw_refigure_widget (x->column_widget, True);
 
   /* Force the pane widget to resize itself.  */
-  int new_height = -1;
-#ifdef USE_LUCID
-  /* For reasons I don't know Lucid wants to add one pixel to the frame
-     height when adding the menu bar.  Compensate that here.  */
-  new_height = FRAME_TEXT_HEIGHT (f) - 1;
-#endif /* USE_LUCID */
-  adjust_frame_size (f, -1, new_height, 2, false, Qmenu_bar_lines);
+  adjust_frame_size (f, -1, -1, 2, false, Qupdate_frame_menubar);
   unblock_input ();
 #endif /* USE_GTK */
 }
@@ -979,7 +969,15 @@ set_frame_menubar (struct frame *f, bool first_time, bool 
deep_p)
     menubar_size
       = (f->output_data.x->menubar_widget
         ? (f->output_data.x->menubar_widget->core.height
-           + f->output_data.x->menubar_widget->core.border_width)
+#ifndef USE_LUCID
+           /* Damn me...  With Lucid I get a core.border_width of 1
+              only the first time this is called and an ibw of 1 every
+              time this is called.  So the first time this is called I
+              was off by one.  Fix that here by never adding
+              core.border_width for Lucid.  */
+           + f->output_data.x->menubar_widget->core.border_width
+#endif /* USE_LUCID */
+           )
         : 0);
 
 #ifdef USE_LUCID
@@ -990,9 +988,10 @@ set_frame_menubar (struct frame *f, bool first_time, bool 
deep_p)
     if (FRAME_EXTERNAL_MENU_BAR (f))
       {
         Dimension ibw = 0;
+
         XtVaGetValues (f->output_data.x->column_widget,
                       XtNinternalBorderWidth, &ibw, NULL);
-        menubar_size += ibw;
+       menubar_size += ibw;
       }
 #endif /* USE_LUCID */
 
@@ -1073,21 +1072,24 @@ free_frame_menubar (struct frame *f)
 
       if (f->output_data.x->widget)
        {
-         int new_height = -1;
 #ifdef USE_MOTIF
          XtVaGetValues (f->output_data.x->widget, XtNx, &x1, XtNy, &y1, NULL);
          if (x1 == 0 && y1 == 0)
            XtVaSetValues (f->output_data.x->widget, XtNx, x0, XtNy, y0, NULL);
          if (frame_inhibit_resize (f, false, Qmenu_bar_lines))
-           new_height = old_height;
+           adjust_frame_size (f, -1, old_height, 1, false, 
Qfree_frame_menubar_1);
+         else
+           adjust_frame_size (f, -1, -1, 2, false, Qfree_frame_menubar_1);
+#else
+         adjust_frame_size (f, -1, -1, 2, false, Qfree_frame_menubar_1);
 #endif /* USE_MOTIF */
-         adjust_frame_size (f, -1, new_height, 2, false, Qmenu_bar_lines);
        }
       else
        {
 #ifdef USE_MOTIF
-         if (frame_inhibit_resize (f, false, Qmenu_bar_lines))
-           adjust_frame_size (f, -1, old_height, 1, false, Qmenu_bar_lines);
+         if (WINDOWP (FRAME_ROOT_WINDOW (f))
+             && frame_inhibit_resize (f, false, Qmenu_bar_lines))
+           adjust_frame_size (f, -1, old_height, 1, false, 
Qfree_frame_menubar_2);
 #endif
        }
 
diff --git a/src/xml.c b/src/xml.c
index 9e68fff..fc77f22 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -25,7 +25,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <libxml/HTMLparser.h>
 
 #include "lisp.h"
-#include "character.h"
 #include "buffer.h"
 
 
diff --git a/src/xrdb.c b/src/xrdb.c
index 2235b45..ce6e7d2 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -43,11 +43,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <pwd.h>
 #endif
 
-#ifdef USE_MOTIF
-/* For Vdouble_click_time.  */
-#include "keyboard.h"
-#endif
-
 /* X file search path processing.  */
 
 
diff --git a/src/xselect.c b/src/xselect.c
index 9a7e697..9d178a5 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -31,12 +31,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "xterm.h"     /* for all of the X includes */
-#include "dispextern.h"        /* frame.h seems to want this */
 #include "frame.h"     /* Need this to get the X window of selected_frame */
 #include "blockinput.h"
-#include "character.h"
-#include "buffer.h"
-#include "process.h"
 #include "termhooks.h"
 #include "keyboard.h"
 
diff --git a/src/xsettings.h b/src/xsettings.h
index 7ef94a0..71b71d6 100644
--- a/src/xsettings.h
+++ b/src/xsettings.h
@@ -20,6 +20,10 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #ifndef XSETTINGS_H
 #define XSETTINGS_H
 
+#include <X11/Xlib.h>
+
+struct x_display_info;
+
 extern void xsettings_initialize (struct x_display_info *);
 extern void xft_settings_event (struct x_display_info *, const XEvent *);
 extern const char *xsettings_get_system_font (void);
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 3b06f71..b84f2ac 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -32,8 +32,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 
 #include "lisp.h"
-#include "systime.h"
-#include "sysselect.h"
 #include "frame.h"
 #include "termhooks.h"
 #include "xterm.h"
diff --git a/src/xterm.c b/src/xterm.c
index d32ca0f..000e1f8 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -28,7 +28,6 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "blockinput.h"
-#include "syssignal.h"
 
 /* This may include sys/types.h, and that somehow loses
    if this is not done before the other system files.  */
@@ -58,12 +57,9 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <fcntl.h>
 #include <errno.h>
 #include <sys/stat.h>
-/* Caused redefinition of DBL_DIG on Netbsd; seems not to be needed.  */
-/* #include <sys/param.h>  */
-
-#include "charset.h"
 #include "character.h"
 #include "coding.h"
+#include "composite.h"
 #include "frame.h"
 #include "dispextern.h"
 #ifdef HAVE_XWIDGETS
@@ -74,17 +70,12 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include "termopts.h"
 #include "termchar.h"
 #include "emacs-icon.h"
-#include "disptab.h"
 #include "buffer.h"
 #include "window.h"
 #include "keyboard.h"
-#include "intervals.h"
-#include "process.h"
 #include "atimer.h"
-#include "keymap.h"
 #include "font.h"
 #include "xsettings.h"
-#include "xgselect.h"
 #include "sysselect.h"
 #include "menu.h"
 
@@ -2218,7 +2209,7 @@ x_query_colors (struct frame *f, XColor *colors, int 
ncolors)
         the 0xff00 we'd get by just zero-filling the lower bits.
 
          We generate a 32-bit scaled-up value and shift it, in case
-         the bit count doesn't divide 16 evently (e.g., when dealing
+         the bit count doesn't divide 16 evenly (e.g., when dealing
          with a 3-3-2 bit RGB display), to get more of the lower bits
          correct.
 
@@ -8416,7 +8407,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
         {
           XNextEvent (dpyinfo->display, &next_event);
           if (next_event.type != ConfigureNotify
-              || next_event.xconfigure.window != event->xconfigure.window)
+              || next_event.xconfigure.window != event->xconfigure.window
+              /* Skipping events with different sizes can lead to a
+                 mispositioned mode line at initial window creation.
+                 Only drop window motion events for now.  */
+              || next_event.xconfigure.width != event->xconfigure.width
+              || next_event.xconfigure.height != event->xconfigure.height)
             {
               XPutBackEvent (dpyinfo->display, &next_event);
               break;
@@ -9593,6 +9589,10 @@ x_new_font (struct frame *f, Lisp_Object font_object, 
int fontset)
 {
   struct font *font = XFONT_OBJECT (font_object);
   int unit, font_ascent, font_descent;
+#ifndef USE_X_TOOLKIT
+  int old_menu_bar_height = FRAME_MENU_BAR_HEIGHT (f);
+  Lisp_Object fullscreen;
+#endif
 
   if (fontset < 0)
     fontset = fontset_from_font (font_object);
@@ -9629,9 +9629,25 @@ x_new_font (struct frame *f, Lisp_Object font_object, 
int fontset)
         doing it because it's done in Fx_show_tip, and it leads to
         problems because the tip frame has no widget.  */
       if (NILP (tip_frame) || XFRAME (tip_frame) != f)
+       {
          adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
                             FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3,
                             false, Qfont);
+#ifndef USE_X_TOOLKIT
+         if (FRAME_MENU_BAR_HEIGHT (f) != old_menu_bar_height
+             && !f->after_make_frame
+             && (EQ (frame_inhibit_implied_resize, Qt)
+                 || (CONSP (frame_inhibit_implied_resize)
+                     && NILP (Fmemq (Qfont, frame_inhibit_implied_resize))))
+             && (NILP (fullscreen = get_frame_param (f, Qfullscreen))
+                 || EQ (fullscreen, Qfullwidth)))
+           /* If the menu bar height changes, try to keep text height
+              constant.  */
+           adjust_frame_size
+             (f, -1, FRAME_TEXT_HEIGHT (f) + FRAME_MENU_BAR_HEIGHT (f)
+              - old_menu_bar_height, 1, false, Qfont);
+#endif /* USE_X_TOOLKIT  */
+       }
     }
 
 #ifdef HAVE_X_I18N
@@ -10563,7 +10579,7 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
   if (EQ (fullscreen, Qfullwidth) && width == FRAME_TEXT_WIDTH (f))
     {
       frame_size_history_add
-       (f, Qxg_frame_set_char_size_1, width, height,
+       (f, Qx_set_window_size_1, width, height,
         list2 (make_number (old_height),
                make_number (pixelheight + FRAME_MENUBAR_HEIGHT (f))));
 
@@ -10573,7 +10589,7 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
   else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f))
     {
       frame_size_history_add
-       (f, Qxg_frame_set_char_size_2, width, height,
+       (f, Qx_set_window_size_2, width, height,
         list2 (make_number (old_width), make_number (pixelwidth)));
 
       XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
@@ -10583,10 +10599,11 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
   else
     {
       frame_size_history_add
-       (f, Qxg_frame_set_char_size_3, width, height,
-        list2 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)),
+       (f, Qx_set_window_size_3, width, height,
+        list3 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)),
                make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
-                            + FRAME_MENUBAR_HEIGHT (f))));
+                            + FRAME_MENUBAR_HEIGHT (f)),
+               make_number (FRAME_MENUBAR_HEIGHT (f))));
 
       XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
                     pixelwidth, pixelheight + FRAME_MENUBAR_HEIGHT (f));
@@ -11356,8 +11373,8 @@ x_wm_set_size_hint (struct frame *f, long flags, bool 
user_position)
   size_hints.x = f->left_pos;
   size_hints.y = f->top_pos;
 
-  size_hints.height = FRAME_PIXEL_HEIGHT (f);
   size_hints.width = FRAME_PIXEL_WIDTH (f);
+  size_hints.height = FRAME_PIXEL_HEIGHT (f);
 
   size_hints.width_inc = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f);
   size_hints.height_inc = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f);
@@ -11370,34 +11387,21 @@ x_wm_set_size_hint (struct frame *f, long flags, bool 
user_position)
   /* Calculate the base and minimum sizes.  */
   {
     int base_width, base_height;
-    int min_rows = 0, min_cols = 0;
 
     base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
     base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);
 
-    if (frame_resize_pixelwise)
-      /* Needed to prevent a bad protocol error crash when making the
-        frame size very small.  */
-      {
-       min_cols = 2 * min_cols;
-       min_rows = 2 * min_rows;
-      }
-
     /* The window manager uses the base width hints to calculate the
        current number of rows and columns in the frame while
        resizing; min_width and min_height aren't useful for this
        purpose, since they might not give the dimensions for a
-       zero-row, zero-column frame.
-
-       We use the base_width and base_height members if we have
-       them; otherwise, we set the min_width and min_height members
-       to the size for a zero x zero frame.  */
+       zero-row, zero-column frame.  */
 
     size_hints.flags |= PBaseSize;
     size_hints.base_width = base_width;
     size_hints.base_height = base_height + FRAME_MENUBAR_HEIGHT (f);
-    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;
   }
 
   /* If we don't need the old flags, we don't need the old hint at all.  */
diff --git a/test/automated/coding-tests.el b/test/automated/coding-tests.el
index ebbf896..cda382f 100644
--- a/test/automated/coding-tests.el
+++ b/test/automated/coding-tests.el
@@ -36,7 +36,7 @@
       (let (test-file)
         (or (file-directory-p coding-tests-workdir)
             (mkdir coding-tests-workdir t))
-        (setq test-file (expand-file-name "nonexisting" coding-tests-workdir))
+        (setq test-file (expand-file-name "nonexistent" coding-tests-workdir))
         (if (file-exists-p test-file)
             (delete-file test-file))
         (should-error
diff --git a/test/automated/file-notify-tests.el 
b/test/automated/file-notify-tests.el
index 03946dd..1763648 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/automated/file-notify-tests.el
@@ -62,7 +62,8 @@
 (defvar file-notify--test-event nil)
 (defvar file-notify--test-events nil)
 (defun file-notify--test-timeout ()
-  (if (file-remote-p temporary-file-directory) 6 3))
+  "Timeout to wait for arriving events, in seconds."
+  (if (file-remote-p temporary-file-directory) 10 3))
 
 (defun file-notify--test-cleanup ()
   "Cleanup after a test."
@@ -324,12 +325,24 @@ Don't wait longer than TIMEOUT seconds for the events to 
be delivered."
                  file-notify--test-tmpfile
                  '(attribute-change) 'file-notify--test-event-handler))
           (file-notify--test-with-events
-              (file-notify--test-timeout) '(attribute-changed 
attribute-changed)
+              (file-notify--test-timeout) '(attribute-changed)
+            (write-region
+             "any text" nil file-notify--test-tmpfile nil 'no-message)
+            (set-file-modes file-notify--test-tmpfile 000)
+            (delete-file file-notify--test-tmpfile))
+          (file-notify-rm-watch file-notify--test-desc)
+
+          ;; With gfilenotify, there are timing issues with attribute
+          ;; changes in a short time period.  So we apply 2 tests.
+          (setq file-notify--test-desc
+                (file-notify-add-watch
+                 file-notify--test-tmpfile
+                 '(attribute-change) 'file-notify--test-event-handler))
+          (file-notify--test-with-events
+              (file-notify--test-timeout) '(attribute-changed)
             (write-region
              "any text" nil file-notify--test-tmpfile nil 'no-message)
             (set-file-modes file-notify--test-tmpfile 000)
-            (read-event nil nil 0.1) ; In order to distinguish the events.
-            (set-file-times file-notify--test-tmpfile '(0 0))
             (delete-file file-notify--test-tmpfile))
           (file-notify-rm-watch file-notify--test-desc))
 
diff --git a/test/automated/seq-tests.el b/test/automated/seq-tests.el
index 7023c94..5d93682 100644
--- a/test/automated/seq-tests.el
+++ b/test/automated/seq-tests.el
@@ -328,5 +328,14 @@ Evaluate BODY for each created sequence.
     (should (eq seq (seq-into-sequence seq)))
     (should-error (seq-into-sequence 2))))
 
+(ert-deftest test-seq-position ()
+  (with-test-sequences (seq '(2 4 6))
+    (should (null (seq-position seq 1)))
+    (should (= (seq-position seq 4) 1)))
+  (let ((seq '(a b c)))
+    (should (null (seq-position seq 'd #'eq)))
+    (should (= (seq-position seq 'a #'eq) 0))
+    (should (null (seq-position seq (make-symbol "a") #'eq)))))
+
 (provide 'seq-tests)
 ;;; seq-tests.el ends here
diff --git a/test/automated/tabulated-list-test.el 
b/test/automated/tabulated-list-test.el
index 5731db4..9aa62ee 100644
--- a/test/automated/tabulated-list-test.el
+++ b/test/automated/tabulated-list-test.el
@@ -60,7 +60,7 @@
        4clojure   4clojure   1507      obsolete    Open and evaluate 
4clojure.com questions
        abc-mode   abc-mode   944       available   Major mode for editing abc 
music files
        mode       mode       1128      installed   A simple mode for editing 
Actionscript 3 files\n"))
-   ;; Preseve position.
+   ;; Preserve position.
    (forward-line 3)
    (let ((pos (thing-at-point 'line)))
      (pop tabulated-list-entries)
diff --git a/test/indent/js.js b/test/indent/js.js
index 2120233..d897b9f 100644
--- a/test/indent/js.js
+++ b/test/indent/js.js
@@ -69,6 +69,13 @@ baz(`http://foo.bar/${tee}`)
   are kept
         unchanged!`
 
+class A {
+  * x() {
+    return 1
+      * 2;
+  }
+}
+
 // Local Variables:
 // indent-tabs-mode: nil
 // js-indent-level: 2



reply via email to

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