emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] xwidget_mvp 5cefb1b 3/4: Merge remote-tracking branch 'ori


From: Joakim Verona
Subject: [Emacs-diffs] xwidget_mvp 5cefb1b 3/4: Merge remote-tracking branch 'origin/master' into xwidget_mvp
Date: Tue, 28 Apr 2015 16:41:14 +0000

branch: xwidget_mvp
commit 5cefb1b7afd86ccd72528f9adc10603847decc9d
Merge: c39847c e78aef0
Author: Joakim Verona <address@hidden>
Commit: Joakim Verona <address@hidden>

    Merge remote-tracking branch 'origin/master' into xwidget_mvp
    
    Conflicts:
        src/print.c
---
 CONTRIBUTE                           |  118 +++--
 ChangeLog.2                          |  448 ++++++++++++++++-
 Makefile.in                          |    2 +-
 build-aux/gitlog-to-emacslog         |   15 +-
 doc/lispref/display.texi             |    8 +
 doc/lispref/sequences.texi           |    2 +-
 doc/misc/eudc.texi                   |   32 +-
 etc/NEWS                             |   26 +
 etc/themes/tsdh-light-theme.el       |    7 +-
 lib-src/ebrowse.c                    |    2 +-
 lib-src/hexl.c                       |    4 +-
 lib/acl-internal.c                   |  469 +++++++++++++++++
 lib/acl-internal.h                   |    2 +-
 lib/file-has-acl.c                   |  919 ----------------------------------
 lib/gnulib.mk                        |    2 +-
 lib/qcopy-acl.c                      |   17 +-
 lib/tempname.c                       |    4 +-
 lisp/cus-edit.el                     |    3 +-
 lisp/custom.el                       |    3 +-
 lisp/emacs-lisp/eieio-core.el        |   22 +-
 lisp/emacs-lisp/package.el           |  169 +++++--
 lisp/emacs-lisp/seq.el               |   38 +-
 lisp/files.el                        |    8 +-
 lisp/gnus/message.el                 |    4 +-
 lisp/help-fns.el                     |   33 +-
 lisp/info.el                         |   43 +-
 lisp/mail/rmail.el                   |   10 +-
 lisp/mail/rmailedit.el               |    2 +
 lisp/midnight.el                     |   95 ++--
 lisp/mouse.el                        |   17 +-
 lisp/net/eudc-vars.el                |    6 +-
 lisp/net/shr.el                      |    3 +
 lisp/progmodes/elisp-mode.el         |    6 +-
 lisp/progmodes/xref.el               |   15 +-
 lisp/saveplace.el                    |   71 ++--
 lisp/server.el                       |    1 +
 lisp/subr.el                         |   28 +-
 lisp/textmodes/bibtex.el             |    2 +-
 lisp/textmodes/ispell.el             |   15 +-
 lisp/textmodes/reftex-cite.el        |   12 +-
 lisp/textmodes/reftex-toc.el         |  145 +++---
 lisp/textmodes/reftex.el             |    4 +-
 lisp/textmodes/tex-mode.el           |    6 +-
 lisp/textmodes/text-mode.el          |    9 +-
 lisp/vc/vc-bzr.el                    |    6 +
 lisp/vc/vc-git.el                    |   43 +-
 lisp/wid-edit.el                     |   14 +-
 lisp/window.el                       |   17 +-
 m4/acl.m4                            |   47 ++-
 m4/gnulib-comp.m4                    |    2 +-
 m4/lstat.m4                          |   48 +-
 m4/manywarnings.m4                   |   23 +-
 nt/gnulib.mk                         |    2 +-
 src/ccl.c                            |    2 +-
 src/character.c                      |    4 +-
 src/dbusbind.c                       |    4 +-
 src/editfns.c                        |   10 +-
 src/gnutls.c                         |    2 +-
 src/gtkutil.c                        |    6 +-
 src/image.c                          |    9 +-
 src/keyboard.c                       |    2 +-
 src/lread.c                          |    2 +-
 src/print.c                          |   88 ++--
 src/process.c                        |   40 +-
 src/term.c                           |    8 +-
 src/textprop.c                       |   60 ++-
 src/w32fns.c                         |   27 +-
 src/xdisp.c                          |   24 +-
 src/xterm.c                          |    2 +-
 test/automated/message-mode-tests.el |    5 +-
 test/automated/package-test.el       |    5 +-
 test/automated/print-tests.el        |    6 +
 72 files changed, 1830 insertions(+), 1525 deletions(-)

diff --git a/CONTRIBUTE b/CONTRIBUTE
index d0e3750..bf23155 100644
--- a/CONTRIBUTE
+++ b/CONTRIBUTE
@@ -7,19 +7,22 @@ 
http://www.gnu.org/software/emacs/manual/html_node/emacs/Contributing.html
 * Information for Emacs Developers.
 
 An "Emacs Developer" is someone who contributes a lot of code or
-documentation to the Emacs repository. Generally, they have write
+documentation to the Emacs repository.  Generally, they have write
 access to the Emacs git repository on Savannah
 https://savannah.gnu.org/git/?group=emacs.
 
 ** Write access to the Emacs repository.
 
 Once you become a frequent contributor to Emacs, we can consider
-giving you write access to the version-control repository. Request
-access on the address@hidden mailing list.
+giving you write access to the version-control repository.  Request
+access on the address@hidden mailing list.  Also, be sure to
+subscribe to the address@hidden mailing list and include the
+"emacs-announce" topic, so that you get the announcements about
+feature freeze and other important events.
 
 ** Using the Emacs repository
 
-Emacs uses git for the source code repository.
+Emacs uses Git for the source code repository.
 
 See http://www.emacswiki.org/emacs/GitQuickStartForEmacsDevs to get
 started, and http://www.emacswiki.org/emacs/GitForEmacsDevs for more
@@ -28,16 +31,18 @@ advanced information.
 Alternately, see admin/notes/git-workflow.
 
 If committing changes written by someone else, make the commit in
-their name, not yours.  git distinguishes between the author
+their name, not yours.  Git distinguishes between the author
 and the committer; use the --author option on the commit command to
 specify the actual author; the committer defaults to you.
 
 ** Commit messages
 
-When a release is prepared, the commit messages are used to generate
-the ChangeLog file.  So a typical patch does not touch any of the
-ChangeLog files in the repository, but contains the ChangeLog entries
-in its message.  Here is an example commit message (indented):
+Emacs development no longer stores descriptions of new changes in
+ChangeLog files.  Instead, a single ChangeLog file is generated from
+the commit messages when a release is prepared.  So changes you commit
+should not touch any of the ChangeLog files in the repository, but
+instead should contain the log entries in the commit message.  Here is
+an example of a commit message (indented):
 
        Deactivate shifted region
 
@@ -48,10 +53,17 @@ in its message.  Here is an example commit message 
(indented):
        * src/frame.c (Fhandle_switch_frame, Fselected_frame):
        Deactivate the mark.
 
-The general format is as follows.
+Below are some rules and recommendations for formatting commit
+messages:
 
-- Start with a single unindented summary line explaining the change,
-  then an empty line, then unindented ChangeLog entries.
+- Start with a single unindented summary line explaining the change;
+  do not end this line with a period.  If that line starts with a
+  semi-colon and a space "; ", the log message will be ignored when
+  generating the ChangeLog file.  Use this for minor commits that do
+  not need separate ChangeLog entries, such as changes in etc/NEWS.
+
+- After the summary line, there should be an empty line, then
+  unindented ChangeLog entries.
 
 - Limit lines in commit messages to 78 characters, unless they consist
   of a single word of at most 140 characters; this is enforced by a
@@ -64,22 +76,38 @@ The general format is as follows.
   file first line (starting with the asterisk).  Then there is no
   individual files section.
 
-- Explaining the rationale for a design choice is best done in comments
-  in the source code. However, sometimes it is useful to describe just
-  the rationale for a change; that can be done in the commit message
-  between the summary line and the file entries.
+- If the commit has more than one author, the commit message should
+  contain separate lines to mention the other authors, like the
+  following:
+
+       Co-authored-by: Joe Schmoe <address@hidden>
+
+- If the commit is a tiny change that is exempt from copyright paperwork,
+  the commit message should contain a separate line like the following:
+
+       Copyright-paperwork-exempt: yes
+
+- The commit message should contain "Bug#NNNNN" if it is related to
+  bug number NNNNN in the debbugs database.  This string is often
+  parenthesized, as in "(Bug#19003)".
 
 - Commit messages should contain only printable UTF-8 characters.
 
 - Commit messages should not contain the "Signed-off-by:" lines that
   are used in some other projects.
 
+- Explaining the rationale for a design choice is best done in comments
+  in the source code.  However, sometimes it is useful to describe just
+  the rationale for a change; that can be done in the commit message
+  between the summary line and the file entries.
+
 - Emacs generally follows the GNU coding standards when it comes to
   ChangeLogs:
-  http://www.gnu.org/prep/standards/html_node/Change-Logs.html .  One
-  exception is that we still sometimes quote `like-this' (as the
-  standards used to recommend) rather than 'like-this' (as they do
-  now), because `...' is so widely used elsewhere in Emacs.
+  http://www.gnu.org/prep/standards/html_node/Change-Logs.html or
+  "(info (standards)Change Logs").  One exception is that we still
+  sometimes quote `like-this' (as the standards used to recommend)
+  rather than 'like-this' (as they do now), because `...' is so widely
+  used elsewhere in Emacs.
 
 - Some of the rules in the GNU coding standards section 5.2
   "Commenting Your Work" also apply to ChangeLog entries: they must be
@@ -102,27 +130,15 @@ The general format is as follows.
 
   (Rather than anything involving "ditto" and suchlike.)
 
-- If the commit has authors other than yourself, the commit message
-  should contain a separate line like the following:
-
-       Co-authored-by: Joe Schmoe <address@hidden>
-
-- If the commit is a tiny change that is exempt from copyright paperwork,
-  the commit message should contain a separate line like the following:
-
-       Copyright-paperwork-exempt: yes
-
-- The commit message should contain "Bug#NNNNN" if it is related to
-  bug number NNNNN in the debbugs database.  This string is often
-  parenthesized, as in "(Bug#19003)".
-
-- In ChangeLog entries, there is no standard or recommended way to
-  identify revisions.
+- There is no standard or recommended way to identify revisions in
+  ChangeLog entries.  Using Git SHA1 values limits the usability of
+  the references to Git, and will become much less useful if Emacs
+  switches to a different VCS.  So we recommend against that.
 
   One way to identify revisions is by quoting their summary line.
   Another is with an action stamp - an RFC3339 date followed by !
   followed by the committer's email - for example,
-  "2014-01-16T05:43:address@hidden". Often, "my previous commit"
+  "2014-01-16T05:43:address@hidden".  Often, "my previous commit"
   will suffice.
 
 - There is no need to mention files such as NEWS, MAINTAINERS, and
@@ -130,12 +146,6 @@ The general format is as follows.
   'configure', in the ChangeLog entry.  "There is no need" means you
   don't have to, but you can if you want to.
 
-- If a commit message's first line starts with "; ", the message is
-  ignored when generating ChangeLog history files via 'make ChangeLog'
-  or via 'make change-history'.  You can use "; " for minor commits
-  that do not need separate ChangeLog entries, as well as commits that
-  only modify files that don't need these entries at all.
-
 ** Generating ChangeLog entries
 
 - You can use various Emacs functions to ease the process of writing
@@ -156,7 +166,7 @@ The general format is as follows.
   with Emacs commands like 'C-x 4 a', and commit the change using the
   shell command 'vc-dwim --commit'.  Type 'vc-dwim --help' for more.
 
-** branches
+** Branches
 
 Development normally takes places on the trunk.
 Sometimes specialized features are developed on separate branches
@@ -167,9 +177,9 @@ Development is discussed on the emacs-devel mailing list.
 Sometime before the release of a new major version of Emacs a "feature
 freeze" is imposed on the trunk, to prepare for creating a release
 branch.  No new features may be added to the trunk after this point,
-until the release branch is created. Announcements about the freeze
-(and other important events) are made on the info-gnu-emacs mailing
-list, and not anywhere else.
+until the release branch is created.  Announcements about the freeze
+(and other important events) are made on the emacs-devel mailing
+list under the "emacs-announce" topic, and not anywhere else.
 
 The trunk branch is named "master" in git; release branches are named
 "emacs-nn" where "nn" is the major version.
@@ -188,13 +198,13 @@ then exclude that commit from the merge to trunk.
 
 ** Other process information
 
-See all the files in admin/notes/* . In particular, see
+See all the files in admin/notes/* .  In particular, see
 admin/notes/newfile, see admin/notes/repo.
 
 *** git vs rename
 
-git does not explicitly represent a file renaming; it uses a percent
-changed heuristic to deduce that a file was renamed. So if you are
+Git does not explicitly represent a file renaming; it uses a percent
+changed heuristic to deduce that a file was renamed.  So if you are
 planning to make extensive changes to a file after renaming it (or
 moving it to another directory), you should:
 
@@ -205,7 +215,7 @@ moving it to another directory), you should:
 - make other changes
 
 - merge the feature branch to trunk, _not_ squashing the commits into
-  one. The commit message on this merge should summarize the renames
+  one.  The commit message on this merge should summarize the renames
   and all the changes.
 
 ** Emacs Mailing lists.
@@ -232,7 +242,7 @@ Doc-strings should be updated together with the code.
 Think about whether your change requires updating the manuals.  If you
 know it does not, mark the NEWS entry with "---".  If you know
 that *all* the necessary documentation updates have been made, mark
-the entry with "+++". Otherwise do not mark it.
+the entry with "+++".  Otherwise do not mark it.
 
 Please see (info "(elisp)Documentation Tips") or
 
https://www.gnu.org/software/emacs/manual/html_node/elisp/Documentation-Tips.html
@@ -258,7 +268,9 @@ top-level directory.  Most tests are in the directory
 
 The best way to understand Emacs Internals is to read the code,
 but the nodes "Tips" and "GNU Emacs Internals" in the Appendix
-of the Emacs Lisp Reference Manual may also help.
+of the Emacs Lisp Reference Manual may also help.  Some source files,
+such as xdisp.c, have large commentaries describing the design and
+implementation in more detail.
 
 The file etc/DEBUG describes how to debug Emacs bugs.
 
diff --git a/ChangeLog.2 b/ChangeLog.2
index 90ef58c..188e3ff 100644
--- a/ChangeLog.2
+++ b/ChangeLog.2
@@ -1,3 +1,443 @@
+2015-04-25  Paul Eggert  <address@hidden>
+
+       Don't freeze with unreadable processes
+       Don't freeze if an exiting process can't be read from. (Bug#19860).
+       This fixes a bug I introduced in
+       2014-07-08T07:24:address@hidden@cs.ucla.edu
+       "* process.c: Add sanity checks for file descriptors."
+       Dmitry Gutov did most of the legwork in finding the problem.
+       * src/process.c (wait_reading_process_output):
+       Treat non-running processes that can't be read from
+       the same as other non-running processes.
+
+2015-04-25  Alan Mackenzie  <address@hidden>
+
+       Fix change from 2015-04-22 "On C-y, stop some text property entries ..."
+       * lisp/subr.el (remove-yank-excluded-properties): put
+       `with-silent-modifications' around only the last three lines of code.
+
+2015-04-25  Artur Malabarba  <address@hidden>
+
+       * lisp/emacs-lisp/package.el (package-all-keywords): Don't cache
+       (package--all-keywords): Deleted variable.
+
+       * etc/NEWS: Document package-hiding functionality
+
+2015-04-25  Eli Zaretskii  <address@hidden>
+
+       lisp/window.el (recenter-last-op): Doc fix.  (Bug#20419)
+
+       Clarify the doc string of 'replace-regexp-in-string'
+       * lisp/subr.el (replace-regexp-in-string): Doc fix.  (Bug#20395)
+
+       Improve doc string of 'insert-buffer-substring'
+       * src/editfns.c (Finsert_buffer_substring): Doc fix.  (Bug#20421)
+
+       MS-Windows followup for the recent gnulib update
+       * nt/gnulib.mk (libgnu_a_SOURCES): Replace file-has-acl.c with
+       acl-internal.c.
+
+2015-04-24  Paul Eggert  <address@hidden>
+
+       Spelling fixes
+
+       Merge from gnulib
+       This incorporates:
+       2015-04-24 file-has-acl: new module, split from acl
+       2015-04-24 manywarnings: add GCC 5.1 warnings
+       2015-04-21 lstat: fix cross-compilation 'ln -s' problem
+       2015-04-15 qacl: Simplify HP-UX acl_nontrivial check
+       2015-04-15 acl: On Linux, check for acls without libacl
+       2015-04-14 tempname: avoid unused parameter warnings (trivial)
+       * lib/acl-internal.c: New file, from gnulib.
+       * lib/file-has-acl.c: Remove; no longer imported from gnulib.
+       * lib/acl-internal.h, lib/gnulib.mk, lib/qcopy-acl.c, lib/tempname.c:
+       * m4/acl.m4, m4/gnulib-comp.m4, m4/lstat.m4, m4/manywarnings.m4:
+       Update from gnulib.
+
+       Port --enable-gcc-warnings to GCC 5.1 x86-64
+       * lib-src/ebrowse.c (dump_sym):
+       * lib-src/hexl.c (main):
+       * src/ccl.c (ccl_driver):
+       * src/character.c (string_escape_byte8):
+       * src/dbusbind.c (xd_retrieve_arg, xd_add_watch):
+       * src/gnutls.c (Fgnutls_boot):
+       * src/gtkutil.c (xg_check_special_colors):
+       * src/image.c (x_build_heuristic_mask):
+       * src/print.c (safe_debug_print, print_object):
+       * src/term.c (produce_glyphless_glyph):
+       * src/xdisp.c (get_next_display_element)
+       (produce_glyphless_glyph):
+       * src/xterm.c (x_draw_glyphless_glyph_string_foreground):
+       Don't use a signed format to print an unsigned integer, or vice
+       versa.  GCC 5.1's new -Wformat-signedness option warns about this.
+       * src/image.c (png_load_body, jpeg_load_body):
+       Silence a bogus setjump diagnostic from GCC 5.1 (GCC bug 54561).
+
+2015-04-24  Tassilo Horn  <address@hidden>
+
+       Add new faces to tsdh-light-theme
+       * etc/themes/tsdh-light-theme.el (tsdh-light): New face
+       definitions for Info-quoted, ace-jump-face-foreground,
+       hl-paren-face, show-paren-match, and show-paren-mismatch.
+
+2015-04-24  Nicolas Petton  <address@hidden>
+
+       * lisp/emacs-lisp/seq.el (seq-doseq): Fix the macro.
+
+2015-04-24  Glenn Morris  <address@hidden>
+
+       * build-aux/gitlog-to-emacslog:
+       Use raw log format rather than wrapped one.
+
+2015-04-24  Stefan Monnier  <address@hidden>
+
+       * lisp/emacs-lisp/seq.el (seq-doseq): Tighten the code
+       (seq-doseq): Fix out-of-scope binding.
+       Don't call `seq-length at every iteration.
+       Reduce `if's from 3 to 2 per iteration.
+       (emacs-lisp-mode-hook): Don't tweak in Emacs≥25.
+
+2015-04-24  Glenn Morris  <address@hidden>
+
+       * lisp/textmodes/text-mode.el (text-mode-hook):
+       Move text-mode-hook-identify to default.
+
+       * lisp/mouse.el (minor-mode-menu-from-indicator):
+       Handle non-function members of minor-mode-map-alist.  (Bug#20201)
+
+       * lisp/help-fns.el (describe-function): More type checking.
+       (describe-function-1): Handle changed symbol-function.  (Bug#20201)
+
+       * build-aux/gitlog-to-emacslog: Convert "Fixes:" to "(Bug#)".
+       (Bug#20325)
+
+2015-04-24  Andreas Schwab  <address@hidden>
+
+       shr: strip leading whitespace when expanding URLs
+       * lisp/net/shr.el (shr-expand-url): Strip leading whitespace from URL.
+
+2015-04-24  Eli Zaretskii  <address@hidden>
+
+       Clarify "co-authored" some more
+
+       * CONTRIBUTE: Clarify "co-authored-by".  (Bug#20400)
+
+       Clarify doc strings of functions that search for properties
+       * src/textprop.c (Fnext_char_property_change)
+       (Fprevious_char_property_change)
+       (Fnext_single_char_property_change)
+       (Fprevious_single_char_property_change, Fnext_property_change)
+       (Fnext_single_property_change, Fprevious_property_change)
+       (Fprevious_single_property_change): Clarify doc strings wrt return
+       value and the optional LIMIT argument.  (Bug#20411)
+
+2015-04-24  Glenn Morris  <address@hidden>
+
+       * test/automated/message-mode-tests.el (message-mode-propertize):
+       Handle non-writable HOME; eg on hydra.nixos.org.
+
+2015-04-23  Eli Zaretskii  <address@hidden>
+
+       Avoid starting threads by w32-shell-execute
+       * src/w32fns.c (Fw32_shell_execute): Convert "file:///" URLs into
+       local file names, before invoking ShellExecute.  (Bug#20220)
+
+2015-04-23  Martin Rudalics  <address@hidden>
+
+       Fix following doc-links in `widget-documentation-link-action'
+       * lisp/wid-edit.el (widget-documentation-link-action): Make
+       following doc-links less simplistic (Bug#20398).
+
+2015-04-22  Thomas Fitzsimmons  <address@hidden>
+
+       Improve EUDC manual
+       * eudc.texi (Troubleshooting): New LDAP troubleshooting subsection.
+
+2015-04-22  Paul Eggert  <address@hidden>
+
+       Omit needless "\ " after multibyte then newline
+       * src/print.c: Include <c-ctype.h>, for c_isxdigit.
+       (print_object): When print-escape-multibyte is non-nil and a
+       multibyte character is followed by a newline or formfeed, followed
+       by a hex digit, don't output a needless "\ " before the hex digit.
+       * test/automated/print-tests.el (print-hex-backslash): New test.
+
+2015-04-22  Oleh Krehel  <address@hidden>
+
+       Add a new `inhibit-message' variable
+       * src/xdisp.c (syms_of_xdisp): Define a boolean `inhibit_message'.
+       (message3): Don't call `message3_nolog' (i.e. use the Echo Area) when
+       `inhibit_message' is non-zero.
+       * etc/NEWS: Add an entry.
+       * doc/lispref/display.texi: Add an entry for `inhibit-message',
+         mention it in `message'.
+
+2015-04-22  Martin Rudalics  <address@hidden>
+
+       Fix last fix in `display-buffer-record-window'.
+       * lisp/window.el (display-buffer-record-window): Fix last fix.
+
+2015-04-22  Eli Zaretskii  <address@hidden>
+
+       Minor edits in CONTRIBUTE
+       * CONTRIBUTE: Rearrange instructions about log messages.
+       Use "Git" capitalized all over.
+       Use 2 spaces between sentences.
+
+2015-04-22  Artur Malabarba  <address@hidden>
+
+       * lisp/files.el (basic-save-buffer): Fix argument
+
+       * lisp/cus-edit.el (custom-file): Consider init-file-had-error
+       In case `(and (null custom-file) init-file-had-error)' do the same
+       thing we'd do if `(null user-init-file)', which is to either error out
+       or return nil.  This is in line with `custom-save-all' which would
+       throw an error in that situation. (bug#20355)
+
+       * lisp/emacs-lisp/package.el: Hide lower-priority packages in menu
+       (package-menu-hide-low-priority): New variable, see its doc.
+       (package-archive-priorities): Update doc.
+       (package-desc-priority): New function.
+       (package-desc-priority-version): Use it.
+       (package--remove-hidden): New function.
+       (package-menu--refresh): Use it.
+
+       * lisp/emacs-lisp/package.el: Implement displaying obsolete packages
+       (package-menu--hide-obsolete): New variable.
+       (package--remove-hidden): Use it.
+       (package-menu-hide-obsolete): New interactive function to toggle
+       the variable.
+       (package--quick-help-keys): Document it.
+       (package-menu-async): Add :version tag.
+       (package-menu-mode-map): Bind package-menu-hide-obsolete.
+       (package-desc-status): Indicate non-installed obsolete packages as
+       avail-obso.
+       (package-menu-mark-install): Allow installation of avail-obso.
+       (package-menu--status-predicate): Sort avail-obso with available.
+
+2015-04-22  Alan Mackenzie  <address@hidden>
+
+       On C-y, stop some text property entries being written into 
buffer-undo-list
+       lisp/subr.el (remove-yank-excluded-properties): enclose the code in
+       `with-silent-modifications'.
+
+2015-04-22  Martin Rudalics  <address@hidden>
+
+       In display-buffer-record-window record selected window if necessary.
+       * lisp/window.el (display-buffer-record-window): Store selected window
+       if it differs from 3rd element of 'quit-restore' parameter (Bug#20353).
+
+2015-04-22  Tassilo Horn  <address@hidden>
+
+       Fix reftex-citation bug
+       * reftex-cite.el (reftex-extract-bib-entries): Fix
+       `wrong-type-argument stringp nil' error that occurs when AUCTeX
+       integration is enabled and there are no citations in the document
+       so far.
+
+2015-04-21  Dmitry Gutov  <address@hidden>
+
+       Add or reset based on the presence of MERGE_HEAD
+       * lisp/vc/vc-git.el (vc-git-find-file-hook): Add
+       `vc-git-resolve-when-done' to `after-save-hook' in either case.
+       (vc-git-conflicted-files): Add a TODO.
+       (vc-git-resolve-when-done): Depending on the presence of
+       MERGE_HEAD, either update the resolved file in the index, or
+       remove it from there.  (Bug#20292)
+
+2015-04-21  Glenn Morris  <address@hidden>
+
+       * lisp/custom.el (custom-declare-group): No need to purecopy
+       custom-current-group-alist members following recent change to set
+       it to nil before dumping.
+
+       * build-aux/gitlog-to-emacslog: Get footer from ChangeLog.2.
+       (Bug#20399)
+
+2015-04-21  Daniel Colascione  <address@hidden>
+
+       Unbreak no-op buffer save message
+       * lisp/files.el (save-buffer): Pass interactive flag to 
`basic-save-buffer`
+       (basic-save-buffer): Accept called-interactively as an argument instead 
of
+       directly invoking called-interactively-p, which will always yield nil
+       in that context.
+
+2015-04-21  Alan Mackenzie  <address@hidden>
+
+       CC Mode: Do nothing in before/after-change-functions for text property 
changes
+       Fixes bug#20266.
+       lisp/progmodes/cc-mode.el (c-basic-common-init): Make
+       yank-handled-properties buffer local, and remove 'category from it.
+       (c-called-from-text-property-change-p): New function.
+       (c-before-change): Don't do anything if a call of the new function
+       returns non-nil.
+       (c-after-change): Don't do much if a call of the new function returns
+       non-nil.
+       (c-extend-after-change-region): Put changes to text property 'fontified
+       inside c-save-buffer-state.
+
+2015-04-20  Stefan Monnier  <address@hidden>
+
+       Fix byte-compiler warnings about looking-back.
+       * lisp/vc/log-view.el (log-view-end-of-defun-1):
+       * lisp/textmodes/tex-mode.el (latex-forward-sexp-1):
+       * lisp/textmodes/reftex-ref.el (reftex-goto-label):
+       * lisp/textmodes/bibtex.el (bibtex-insert-kill):
+       * lisp/progmodes/sh-script.el (sh--maybe-here-document):
+       * lisp/progmodes/ruby-mode.el (ruby-end-of-defun):
+       * lisp/progmodes/ada-mode.el (ada-in-numeric-literal-p):
+       * lisp/org/org.el (org-insert-heading, org-sort-entries):
+       * lisp/org/org-mouse.el (org-mouse-end-headline)
+       (org-mouse-context-menu):
+       * lisp/org/org-clock.el (org-clock-cancel):
+       * lisp/man.el (Man-default-man-entry):
+       * lisp/mail/rmail.el (rmail-get-new-mail, rmail-insert-inbox-text)
+       (rmail-ensure-blank-line):
+       * lisp/mail/footnote.el (Footnote-delete-footnote):
+       * lisp/mail/emacsbug.el (report-emacs-bug):
+       * lisp/info.el (Info-follow-reference, Info-fontify-node):
+       * lisp/info-look.el (info-lookup-guess-custom-symbol):
+       * lisp/help-fns.el (help-fns--key-bindings):
+       * lisp/files.el (hack-local-variables):
+       * lisp/emulation/viper-ex.el (viper-get-ex-token, ex-cmd-complete)
+       (viper-get-ex-pat, ex-expand-filsyms, viper-get-ex-file)
+       (viper-complete-filename-or-exit):
+       * lisp/emulation/viper-cmd.el (viper-backward-indent):
+       * lisp/emacs-lisp/lisp-mode.el (calculate-lisp-indent):
+       * lisp/emacs-lisp/elint.el (elint-get-top-forms):
+       * lisp/cus-edit.el (custom-face-edit-value-create):
+       * lisp/calendar/todo-mode.el (todo-set-item-priority)
+       (todo-filter-items-1, todo-convert-legacy-files)
+       (todo-prefix-overlays): Add explicit second arg to looking-back.
+
+2015-04-20  Glenn Morris  <address@hidden>
+
+       Avoid non-nil current-load-list at startup
+       * src/process.c (init_process_emacs): Move Fprovide statement...
+       (syms_of_process): ... to here.
+
+       * lisp/loadup.el (custom-current-group-alist): Reset before dumping.
+
+       * lisp/startup.el (command-line) <site-run-file>: Avoid rogue value in 
emacs -Q.
+
+2015-04-20  Ludovic Courtès  <address@hidden>
+
+       * lisp/loadup.el (exec-path): Avoid storing build-time PATH in binary.
+       (Bug#20330)
+
+2015-04-20  Glenn Morris  <address@hidden>
+
+       * lisp/cus-start.el (exec-path): Set standard value, to avoid rogue.
+
+       Tweak exec-path in uninstalled case
+       * src/callproc.c (init_callproc): If running uninstalled, do not
+       include eventual installation libexec directory in exec-path.
+
+2015-04-20  Artur Malabarba  <address@hidden>
+
+       * lisp/emacs-lisp/package.el: Filter by multiple keywords and cache 
keywords
+       (package-menu-filter): Accept a list of keywords.
+       (package--all-keywords): New variable to cache known keywords.
+       (package-all-keywords): Populate it if necessary.
+       (package-refresh-contents): Reset it.
+
+       * lisp/emacs-lisp/package.el: Make archive and status pseudo-keywords
+       (package--has-keyword-p): Understand "arc:xxxx" and "status:xxxx"
+       as special keywords which match agains package archive and status
+       respectively.
+       * etc/NEWS: Document it.
+
+2015-04-20  Eli Zaretskii  <address@hidden>
+
+       Describe and index "empty overlays".
+       * doc/lispref/display.texi (Overlays): Improve indexing.
+       (Managing Overlays): Describe "empty" overlays.
+       (Overlay Properties, Finding Overlays): Add cross-reference to
+       where empty overlays are described.
+
+2015-04-19  Paul Eggert  <address@hidden>
+
+       Spelling fixes
+
+       Quote 'like this' in top-level files
+       * CONTRIBUTE, INSTALL, Makefile.in, README, configure.ac, make-dist:
+       Prefer to single-quote 'like this' (instead of the older style
+       `like this').
+       * configure.ac: Fix some space-before-tab problems that 'git commit'
+       complained about.
+
+       Use bool for boolean in textprop.c, undo.c
+       * src/textprop.c (soft, hard): Now constants instead of macros.
+       (validate_plist): Rewrite to avoid need for boolean local.
+       (interval_has_all_properties, interval_has_some_properties)
+       (interval_has_some_properties_list, add_properties)
+       (remove_properties, get_char_property_and_overlay)
+       (Fnext_single_char_property_change)
+       (Fprevious_single_char_property_change, add_text_properties_1)
+       (Fremove_text_properties, Fremove_list_of_text_properties)
+       (copy_text_properties):
+       * src/tparam.c (tparam1):
+       * src/undo.c (record_change, record_property_change)
+       (syms_of_undo):
+       Use 'true' and 'false' for booleans.
+
+2015-04-19  Dmitry Gutov  <address@hidden>
+
+       Call `smerge-start-session' even when dealing with a stash conflict
+       * lisp/vc/vc-git.el (vc-git-find-file-hook):
+       Call `smerge-start-session' even when dealing with a stash
+       conflict (bug#20292).
+
+2015-04-19  Vibhav Pant  <address@hidden>
+
+       Add option to eshell/clear to clear scrollback.
+       * lisp/eshell/esh-mode.el (eshell/clear-scrollback): New function.
+       (eshell/clear): Add an optional SCROLLBACK argument. If non-nil,
+       scrollback contents are cleared.
+       * etc/NEWS: Describe change.
+       * doc/misc/eshell.texi: Add entry for `clear'.
+
+2015-04-19  Paul Eggert  <address@hidden>
+
+       * src/widget.c (set_frame_size): Prefer 'int' to 'unsigned'
+       where either will do.
+
+2015-04-19  Steve Purcell  <address@hidden>
+
+       Assume package archive-contents are UTF8-encoded
+       * lisp/emacs-lisp/package.el (package--read-archive-file):
+       Set `coding-system-for-read' explicitly to 'utf-8 when reading the
+       downloaded and cached archive-contents files, so that non-ASCII
+       characters in package descriptions are displayed correctly in the
+       `list-packages' menu. (Bug#20231)
+
+2015-04-19  Dmitry Gutov  <address@hidden>
+
+       Abort when looking at stashed changes
+       * lisp/vc/vc-git.el (vc-git-find-file-hook): Abort when looking at
+       stashed changes (bug#20292).
+
+2015-04-19  Paul Eggert  <address@hidden>
+
+       Refactor low-level printing for simplicity
+       * src/print.c (PRINTDECLARE): Remove.  Move its contents into
+       PRINTPREPARE; doable now that we assume C99.  All callers changed.
+       (PRINTCHAR): Remove, as it adds more mystery than clarity.
+       All callers changed.
+       (strout): Assume that caller computes length.  All callers changed.
+       (print_c_string): New function.
+       (write_string, write_string_1): Compute length instead of asking
+       the caller to compute it.  All callers changed.
+       (write_string): Simplify by using write_string_1.
+       (write_string_1): Simplify by using print_c_string.
+       (Fterpri): Compute default val more clearly.
+       (Fprin1_to_string, print_object):
+       Assume C99 to avoid unnecessary nesting.
+       (print_object): Prefer print_c_string to multiple printchar, or
+       to calling strout with -1 length.  Coalesce into sprintf when
+       this is easy.
+
 2015-04-18  Paul Eggert  <address@hidden>
 
        Prefer "Bug#1234" in commit messages (Bug#20325)
@@ -1222,6 +1662,10 @@
 
 See ChangeLog.1 for earlier changes.
 
+;; Local Variables:
+;; coding: utf-8
+;; End:
+
   Copyright (C) 2015 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
@@ -1238,7 +1682,3 @@ See ChangeLog.1 for earlier changes.
 
   You should have received a copy of the GNU General Public License
   along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;; Local Variables:
-;; coding: utf-8
-;; End:
diff --git a/Makefile.in b/Makefile.in
index ff8dbf3..f88a9c5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1092,7 +1092,7 @@ bootstrap: bootstrap-clean
 .PHONY: master-branch-is-current no-ChangeLog unchanged-history-files
 
 # The newest revision that should not appear in the generated ChangeLog.
-gen_origin = 870287327b1fba7105599eeabac5a2aa5ebadf19
+gen_origin = 2c1b8604946efbcd8ec5dd6c6dda7541ce4fc3c0
 
 # Convert git commit log to ChangeLog file.  make-dist uses this.
 ChangeLog:
diff --git a/build-aux/gitlog-to-emacslog b/build-aux/gitlog-to-emacslog
index a523d86..996f6d0 100755
--- a/build-aux/gitlog-to-emacslog
+++ b/build-aux/gitlog-to-emacslog
@@ -4,6 +4,8 @@
 
 # Copyright (C) 2014-2015 Free Software Foundation, Inc.
 
+# Author: Paul Eggert
+
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
@@ -17,8 +19,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Written by Paul Eggert
-
 LC_ALL=C
 export LC_ALL
 
@@ -34,10 +34,19 @@ test -d ${srcprefix}.git || {
 
 # Use Gnulib's packaged ChangeLog generator.
 ${srcprefix}build-aux/gitlog-to-changelog --ignore-matching='^; ' \
+  --format='%B' \
   "$gen_origin.." >"${distprefix}ChangeLog.tmp" || exit
 
 if test -s "${distprefix}ChangeLog.tmp"; then
 
+  # Fix up bug references.
+  # This would be better as eg a --transform option to gitlog-to-changelog,
+  # but... effort.  FIXME does not handle rare cases like:
+  # Fixes: debbugs:19434 debbugs:19519
+  sed 's/      Fixes: \(debbugs:\|bug#\)\([0-9][0-9]*\)/       (Bug#\2)/' \
+      "${distprefix}ChangeLog.tmp" > "${distprefix}ChangeLog.tmp2"
+  mv "${distprefix}ChangeLog.tmp2" "${distprefix}ChangeLog.tmp"
+
   # Find the years covered by the generated ChangeLog, so that
   # a proper copyright notice can be output.
   years=`
@@ -65,7 +74,7 @@ if test -s "${distprefix}ChangeLog.tmp"; then
        s/\(Copyright[ (C)]*\)[0-9]*-[0-9]*/\1'"$year_range"'/
        p
     }
-  ' <ChangeLog.1 >>"${distprefix}ChangeLog.tmp" || exit
+  ' <ChangeLog.2 >>"${distprefix}ChangeLog.tmp" || exit
 fi
 
 # Install the generated ChangeLog.
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index e2a38b6..d5d9bb5 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -257,6 +257,9 @@ text properties (@pxref{Logging Messages}).
 In batch mode, the message is printed to the standard error stream,
 followed by a newline.
 
+When @code{inhibit-message} is address@hidden, no message will be displayed
+in the echo area, it will only be logged to @samp{*Messages*}.
+
 If @var{format-string} is @code{nil} or the empty string,
 @code{message} clears the echo area; if the echo area has been
 expanded automatically, this brings it back to its normal size.  If
@@ -282,6 +285,11 @@ To automatically display a message in the echo area or in 
a pop-buffer,
 depending on its size, use @code{display-message-or-buffer} (see below).
 @end defun
 
address@hidden inhibit-message
+When this variable is address@hidden, @code{message} and related functions
+will not use the Echo Area to display messages.
address@hidden defvar
+
 @defmac with-temp-message message &rest body
 This construct displays a message in the echo area temporarily, during
 the execution of @var{body}.  It displays @var{message}, executes
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi
index e1330f7..b48fae4 100644
--- a/doc/lispref/sequences.texi
+++ b/doc/lispref/sequences.texi
@@ -790,7 +790,7 @@ of type @var{type}.  @var{type} can be one of the following 
symbols:
 @end example
 @end defun
 
address@hidden seq-doseq (var sequence [result]) address@hidden
address@hidden seq-doseq (var sequence) address@hidden
 @cindex sequence iteration
   This macro is like @code{dolist}, except that @var{sequence} can be a list,
 vector or string (@pxref{Iteration} for more information about the
diff --git a/doc/misc/eudc.texi b/doc/misc/eudc.texi
index 4d6e6ad..064f570 100644
--- a/doc/misc/eudc.texi
+++ b/doc/misc/eudc.texi
@@ -248,7 +248,7 @@ Pass any required extra options to @command{ldapsearch} 
using
 @end itemize
 
 The following examples use a base of
address@hidden,dc=example,dc=com} and the host name
address@hidden,dc=gnu,dc=org} and the host name
 @code{ldap.gnu.org}, a server that supports LDAP-over-SSL (the
 @code{ldaps} protocol, with default port @code{636}) and which
 requires authentication by the user @code{emacsuser} with password
@@ -274,6 +274,7 @@ the wildcard character to the end of the last word.
 @menu
 * Emacs-only Configuration::    Configure with @file{.emacs}
 * External Configuration::      Configure with @file{/etc/openldap/ldap.conf}
+* Troubleshooting::             Debug @command{ldapsearch} failures
 @end menu
 
 @node Emacs-only Configuration
@@ -305,8 +306,8 @@ LDAP:
                           ("ldaps://ldap.gnu.org" . ldap)))
 (customize-set-variable 'ldap-host-parameters-alist
                         '(("ldaps://ldap.gnu.org"
-                           base "ou=people,dc=example,dc=com"
-                           binddn "example\\emacsuser"
+                           base "ou=people,dc=gnu,dc=org"
+                           binddn "gnu\\emacsuser"
                            passwd ldap-password-read)))
 @end lisp
 
@@ -330,7 +331,7 @@ Your system may already be configured for a default LDAP 
server.  For
 example, @file{/etc/openldap/ldap.conf} might contain:
 
 @example
-BASE ou=people,dc=example,dc=com
+BASE ou=people,dc=gnu,dc=org
 URI ldaps://ldap.gnu.org
 TLS_CACERTDIR /etc/openldap/certs
 @end example
@@ -339,11 +340,11 @@ TLS_CACERTDIR /etc/openldap/certs
 @cindex binddn
 Authentication requires a password, and a @dfn{bind distinguished name
 (binddn)} representing the user, in this case,
address@hidden  These can be specified in
address@hidden  These can be specified in
 @file{~/.authinfo.gpg} with the following line:
 
 @example
-machine ldaps://ldap.gnu.org binddn example\emacsuser password s3cr3t
+machine ldaps://ldap.gnu.org binddn gnu\emacsuser password s3cr3t
 @end example
 
 Then in the @file{.emacs} init file, these expressions suffice to
@@ -372,7 +373,7 @@ case @command{ldapsearch} defaults to the host name in
 The @file{~/.authinfo.gpg} line becomes:
 
 @example
-binddn example\emacsuser password s3cr3t
+binddn gnu\emacsuser password s3cr3t
 @end example
 
 @noindent
@@ -391,6 +392,23 @@ and the @file{.emacs} expressions become:
                         '(("" auth-source t)))
 @end lisp
 
address@hidden Troubleshooting
address@hidden Troubleshooting
+
+If @command{ldapsearch} exits with an error, you'll see a message like
+this in the @code{*Messages*} buffer (all on one line):
+
address@hidden
+ldap-search-internal: Failed ldapsearch invocation:
+   ldapsearch "-Hldaps://ldap.gnu.org" "-bou=people,dc=gnu,dc=org"
+   "-Dgnu\emacsuser" "-W" "-LL" "-tt" "(&(mail=name*))"
+   "givenname" "sn" "mail"
address@hidden example
+
+The @command{ldapsearch} command is formatted such that it can be
+copied and pasted into a terminal.  Set the @command{ldapsearch} debug
+level to 5 by appending @code{-d 5} to the command line.
+
 @node Usage
 @chapter Usage
 
diff --git a/etc/NEWS b/etc/NEWS
index 804b819..5046d30 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -200,6 +200,11 @@ font, and (iii) the specified window.
 
 ** New possible value for `system-type': nacl.
 
++++
+** New variable `inhibit-message', when bound to non-nil, inhibits
+   `message' and related functions from displaying messages the Echo
+   Area.  The output is still logged to the *Messages* buffer.
+
 
 * Editing Changes in Emacs 25.1
 
@@ -232,6 +237,13 @@ Unicode standards.
 
 
 * Changes in Specialized Modes and Packages in Emacs 25.1
+
+** The `save-place' variable is replaced by a `save-place-mode'.
+
+** Midnight-mode
+*** `midnight-mode' is a proper minor mode.
+*** clean-buffer-*-regexps can now specify buffers via predicate functions.
+
 ** In xterms, killing text now also sets the CLIPBOARD/PRIMARY selection
 in the surrounding GUI (using the OSC-52 escape sequence).  This only works
 if your xterm supports it and enables the `allowWindowOps' options (disabled
@@ -241,6 +253,17 @@ by default at least in Debian, for security reasons).
 
 ** package.el
 
+*** If a package is available on multiple archives and one has higher
+priority (as per `package-archive-priorities') only that one is
+listed. This can be configured with `package-menu-hide-low-priority'.
+
+*** `package-menu-hide-obsolete' now toggles the hiding of packages.
+This includes the above-mentioned low-priority packages, as well as
+available packages whose version is lower than the currently installed
+version (which were previously impossible to display).
+This allows users to downgrade a package if a lower version is
+available.
+
 *** When filtering the package menu, keywords starting with "arc:" or
 "status:" represent package archive or status, respectively, instead
 of actual keywords.
@@ -610,6 +633,9 @@ to avoid interfering with the kill ring.
 *** Custom variable `eudc-inline-expansion-format' defaults to
 "Firstname Surname <mail-address>".
 
+*** Custom variable `eudc-options-file' defaults to
+"~/.emacs.d/eudc-options".
+
 *** New custom variable `ldap-ldapsearch-password-prompt-regexp' to
 allow overriding the regular expression that recognizes the ldapsearch
 command line's password prompt.
diff --git a/etc/themes/tsdh-light-theme.el b/etc/themes/tsdh-light-theme.el
index f85f2ba..6555e49 100644
--- a/etc/themes/tsdh-light-theme.el
+++ b/etc/themes/tsdh-light-theme.el
@@ -25,6 +25,8 @@ Used and created by Tassilo Horn.")
 
 (custom-theme-set-faces
  'tsdh-light
+ '(Info-quoted ((t (:weight bold))))
+ '(ace-jump-face-foreground ((t (:foreground "DeepPink" :box (:line-width -1 
:color "grey75") :weight bold))))
  '(default ((t (:background "white" :foreground "black"))))
  '(diff-added ((t (:inherit diff-changed :background "light green"))))
  '(diff-changed ((t (:background "light steel blue"))))
@@ -48,6 +50,7 @@ Used and created by Tassilo Horn.")
  '(gnus-group-news-3 ((t (:inherit gnus-group-news-3-empty :weight bold))))
  '(gnus-group-news-3-empty ((t (:foreground "tomato2")))) '(header-line ((t 
(:inherit mode-line :inverse-video t))))
  '(hl-line ((t (:background "grey95"))))
+ '(hl-paren-face ((t (:weight bold))) t)
  '(minibuffer-prompt ((t (:background "yellow" :foreground "medium blue" :box 
(:line-width -1 :color "red" :style released-button) :weight bold))))
  '(mode-line ((t (:background "wheat" :foreground "black" :box (:line-width 1 
:color "tan") :family "DejaVu Sans"))))
  '(mode-line-inactive ((t (:inherit mode-line :foreground "dark gray"))))
@@ -75,8 +78,8 @@ Used and created by Tassilo Horn.")
  '(outline-8 ((t (:inherit font-lock-string-face :weight bold))))
  '(rcirc-my-nick ((t (:foreground "LightSkyBlue" :weight bold))))
  '(region ((t (:background "lightgoldenrod1"))))
- '(show-paren-match ((t (:background "LightCyan2"))))
- '(show-paren-mismatch ((t (:background "deep pink"))))
+ '(show-paren-match ((t (:background "Cyan1" :weight bold))))
+ '(show-paren-mismatch ((t (:background "deep pink" :weight bold))))
  '(window-number-face ((t (:foreground "red" :weight bold)))))
 
 (provide-theme 'tsdh-light)
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index d16c9ae..5c1e9d9 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -1241,7 +1241,7 @@ dump_sym (FILE *fp, struct sym *root)
     putstr (NULL, fp);
 
   /* Print flags.  */
-  fprintf (fp, "%u", root->flags);
+  fprintf (fp, "%d", root->flags);
   putstr (root->filename, fp);
   putstr (root->regexp, fp);
   fprintf (fp, "%u", (unsigned) root->pos);
diff --git a/lib-src/hexl.c b/lib-src/hexl.c
index 490f727..ac493c2 100644
--- a/lib-src/hexl.c
+++ b/lib-src/hexl.c
@@ -216,7 +216,7 @@ main (int argc, char **argv)
                  else
                    {
                      if (!i)
-                       printf ("%08lx: ", address);
+                       printf ("%08lx: ", address + 0ul);
 
                      if (iso_flag)
                        string[i+1] =
@@ -224,7 +224,7 @@ main (int argc, char **argv)
                      else
                        string[i+1] = (c < 0x20 || c >= 0x7F) ? '.' : c;
 
-                     printf ("%02x", c);
+                     printf ("%02x", c + 0u);
                    }
 
                  if ((i&group_by) == group_by)
diff --git a/lib/acl-internal.c b/lib/acl-internal.c
new file mode 100644
index 0000000..d9bd446
--- /dev/null
+++ b/lib/acl-internal.c
@@ -0,0 +1,469 @@
+/* Test whether a file has a nontrivial access control list.
+
+   Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+   Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible.  */
+
+#include <config.h>
+
+#include "acl.h"
+
+#include "acl-internal.h"
+
+#if USE_ACL && HAVE_ACL_GET_FILE
+
+# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
+
+/* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED.
+   Return 1 if the given ACL is non-trivial.
+   Return 0 if it is trivial.  */
+int
+acl_extended_nontrivial (acl_t acl)
+{
+  /* acl is non-trivial if it is non-empty.  */
+  return (acl_entries (acl) > 0);
+}
+
+# else /* Linux, FreeBSD, IRIX, Tru64 */
+
+/* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS.
+   Return 1 if the given ACL is non-trivial.
+   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.
+   Return -1 and set errno upon failure to determine it.  */
+int
+acl_access_nontrivial (acl_t acl)
+{
+  /* acl is non-trivial if it has some entries other than for "user::",
+     "group::", and "other::".  Normally these three should be present
+     at least, allowing us to write
+        return (3 < acl_entries (acl));
+     but the following code is more robust.  */
+#  if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD */
+
+  acl_entry_t ace;
+  int got_one;
+
+  for (got_one = acl_get_entry (acl, ACL_FIRST_ENTRY, &ace);
+       got_one > 0;
+       got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace))
+    {
+      acl_tag_t tag;
+      if (acl_get_tag_type (ace, &tag) < 0)
+        return -1;
+      if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER))
+        return 1;
+    }
+  return got_one;
+
+#  elif HAVE_ACL_TO_SHORT_TEXT /* IRIX */
+  /* Don't use acl_get_entry: it is undocumented.  */
+
+  int count = acl->acl_cnt;
+  int i;
+
+  for (i = 0; i < count; i++)
+    {
+      acl_entry_t ace = &acl->acl_entry[i];
+      acl_tag_t tag = ace->ae_tag;
+
+      if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ
+            || tag == ACL_OTHER_OBJ))
+        return 1;
+    }
+  return 0;
+
+#  elif HAVE_ACL_FREE_TEXT /* Tru64 */
+  /* Don't use acl_get_entry: it takes only one argument and does not work.  */
+
+  int count = acl->acl_num;
+  acl_entry_t ace;
+
+  for (ace = acl->acl_first; count > 0; ace = ace->next, count--)
+    {
+      acl_tag_t tag;
+      acl_perm_t perm;
+
+      tag = ace->entry->acl_type;
+      if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER))
+        return 1;
+
+      perm = ace->entry->acl_perm;
+      /* On Tru64, perm can also contain non-standard bits such as
+         PERM_INSERT, PERM_DELETE, PERM_MODIFY, PERM_LOOKUP, ... */
+      if ((perm & ~(ACL_READ | ACL_WRITE | ACL_EXECUTE)) != 0)
+        return 1;
+    }
+  return 0;
+
+#  else
+
+  errno = ENOSYS;
+  return -1;
+#  endif
+}
+
+# endif
+
+#elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
+
+/* Test an ACL retrieved with GETACL.
+   Return 1 if the given ACL, consisting of COUNT entries, is non-trivial.
+   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
+int
+acl_nontrivial (int count, aclent_t *entries)
+{
+  int i;
+
+  for (i = 0; i < count; i++)
+    {
+      aclent_t *ace = &entries[i];
+
+      /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat().
+         If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat().
+         We don't need to check ace->a_id in these cases.  */
+      if (!(ace->a_type == USER_OBJ
+            || ace->a_type == GROUP_OBJ
+            || ace->a_type == OTHER_OBJ
+            /* Note: Cygwin does not return a CLASS_OBJ ("mask:") entry
+               sometimes.  */
+            || ace->a_type == CLASS_OBJ))
+        return 1;
+    }
+  return 0;
+}
+
+# ifdef ACE_GETACL
+
+/* A shortcut for a bitmask.  */
+#  define NEW_ACE_WRITEA_DATA (NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA)
+
+/* Test an ACL retrieved with ACE_GETACL.
+   Return 1 if the given ACL, consisting of COUNT entries, is non-trivial.
+   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
+int
+acl_ace_nontrivial (int count, ace_t *entries)
+{
+  int i;
+
+  /* The flags in the ace_t structure changed in a binary incompatible way
+     when ACL_NO_TRIVIAL etc. were introduced in <sys/acl.h> version 1.15.
+     How to distinguish the two conventions at runtime?
+     In the old convention, usually three ACEs have a_flags = ACE_OWNER /
+     ACE_GROUP / ACE_OTHER, in the range 0x0100..0x0400.  In the new
+     convention, these values are not used.  */
+  int old_convention = 0;
+
+  for (i = 0; i < count; i++)
+    if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER))
+      {
+        old_convention = 1;
+        break;
+      }
+
+  if (old_convention)
+    /* Running on Solaris 10.  */
+    for (i = 0; i < count; i++)
+      {
+        ace_t *ace = &entries[i];
+
+        /* Note:
+           If ace->a_flags = ACE_OWNER, ace->a_who is the st_uid from stat().
+           If ace->a_flags = ACE_GROUP, ace->a_who is the st_gid from stat().
+           We don't need to check ace->a_who in these cases.  */
+        if (!(ace->a_type == OLD_ALLOW
+              && (ace->a_flags == OLD_ACE_OWNER
+                  || ace->a_flags == OLD_ACE_GROUP
+                  || ace->a_flags == OLD_ACE_OTHER)))
+          return 1;
+      }
+  else
+    {
+      /* Running on Solaris 10 (newer version) or Solaris 11.  */
+      unsigned int access_masks[6] =
+        {
+          0, /* owner@ deny */
+          0, /* owner@ allow */
+          0, /* group@ deny */
+          0, /* group@ allow */
+          0, /* everyone@ deny */
+          0  /* everyone@ allow */
+        };
+
+      for (i = 0; i < count; i++)
+        {
+          ace_t *ace = &entries[i];
+          unsigned int index1;
+          unsigned int index2;
+
+          if (ace->a_type == NEW_ACE_ACCESS_ALLOWED_ACE_TYPE)
+            index1 = 1;
+          else if (ace->a_type == NEW_ACE_ACCESS_DENIED_ACE_TYPE)
+            index1 = 0;
+          else
+            return 1;
+
+          if (ace->a_flags == NEW_ACE_OWNER)
+            index2 = 0;
+          else if (ace->a_flags == (NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP))
+            index2 = 2;
+          else if (ace->a_flags == NEW_ACE_EVERYONE)
+            index2 = 4;
+          else
+            return 1;
+
+          access_masks[index1 + index2] |= ace->a_access_mask;
+        }
+
+      /* The same bit shouldn't be both allowed and denied.  */
+      if (access_masks[0] & access_masks[1])
+        return 1;
+      if (access_masks[2] & access_masks[3])
+        return 1;
+      if (access_masks[4] & access_masks[5])
+        return 1;
+
+      /* Check minimum masks.  */
+      if ((NEW_ACE_WRITE_NAMED_ATTRS
+           | NEW_ACE_WRITE_ATTRIBUTES
+           | NEW_ACE_WRITE_ACL
+           | NEW_ACE_WRITE_OWNER)
+          & ~ access_masks[1])
+        return 1;
+      access_masks[1] &= ~(NEW_ACE_WRITE_NAMED_ATTRS
+                           | NEW_ACE_WRITE_ATTRIBUTES
+                           | NEW_ACE_WRITE_ACL
+                           | NEW_ACE_WRITE_OWNER);
+      if ((NEW_ACE_READ_NAMED_ATTRS
+           | NEW_ACE_READ_ATTRIBUTES
+           | NEW_ACE_READ_ACL
+           | NEW_ACE_SYNCHRONIZE)
+          & ~ access_masks[5])
+        return 1;
+      access_masks[5] &= ~(NEW_ACE_READ_NAMED_ATTRS
+                           | NEW_ACE_READ_ATTRIBUTES
+                           | NEW_ACE_READ_ACL
+                           | NEW_ACE_SYNCHRONIZE);
+
+      /* Check the allowed or denied bits.  */
+      switch ((access_masks[0] | access_masks[1])
+              & ~(NEW_ACE_READ_NAMED_ATTRS
+                  | NEW_ACE_READ_ATTRIBUTES
+                  | NEW_ACE_READ_ACL
+                  | NEW_ACE_SYNCHRONIZE))
+        {
+        case 0:
+        case NEW_ACE_READ_DATA:
+        case                     NEW_ACE_WRITEA_DATA:
+        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA:
+        case                                           NEW_ACE_EXECUTE:
+        case NEW_ACE_READ_DATA |                       NEW_ACE_EXECUTE:
+        case                     NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
+        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
+          break;
+        default:
+          return 1;
+        }
+      switch ((access_masks[2] | access_masks[3])
+              & ~(NEW_ACE_READ_NAMED_ATTRS
+                  | NEW_ACE_READ_ATTRIBUTES
+                  | NEW_ACE_READ_ACL
+                  | NEW_ACE_SYNCHRONIZE))
+        {
+        case 0:
+        case NEW_ACE_READ_DATA:
+        case                     NEW_ACE_WRITEA_DATA:
+        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA:
+        case                                           NEW_ACE_EXECUTE:
+        case NEW_ACE_READ_DATA |                       NEW_ACE_EXECUTE:
+        case                     NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
+        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
+          break;
+        default:
+          return 1;
+        }
+      switch ((access_masks[4] | access_masks[5])
+              & ~(NEW_ACE_WRITE_NAMED_ATTRS
+                  | NEW_ACE_WRITE_ATTRIBUTES
+                  | NEW_ACE_WRITE_ACL
+                  | NEW_ACE_WRITE_OWNER))
+        {
+        case 0:
+        case NEW_ACE_READ_DATA:
+        case                     NEW_ACE_WRITEA_DATA:
+        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA:
+        case                                           NEW_ACE_EXECUTE:
+        case NEW_ACE_READ_DATA |                       NEW_ACE_EXECUTE:
+        case                     NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
+        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
+          break;
+        default:
+          return 1;
+        }
+
+      /* Check that the NEW_ACE_WRITE_DATA and NEW_ACE_APPEND_DATA bits are
+         either both allowed or both denied.  */
+      if (((access_masks[0] & NEW_ACE_WRITE_DATA) != 0)
+          != ((access_masks[0] & NEW_ACE_APPEND_DATA) != 0))
+        return 1;
+      if (((access_masks[2] & NEW_ACE_WRITE_DATA) != 0)
+          != ((access_masks[2] & NEW_ACE_APPEND_DATA) != 0))
+        return 1;
+      if (((access_masks[4] & NEW_ACE_WRITE_DATA) != 0)
+          != ((access_masks[4] & NEW_ACE_APPEND_DATA) != 0))
+        return 1;
+    }
+
+  return 0;
+}
+
+# endif
+
+#elif USE_ACL && HAVE_GETACL /* HP-UX */
+
+/* Return 1 if the given ACL is non-trivial.
+   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
+int
+acl_nontrivial (int count, struct acl_entry *entries)
+{
+  int i;
+
+  if (count > 3)
+    return 1;
+
+  for (i = 0; i < count; i++)
+    {
+      struct acl_entry *ace = &entries[i];
+
+      if (ace->uid != ACL_NSUSER && ace->gid != ACL_NSGROUP)
+       return 1;
+    }
+  return 0;
+}
+
+# if HAVE_ACLV_H /* HP-UX >= 11.11 */
+
+/* Return 1 if the given ACL is non-trivial.
+   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
+int
+aclv_nontrivial (int count, struct acl *entries)
+{
+  int i;
+
+  for (i = 0; i < count; i++)
+    {
+      struct acl *ace = &entries[i];
+
+      /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat().
+         If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat().
+         We don't need to check ace->a_id in these cases.  */
+      if (!(ace->a_type == USER_OBJ /* no need to check ace->a_id here */
+            || ace->a_type == GROUP_OBJ /* no need to check ace->a_id here */
+            || ace->a_type == CLASS_OBJ
+            || ace->a_type == OTHER_OBJ))
+        return 1;
+    }
+  return 0;
+}
+
+# endif
+
+#elif USE_ACL && (HAVE_ACLX_GET || HAVE_STATACL) /* AIX */
+
+/* Return 1 if the given ACL is non-trivial.
+   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
+int
+acl_nontrivial (struct acl *a)
+{
+  /* The normal way to iterate through an ACL is like this:
+       struct acl_entry *ace;
+       for (ace = a->acl_ext; ace != acl_last (a); ace = acl_nxt (ace))
+         {
+           struct ace_id *aei;
+           switch (ace->ace_type)
+             {
+             case ACC_PERMIT:
+             case ACC_DENY:
+             case ACC_SPECIFY:
+               ...;
+             }
+           for (aei = ace->ace_id; aei != id_last (ace); aei = id_nxt (aei))
+             ...
+         }
+   */
+  return (acl_last (a) != a->acl_ext ? 1 : 0);
+}
+
+# if HAVE_ACLX_GET && defined ACL_AIX_WIP /* newer AIX */
+
+/* Return 1 if the given ACL is non-trivial.
+   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
+int
+acl_nfs4_nontrivial (nfs4_acl_int_t *a)
+{
+#  if 1 /* let's try this first */
+  return (a->aclEntryN > 0 ? 1 : 0);
+#  else
+  int count = a->aclEntryN;
+  int i;
+
+  for (i = 0; i < count; i++)
+    {
+      nfs4_ace_int_t *ace = &a->aclEntry[i];
+
+      if (!((ace->flags & ACE4_ID_SPECIAL) != 0
+            && (ace->aceWho.special_whoid == ACE4_WHO_OWNER
+                || ace->aceWho.special_whoid == ACE4_WHO_GROUP
+                || ace->aceWho.special_whoid == ACE4_WHO_EVERYONE)
+            && ace->aceType == ACE4_ACCESS_ALLOWED_ACE_TYPE
+            && ace->aceFlags == 0
+            && (ace->aceMask & ~(ACE4_READ_DATA | ACE4_LIST_DIRECTORY
+                                 | ACE4_WRITE_DATA | ACE4_ADD_FILE
+                                 | ACE4_EXECUTE)) == 0))
+        return 1;
+    }
+  return 0;
+#  endif
+}
+
+# endif
+
+#elif USE_ACL && HAVE_ACLSORT /* NonStop Kernel */
+
+/* Test an ACL retrieved with ACL_GET.
+   Return 1 if the given ACL, consisting of COUNT entries, is non-trivial.
+   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
+int
+acl_nontrivial (int count, struct acl *entries)
+{
+  int i;
+
+  for (i = 0; i < count; i++)
+    {
+      struct acl *ace = &entries[i];
+
+      /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat().
+         If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat().
+         We don't need to check ace->a_id in these cases.  */
+      if (!(ace->a_type == USER_OBJ /* no need to check ace->a_id here */
+            || ace->a_type == GROUP_OBJ /* no need to check ace->a_id here */
+            || ace->a_type == CLASS_OBJ
+            || ace->a_type == OTHER_OBJ))
+        return 1;
+    }
+  return 0;
+}
+
+#endif
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 243ca32..9b9fae2 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -220,7 +220,7 @@ extern int acl_ace_nontrivial (int count, ace_t *entries) 
_GL_ATTRIBUTE_PURE;
 
 /* Return 1 if the given ACL is non-trivial.
    Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
-extern int acl_nontrivial (int count, struct acl_entry *entries, struct stat 
*sb);
+extern int acl_nontrivial (int count, struct acl_entry *entries);
 
 #  if HAVE_ACLV_H /* HP-UX >= 11.11 */
 
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
deleted file mode 100644
index 2ef4e8b..0000000
--- a/lib/file-has-acl.c
+++ /dev/null
@@ -1,919 +0,0 @@
-/* Test whether a file has a nontrivial access control list.
-
-   Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-   Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible.  */
-
-/* Without this pragma, gcc 4.7.0 20120126 may suggest that the
-   file_has_acl function might be candidate for attribute 'const'  */
-#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
-# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
-#endif
-
-#include <config.h>
-
-#include "acl.h"
-
-#include "acl-internal.h"
-
-
-#if USE_ACL && HAVE_ACL_GET_FILE
-
-# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
-
-/* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED.
-   Return 1 if the given ACL is non-trivial.
-   Return 0 if it is trivial.  */
-int
-acl_extended_nontrivial (acl_t acl)
-{
-  /* acl is non-trivial if it is non-empty.  */
-  return (acl_entries (acl) > 0);
-}
-
-# else /* Linux, FreeBSD, IRIX, Tru64 */
-
-/* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS.
-   Return 1 if the given ACL is non-trivial.
-   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.
-   Return -1 and set errno upon failure to determine it.  */
-int
-acl_access_nontrivial (acl_t acl)
-{
-  /* acl is non-trivial if it has some entries other than for "user::",
-     "group::", and "other::".  Normally these three should be present
-     at least, allowing us to write
-        return (3 < acl_entries (acl));
-     but the following code is more robust.  */
-#  if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD */
-
-  acl_entry_t ace;
-  int got_one;
-
-  for (got_one = acl_get_entry (acl, ACL_FIRST_ENTRY, &ace);
-       got_one > 0;
-       got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace))
-    {
-      acl_tag_t tag;
-      if (acl_get_tag_type (ace, &tag) < 0)
-        return -1;
-      if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER))
-        return 1;
-    }
-  return got_one;
-
-#  elif HAVE_ACL_TO_SHORT_TEXT /* IRIX */
-  /* Don't use acl_get_entry: it is undocumented.  */
-
-  int count = acl->acl_cnt;
-  int i;
-
-  for (i = 0; i < count; i++)
-    {
-      acl_entry_t ace = &acl->acl_entry[i];
-      acl_tag_t tag = ace->ae_tag;
-
-      if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ
-            || tag == ACL_OTHER_OBJ))
-        return 1;
-    }
-  return 0;
-
-#  elif HAVE_ACL_FREE_TEXT /* Tru64 */
-  /* Don't use acl_get_entry: it takes only one argument and does not work.  */
-
-  int count = acl->acl_num;
-  acl_entry_t ace;
-
-  for (ace = acl->acl_first; count > 0; ace = ace->next, count--)
-    {
-      acl_tag_t tag;
-      acl_perm_t perm;
-
-      tag = ace->entry->acl_type;
-      if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER))
-        return 1;
-
-      perm = ace->entry->acl_perm;
-      /* On Tru64, perm can also contain non-standard bits such as
-         PERM_INSERT, PERM_DELETE, PERM_MODIFY, PERM_LOOKUP, ... */
-      if ((perm & ~(ACL_READ | ACL_WRITE | ACL_EXECUTE)) != 0)
-        return 1;
-    }
-  return 0;
-
-#  else
-
-  errno = ENOSYS;
-  return -1;
-#  endif
-}
-
-# endif
-
-
-#elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
-
-/* Test an ACL retrieved with GETACL.
-   Return 1 if the given ACL, consisting of COUNT entries, is non-trivial.
-   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
-int
-acl_nontrivial (int count, aclent_t *entries)
-{
-  int i;
-
-  for (i = 0; i < count; i++)
-    {
-      aclent_t *ace = &entries[i];
-
-      /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat().
-         If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat().
-         We don't need to check ace->a_id in these cases.  */
-      if (!(ace->a_type == USER_OBJ
-            || ace->a_type == GROUP_OBJ
-            || ace->a_type == OTHER_OBJ
-            /* Note: Cygwin does not return a CLASS_OBJ ("mask:") entry
-               sometimes.  */
-            || ace->a_type == CLASS_OBJ))
-        return 1;
-    }
-  return 0;
-}
-
-# ifdef ACE_GETACL
-
-/* A shortcut for a bitmask.  */
-#  define NEW_ACE_WRITEA_DATA (NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA)
-
-/* Test an ACL retrieved with ACE_GETACL.
-   Return 1 if the given ACL, consisting of COUNT entries, is non-trivial.
-   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
-int
-acl_ace_nontrivial (int count, ace_t *entries)
-{
-  int i;
-
-  /* The flags in the ace_t structure changed in a binary incompatible way
-     when ACL_NO_TRIVIAL etc. were introduced in <sys/acl.h> version 1.15.
-     How to distinguish the two conventions at runtime?
-     In the old convention, usually three ACEs have a_flags = ACE_OWNER /
-     ACE_GROUP / ACE_OTHER, in the range 0x0100..0x0400.  In the new
-     convention, these values are not used.  */
-  int old_convention = 0;
-
-  for (i = 0; i < count; i++)
-    if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER))
-      {
-        old_convention = 1;
-        break;
-      }
-
-  if (old_convention)
-    /* Running on Solaris 10.  */
-    for (i = 0; i < count; i++)
-      {
-        ace_t *ace = &entries[i];
-
-        /* Note:
-           If ace->a_flags = ACE_OWNER, ace->a_who is the st_uid from stat().
-           If ace->a_flags = ACE_GROUP, ace->a_who is the st_gid from stat().
-           We don't need to check ace->a_who in these cases.  */
-        if (!(ace->a_type == OLD_ALLOW
-              && (ace->a_flags == OLD_ACE_OWNER
-                  || ace->a_flags == OLD_ACE_GROUP
-                  || ace->a_flags == OLD_ACE_OTHER)))
-          return 1;
-      }
-  else
-    {
-      /* Running on Solaris 10 (newer version) or Solaris 11.  */
-      unsigned int access_masks[6] =
-        {
-          0, /* owner@ deny */
-          0, /* owner@ allow */
-          0, /* group@ deny */
-          0, /* group@ allow */
-          0, /* everyone@ deny */
-          0  /* everyone@ allow */
-        };
-
-      for (i = 0; i < count; i++)
-        {
-          ace_t *ace = &entries[i];
-          unsigned int index1;
-          unsigned int index2;
-
-          if (ace->a_type == NEW_ACE_ACCESS_ALLOWED_ACE_TYPE)
-            index1 = 1;
-          else if (ace->a_type == NEW_ACE_ACCESS_DENIED_ACE_TYPE)
-            index1 = 0;
-          else
-            return 1;
-
-          if (ace->a_flags == NEW_ACE_OWNER)
-            index2 = 0;
-          else if (ace->a_flags == (NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP))
-            index2 = 2;
-          else if (ace->a_flags == NEW_ACE_EVERYONE)
-            index2 = 4;
-          else
-            return 1;
-
-          access_masks[index1 + index2] |= ace->a_access_mask;
-        }
-
-      /* The same bit shouldn't be both allowed and denied.  */
-      if (access_masks[0] & access_masks[1])
-        return 1;
-      if (access_masks[2] & access_masks[3])
-        return 1;
-      if (access_masks[4] & access_masks[5])
-        return 1;
-
-      /* Check minimum masks.  */
-      if ((NEW_ACE_WRITE_NAMED_ATTRS
-           | NEW_ACE_WRITE_ATTRIBUTES
-           | NEW_ACE_WRITE_ACL
-           | NEW_ACE_WRITE_OWNER)
-          & ~ access_masks[1])
-        return 1;
-      access_masks[1] &= ~(NEW_ACE_WRITE_NAMED_ATTRS
-                           | NEW_ACE_WRITE_ATTRIBUTES
-                           | NEW_ACE_WRITE_ACL
-                           | NEW_ACE_WRITE_OWNER);
-      if ((NEW_ACE_READ_NAMED_ATTRS
-           | NEW_ACE_READ_ATTRIBUTES
-           | NEW_ACE_READ_ACL
-           | NEW_ACE_SYNCHRONIZE)
-          & ~ access_masks[5])
-        return 1;
-      access_masks[5] &= ~(NEW_ACE_READ_NAMED_ATTRS
-                           | NEW_ACE_READ_ATTRIBUTES
-                           | NEW_ACE_READ_ACL
-                           | NEW_ACE_SYNCHRONIZE);
-
-      /* Check the allowed or denied bits.  */
-      switch ((access_masks[0] | access_masks[1])
-              & ~(NEW_ACE_READ_NAMED_ATTRS
-                  | NEW_ACE_READ_ATTRIBUTES
-                  | NEW_ACE_READ_ACL
-                  | NEW_ACE_SYNCHRONIZE))
-        {
-        case 0:
-        case NEW_ACE_READ_DATA:
-        case                     NEW_ACE_WRITEA_DATA:
-        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA:
-        case                                           NEW_ACE_EXECUTE:
-        case NEW_ACE_READ_DATA |                       NEW_ACE_EXECUTE:
-        case                     NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
-        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
-          break;
-        default:
-          return 1;
-        }
-      switch ((access_masks[2] | access_masks[3])
-              & ~(NEW_ACE_READ_NAMED_ATTRS
-                  | NEW_ACE_READ_ATTRIBUTES
-                  | NEW_ACE_READ_ACL
-                  | NEW_ACE_SYNCHRONIZE))
-        {
-        case 0:
-        case NEW_ACE_READ_DATA:
-        case                     NEW_ACE_WRITEA_DATA:
-        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA:
-        case                                           NEW_ACE_EXECUTE:
-        case NEW_ACE_READ_DATA |                       NEW_ACE_EXECUTE:
-        case                     NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
-        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
-          break;
-        default:
-          return 1;
-        }
-      switch ((access_masks[4] | access_masks[5])
-              & ~(NEW_ACE_WRITE_NAMED_ATTRS
-                  | NEW_ACE_WRITE_ATTRIBUTES
-                  | NEW_ACE_WRITE_ACL
-                  | NEW_ACE_WRITE_OWNER))
-        {
-        case 0:
-        case NEW_ACE_READ_DATA:
-        case                     NEW_ACE_WRITEA_DATA:
-        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA:
-        case                                           NEW_ACE_EXECUTE:
-        case NEW_ACE_READ_DATA |                       NEW_ACE_EXECUTE:
-        case                     NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
-        case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE:
-          break;
-        default:
-          return 1;
-        }
-
-      /* Check that the NEW_ACE_WRITE_DATA and NEW_ACE_APPEND_DATA bits are
-         either both allowed or both denied.  */
-      if (((access_masks[0] & NEW_ACE_WRITE_DATA) != 0)
-          != ((access_masks[0] & NEW_ACE_APPEND_DATA) != 0))
-        return 1;
-      if (((access_masks[2] & NEW_ACE_WRITE_DATA) != 0)
-          != ((access_masks[2] & NEW_ACE_APPEND_DATA) != 0))
-        return 1;
-      if (((access_masks[4] & NEW_ACE_WRITE_DATA) != 0)
-          != ((access_masks[4] & NEW_ACE_APPEND_DATA) != 0))
-        return 1;
-    }
-
-  return 0;
-}
-
-# endif
-
-#elif USE_ACL && HAVE_GETACL /* HP-UX */
-
-/* Return 1 if the given ACL is non-trivial.
-   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
-int
-acl_nontrivial (int count, struct acl_entry *entries, struct stat *sb)
-{
-  int i;
-
-  for (i = 0; i < count; i++)
-    {
-      struct acl_entry *ace = &entries[i];
-
-      if (!((ace->uid == sb->st_uid && ace->gid == ACL_NSGROUP)
-            || (ace->uid == ACL_NSUSER && ace->gid == sb->st_gid)
-            || (ace->uid == ACL_NSUSER && ace->gid == ACL_NSGROUP)))
-        return 1;
-    }
-  return 0;
-}
-
-# if HAVE_ACLV_H /* HP-UX >= 11.11 */
-
-/* Return 1 if the given ACL is non-trivial.
-   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
-int
-aclv_nontrivial (int count, struct acl *entries)
-{
-  int i;
-
-  for (i = 0; i < count; i++)
-    {
-      struct acl *ace = &entries[i];
-
-      /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat().
-         If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat().
-         We don't need to check ace->a_id in these cases.  */
-      if (!(ace->a_type == USER_OBJ /* no need to check ace->a_id here */
-            || ace->a_type == GROUP_OBJ /* no need to check ace->a_id here */
-            || ace->a_type == CLASS_OBJ
-            || ace->a_type == OTHER_OBJ))
-        return 1;
-    }
-  return 0;
-}
-
-# endif
-
-#elif USE_ACL && (HAVE_ACLX_GET || HAVE_STATACL) /* AIX */
-
-/* Return 1 if the given ACL is non-trivial.
-   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
-int
-acl_nontrivial (struct acl *a)
-{
-  /* The normal way to iterate through an ACL is like this:
-       struct acl_entry *ace;
-       for (ace = a->acl_ext; ace != acl_last (a); ace = acl_nxt (ace))
-         {
-           struct ace_id *aei;
-           switch (ace->ace_type)
-             {
-             case ACC_PERMIT:
-             case ACC_DENY:
-             case ACC_SPECIFY:
-               ...;
-             }
-           for (aei = ace->ace_id; aei != id_last (ace); aei = id_nxt (aei))
-             ...
-         }
-   */
-  return (acl_last (a) != a->acl_ext ? 1 : 0);
-}
-
-# if HAVE_ACLX_GET && defined ACL_AIX_WIP /* newer AIX */
-
-/* Return 1 if the given ACL is non-trivial.
-   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
-int
-acl_nfs4_nontrivial (nfs4_acl_int_t *a)
-{
-#  if 1 /* let's try this first */
-  return (a->aclEntryN > 0 ? 1 : 0);
-#  else
-  int count = a->aclEntryN;
-  int i;
-
-  for (i = 0; i < count; i++)
-    {
-      nfs4_ace_int_t *ace = &a->aclEntry[i];
-
-      if (!((ace->flags & ACE4_ID_SPECIAL) != 0
-            && (ace->aceWho.special_whoid == ACE4_WHO_OWNER
-                || ace->aceWho.special_whoid == ACE4_WHO_GROUP
-                || ace->aceWho.special_whoid == ACE4_WHO_EVERYONE)
-            && ace->aceType == ACE4_ACCESS_ALLOWED_ACE_TYPE
-            && ace->aceFlags == 0
-            && (ace->aceMask & ~(ACE4_READ_DATA | ACE4_LIST_DIRECTORY
-                                 | ACE4_WRITE_DATA | ACE4_ADD_FILE
-                                 | ACE4_EXECUTE)) == 0))
-        return 1;
-    }
-  return 0;
-#  endif
-}
-
-# endif
-
-#elif USE_ACL && HAVE_ACLSORT /* NonStop Kernel */
-
-/* Test an ACL retrieved with ACL_GET.
-   Return 1 if the given ACL, consisting of COUNT entries, is non-trivial.
-   Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
-int
-acl_nontrivial (int count, struct acl *entries)
-{
-  int i;
-
-  for (i = 0; i < count; i++)
-    {
-      struct acl *ace = &entries[i];
-
-      /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat().
-         If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat().
-         We don't need to check ace->a_id in these cases.  */
-      if (!(ace->a_type == USER_OBJ /* no need to check ace->a_id here */
-            || ace->a_type == GROUP_OBJ /* no need to check ace->a_id here */
-            || ace->a_type == CLASS_OBJ
-            || ace->a_type == OTHER_OBJ))
-        return 1;
-    }
-  return 0;
-}
-
-#endif
-
-
-/* Return 1 if NAME has a nontrivial access control list, 0 if NAME
-   only has no or a base access control list, and -1 (setting errno)
-   on error.  SB must be set to the stat buffer of NAME, obtained
-   through stat() or lstat().  */
-
-int
-file_has_acl (char const *name, struct stat const *sb)
-{
-#if USE_ACL
-  if (! S_ISLNK (sb->st_mode))
-    {
-# if HAVE_ACL_GET_FILE
-
-      /* POSIX 1003.1e (draft 17 -- abandoned) specific version.  */
-      /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */
-      int ret;
-
-      if (HAVE_ACL_EXTENDED_FILE) /* Linux */
-        {
-          /* On Linux, acl_extended_file is an optimized function: It only
-             makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for
-             ACL_TYPE_DEFAULT.  */
-          ret = acl_extended_file (name);
-        }
-      else /* FreeBSD, Mac OS X, IRIX, Tru64 */
-        {
-#  if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
-          /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS)
-             and acl_get_file (name, ACL_TYPE_DEFAULT)
-             always return NULL / EINVAL.  There is no point in making
-             these two useless calls.  The real ACL is retrieved through
-             acl_get_file (name, ACL_TYPE_EXTENDED).  */
-          acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED);
-          if (acl)
-            {
-              ret = acl_extended_nontrivial (acl);
-              acl_free (acl);
-            }
-          else
-            ret = -1;
-#  else /* FreeBSD, IRIX, Tru64 */
-          acl_t acl = acl_get_file (name, ACL_TYPE_ACCESS);
-          if (acl)
-            {
-              int saved_errno;
-
-              ret = acl_access_nontrivial (acl);
-              saved_errno = errno;
-              acl_free (acl);
-              errno = saved_errno;
-#   if HAVE_ACL_FREE_TEXT /* Tru64 */
-              /* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always
-                 returns NULL with errno not set.  There is no point in
-                 making this call.  */
-#   else /* FreeBSD, IRIX */
-              /* On Linux, FreeBSD, IRIX, acl_get_file (name, ACL_TYPE_ACCESS)
-                 and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory
-                 either both succeed or both fail; it depends on the
-                 file system.  Therefore there is no point in making the second
-                 call if the first one already failed.  */
-              if (ret == 0 && S_ISDIR (sb->st_mode))
-                {
-                  acl = acl_get_file (name, ACL_TYPE_DEFAULT);
-                  if (acl)
-                    {
-                      ret = (0 < acl_entries (acl));
-                      acl_free (acl);
-                    }
-                  else
-                    ret = -1;
-                }
-#   endif
-            }
-          else
-            ret = -1;
-#  endif
-        }
-      if (ret < 0)
-        return - acl_errno_valid (errno);
-      return ret;
-
-# elif HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
-
-#  if defined ACL_NO_TRIVIAL
-
-      /* Solaris 10 (newer version), which has additional API declared in
-         <sys/acl.h> (acl_t) and implemented in libsec (acl_set, acl_trivial,
-         acl_fromtext, ...).  */
-      return acl_trivial (name);
-
-#  else /* Solaris, Cygwin, general case */
-
-      /* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions
-         of Unixware.  The acl() call returns the access and default ACL both
-         at once.  */
-      {
-        /* Initially, try to read the entries into a stack-allocated buffer.
-           Use malloc if it does not fit.  */
-        enum
-          {
-            alloc_init = 4000 / sizeof (aclent_t), /* >= 3 */
-            alloc_max = MIN (INT_MAX, SIZE_MAX / sizeof (aclent_t))
-          };
-        aclent_t buf[alloc_init];
-        size_t alloc = alloc_init;
-        aclent_t *entries = buf;
-        aclent_t *malloced = NULL;
-        int count;
-
-        for (;;)
-          {
-            count = acl (name, GETACL, alloc, entries);
-            if (count < 0 && errno == ENOSPC)
-              {
-                /* Increase the size of the buffer.  */
-                free (malloced);
-                if (alloc > alloc_max / 2)
-                  {
-                    errno = ENOMEM;
-                    return -1;
-                  }
-                alloc = 2 * alloc; /* <= alloc_max */
-                entries = malloced =
-                  (aclent_t *) malloc (alloc * sizeof (aclent_t));
-                if (entries == NULL)
-                  {
-                    errno = ENOMEM;
-                    return -1;
-                  }
-                continue;
-              }
-            break;
-          }
-        if (count < 0)
-          {
-            if (errno == ENOSYS || errno == ENOTSUP)
-              ;
-            else
-              {
-                int saved_errno = errno;
-                free (malloced);
-                errno = saved_errno;
-                return -1;
-              }
-          }
-        else if (count == 0)
-          ;
-        else
-          {
-            /* Don't use MIN_ACL_ENTRIES:  It's set to 4 on Cygwin, but Cygwin
-               returns only 3 entries for files with no ACL.  But this is safe:
-               If there are more than 4 entries, there cannot be only the
-               "user::", "group::", "other:", and "mask:" entries.  */
-            if (count > 4)
-              {
-                free (malloced);
-                return 1;
-              }
-
-            if (acl_nontrivial (count, entries))
-              {
-                free (malloced);
-                return 1;
-              }
-          }
-        free (malloced);
-      }
-
-#   ifdef ACE_GETACL
-      /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4
-         file systems (whereas the other ones are used in UFS file systems).  
*/
-      {
-        /* Initially, try to read the entries into a stack-allocated buffer.
-           Use malloc if it does not fit.  */
-        enum
-          {
-            alloc_init = 4000 / sizeof (ace_t), /* >= 3 */
-            alloc_max = MIN (INT_MAX, SIZE_MAX / sizeof (ace_t))
-          };
-        ace_t buf[alloc_init];
-        size_t alloc = alloc_init;
-        ace_t *entries = buf;
-        ace_t *malloced = NULL;
-        int count;
-
-        for (;;)
-          {
-            count = acl (name, ACE_GETACL, alloc, entries);
-            if (count < 0 && errno == ENOSPC)
-              {
-                /* Increase the size of the buffer.  */
-                free (malloced);
-                if (alloc > alloc_max / 2)
-                  {
-                    errno = ENOMEM;
-                    return -1;
-                  }
-                alloc = 2 * alloc; /* <= alloc_max */
-                entries = malloced = (ace_t *) malloc (alloc * sizeof (ace_t));
-                if (entries == NULL)
-                  {
-                    errno = ENOMEM;
-                    return -1;
-                  }
-                continue;
-              }
-            break;
-          }
-        if (count < 0)
-          {
-            if (errno == ENOSYS || errno == EINVAL)
-              ;
-            else
-              {
-                int saved_errno = errno;
-                free (malloced);
-                errno = saved_errno;
-                return -1;
-              }
-          }
-        else if (count == 0)
-          ;
-        else
-          {
-            /* In the old (original Solaris 10) convention:
-               If there are more than 3 entries, there cannot be only the
-               ACE_OWNER, ACE_GROUP, ACE_OTHER entries.
-               In the newer Solaris 10 and Solaris 11 convention:
-               If there are more than 6 entries, there cannot be only the
-               ACE_OWNER, ACE_GROUP, ACE_EVERYONE entries, each once with
-               NEW_ACE_ACCESS_ALLOWED_ACE_TYPE and once with
-               NEW_ACE_ACCESS_DENIED_ACE_TYPE.  */
-            if (count > 6)
-              {
-                free (malloced);
-                return 1;
-              }
-
-            if (acl_ace_nontrivial (count, entries))
-              {
-                free (malloced);
-                return 1;
-              }
-          }
-        free (malloced);
-      }
-#   endif
-
-      return 0;
-#  endif
-
-# elif HAVE_GETACL /* HP-UX */
-
-      {
-        struct acl_entry entries[NACLENTRIES];
-        int count;
-
-        count = getacl (name, NACLENTRIES, entries);
-
-        if (count < 0)
-          {
-            /* ENOSYS is seen on newer HP-UX versions.
-               EOPNOTSUPP is typically seen on NFS mounts.
-               ENOTSUP was seen on Quantum StorNext file systems (cvfs).  */
-            if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
-              ;
-            else
-              return -1;
-          }
-        else if (count == 0)
-          return 0;
-        else /* count > 0 */
-          {
-            if (count > NACLENTRIES)
-              /* If NACLENTRIES cannot be trusted, use dynamic memory
-                 allocation.  */
-              abort ();
-
-            /* If there are more than 3 entries, there cannot be only the
-               (uid,%), (%,gid), (%,%) entries.  */
-            if (count > 3)
-              return 1;
-
-            {
-              struct stat statbuf;
-
-              if (stat (name, &statbuf) < 0)
-                return -1;
-
-              return acl_nontrivial (count, entries, &statbuf);
-            }
-          }
-      }
-
-#  if HAVE_ACLV_H /* HP-UX >= 11.11 */
-
-      {
-        struct acl entries[NACLVENTRIES];
-        int count;
-
-        count = acl ((char *) name, ACL_GET, NACLVENTRIES, entries);
-
-        if (count < 0)
-          {
-            /* EOPNOTSUPP is seen on NFS in HP-UX 11.11, 11.23.
-               EINVAL is seen on NFS in HP-UX 11.31.  */
-            if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
-              ;
-            else
-              return -1;
-          }
-        else if (count == 0)
-          return 0;
-        else /* count > 0 */
-          {
-            if (count > NACLVENTRIES)
-              /* If NACLVENTRIES cannot be trusted, use dynamic memory
-                 allocation.  */
-              abort ();
-
-            /* If there are more than 4 entries, there cannot be only the
-               four base ACL entries.  */
-            if (count > 4)
-              return 1;
-
-            return aclv_nontrivial (count, entries);
-          }
-      }
-
-#  endif
-
-# elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */
-
-      acl_type_t type;
-      char aclbuf[1024];
-      void *acl = aclbuf;
-      size_t aclsize = sizeof (aclbuf);
-      mode_t mode;
-
-      for (;;)
-        {
-          /* The docs say that type being 0 is equivalent to ACL_ANY, but it
-             is not true, in AIX 5.3.  */
-          type.u64 = ACL_ANY;
-          if (aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) >= 0)
-            break;
-          if (errno == ENOSYS)
-            return 0;
-          if (errno != ENOSPC)
-            {
-              if (acl != aclbuf)
-                {
-                  int saved_errno = errno;
-                  free (acl);
-                  errno = saved_errno;
-                }
-              return -1;
-            }
-          aclsize = 2 * aclsize;
-          if (acl != aclbuf)
-            free (acl);
-          acl = malloc (aclsize);
-          if (acl == NULL)
-            {
-              errno = ENOMEM;
-              return -1;
-            }
-        }
-
-      if (type.u64 == ACL_AIXC)
-        {
-          int result = acl_nontrivial ((struct acl *) acl);
-          if (acl != aclbuf)
-            free (acl);
-          return result;
-        }
-      else if (type.u64 == ACL_NFS4)
-        {
-          int result = acl_nfs4_nontrivial ((nfs4_acl_int_t *) acl);
-          if (acl != aclbuf)
-            free (acl);
-          return result;
-        }
-      else
-        {
-          /* A newer type of ACL has been introduced in the system.
-             We should better support it.  */
-          if (acl != aclbuf)
-            free (acl);
-          errno = EINVAL;
-          return -1;
-        }
-
-# elif HAVE_STATACL /* older AIX */
-
-      union { struct acl a; char room[4096]; } u;
-
-      if (statacl (name, STX_NORMAL, &u.a, sizeof (u)) < 0)
-        return -1;
-
-      return acl_nontrivial (&u.a);
-
-# elif HAVE_ACLSORT /* NonStop Kernel */
-
-      {
-        struct acl entries[NACLENTRIES];
-        int count;
-
-        count = acl ((char *) name, ACL_GET, NACLENTRIES, entries);
-
-        if (count < 0)
-          {
-            if (errno == ENOSYS || errno == ENOTSUP)
-              ;
-            else
-              return -1;
-          }
-        else if (count == 0)
-          return 0;
-        else /* count > 0 */
-          {
-            if (count > NACLENTRIES)
-              /* If NACLENTRIES cannot be trusted, use dynamic memory
-                 allocation.  */
-              abort ();
-
-            /* If there are more than 4 entries, there cannot be only the
-               four base ACL entries.  */
-            if (count > 4)
-              return 1;
-
-            return acl_nontrivial (count, entries);
-          }
-      }
-
-# endif
-    }
-#endif
-
-  return 0;
-}
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 273b018..bec0d3b 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -698,7 +698,7 @@ EXTRA_libgnu_a_SOURCES += putenv.c
 
 ## begin gnulib module qacl
 
-libgnu_a_SOURCES += acl-errno-valid.c file-has-acl.c qcopy-acl.c qset-acl.c
+libgnu_a_SOURCES += acl-errno-valid.c acl-internal.c qcopy-acl.c qset-acl.c
 
 EXTRA_DIST += acl-internal.h acl.h acl_entries.c
 
diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c
index aac76a1..bc258ba 100644
--- a/lib/qcopy-acl.c
+++ b/lib/qcopy-acl.c
@@ -437,20 +437,9 @@ qcopy_acl (const char *src_name, int source_desc, const 
char *dst_name,
       if (ret < 0 && saved_errno == 0)
         {
           saved_errno = errno;
-          if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
-            {
-              struct stat source_statbuf;
-
-              if ((source_desc != -1
-                   ? fstat (source_desc, &source_statbuf)
-                   : stat (src_name, &source_statbuf)) == 0)
-                {
-                  if (!acl_nontrivial (count, entries, &source_statbuf))
-                    saved_errno = 0;
-                }
-              else
-                saved_errno = errno;
-            }
+          if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP
+             && !acl_nontrivial (count, entries))
+               saved_errno = 0;
         }
       else
         did_chmod = 1;
diff --git a/lib/tempname.c b/lib/tempname.c
index 8e6d26c..69c572f 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -269,13 +269,13 @@ try_file (char *tmpl, void *flags)
 }
 
 static int
-try_dir (char *tmpl, void *flags)
+try_dir (char *tmpl, void *flags _GL_UNUSED)
 {
   return __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
 }
 
 static int
-try_nocreate (char *tmpl, void *flags)
+try_nocreate (char *tmpl, void *flags _GL_UNUSED)
 {
   struct_stat64 st;
 
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index cd894f4..9f57d0d 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -4377,7 +4377,8 @@ if only the first line of the docstring is shown."))
 
 (defun custom-file (&optional no-error)
   "Return the file name for saving customizations."
-  (if (null user-init-file)
+  (if (or (null user-init-file)
+          (and (null custom-file) init-file-had-error))
       ;; Started with -q, i.e. the file containing Custom settings
       ;; hasn't been read.  Saving settings there won't make much
       ;; sense.
diff --git a/lisp/custom.el b/lisp/custom.el
index e5fe0eb..ea5ab7a 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -449,8 +449,7 @@ information."
   ;; Record the group on the `current' list.
   (let ((elt (assoc load-file-name custom-current-group-alist)))
     (if elt (setcdr elt symbol)
-      (push (cons (purecopy load-file-name) symbol)
-           custom-current-group-alist)))
+      (push (cons load-file-name symbol) custom-current-group-alist)))
   (run-hooks 'custom-define-hook)
   symbol)
 
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index 59d8348..92d7234 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -88,7 +88,7 @@ Currently under control of this var:
 
 (cl-defstruct (eieio--class
                (:constructor nil)
-               (:constructor eieio--class-make (name &aux (tag 'defclass)))
+               (:constructor eieio--class-make (name))
                (:include cl--class)
                (:copier nil))
   children
@@ -277,12 +277,12 @@ See `defclass' for more information."
   (setq eieio-hook nil)
 
   (let* ((oldc (let ((c (eieio--class-v cname))) (if (eieio--class-p c) c)))
-        (newc (if (and oldc (not (eieio--class-default-object-cache oldc)))
-                   ;; The oldc class is a stub setup by 
eieio-defclass-autoload.
-                   ;; Reuse it instead of creating a new one, so that existing
-                   ;; references stay valid.
-                   oldc
-                 (eieio--class-make cname)))
+        (newc (or oldc
+                   ;; Reuse `oldc' instead of creating a new one, so that
+                   ;; existing references stay valid.  E.g. when
+                   ;; reloading the file that does the `defclass', we don't
+                   ;; want to create a new class object.
+                   (eieio--class-make cname)))
         (groups nil) ;; list of groups id'd from slots
         (clearparent nil))
 
@@ -292,7 +292,13 @@ See `defclass' for more information."
     ;; method table breakage, particularly when the users is only
     ;; byte compiling an EIEIO file.
     (if oldc
-       (setf (eieio--class-children newc) (eieio--class-children oldc))
+        (progn
+          (cl-assert (eq newc oldc))
+          ;; Reset the fields.
+          (setf (eieio--class-parents newc) nil)
+          (setf (eieio--class-slots newc) nil)
+          (setf (eieio--class-initarg-tuples newc) nil)
+          (setf (eieio--class-class-slots newc) nil))
       ;; If the old class did not exist, but did exist in the autoload map,
       ;; then adopt those children.  This is like the above, but deals with
       ;; autoloads nicely.
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index c69e15b..bb9a3bb 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -185,7 +185,6 @@ and before `after-init-hook'.  Activation is not done if
 Even if the value is nil, you can type \\[package-initialize] to
 activate the package system at any time."
   :type 'boolean
-  :group 'package
   :version "24.1")
 
 (defcustom package-load-list '(all)
@@ -203,7 +202,6 @@ If VERSION is a string, only that version is ever loaded.
 If VERSION is nil, the package is not loaded (it is \"disabled\")."
   :type '(repeat symbol)
   :risky t
-  :group 'package
   :version "24.1")
 
 (defcustom package-archives '(("gnu" . "http://elpa.gnu.org/packages/";))
@@ -222,9 +220,31 @@ a package can run arbitrary code."
   :type '(alist :key-type (string :tag "Archive name")
                 :value-type (string :tag "URL or directory name"))
   :risky t
-  :group 'package
   :version "24.1")
 
+(defcustom package-menu-hide-low-priority 'archive
+  "If non-nil, hide low priority packages from the packages menu.
+A package is considered low priority if there's another version
+of it available such that:
+    (a) the archive of the other package is higher priority than
+    this one, as per `package-archive-priorities';
+  or
+    (b) they both have the same archive priority but the other
+    package has a higher version number.
+
+This variable has three possible values:
+    nil: no packages are hidden;
+    archive: only criteria (a) is used;
+    t: both criteria are used.
+
+This variable has no effect if `package-menu--hide-obsolete' is
+nil, so it can be toggled with \\<package-menu-mode-map> 
\\[package-menu-hide-obsolete]."
+  :type '(choice (const :tag "Don't hide anything" nil)
+                 (const :tag "Hide per package-archive-priorities"
+                        archive)
+                 (const :tag "Hide per archive and version number" t))
+  :version "25.1")
+
 (defcustom package-archive-priorities nil
   "An alist of priorities for packages.
 
@@ -235,11 +255,12 @@ number from the archive with the highest priority is
 selected. When higher versions are available from archives with
 lower priorities, the user has to select those manually.
 
-Archives not in this list have the priority 0."
+Archives not in this list have the priority 0.
+
+See also `package-menu-hide-low-priority'."
   :type '(alist :key-type (string :tag "Archive name")
                 :value-type (integer :tag "Priority (default is 0)"))
   :risky t
-  :group 'package
   :version "25.1")
 
 (defcustom package-pinned-packages nil
@@ -263,7 +284,6 @@ the package will be unavailable."
   ;; via an entry (PACKAGE . NON-EXISTING).  Which could be an issue
   ;; if PACKAGE has a known vulnerability that is fixed in newer versions.
   :risky t
-  :group 'package
   :version "24.4")
 
 (defcustom package-user-dir (locate-user-emacs-file "elpa")
@@ -273,7 +293,6 @@ Apart from this directory, Emacs also looks for system-wide
 packages in `package-directory-list'."
   :type 'directory
   :risky t
-  :group 'package
   :version "24.1")
 
 (defcustom package-directory-list
@@ -291,7 +310,6 @@ These directories contain packages intended for 
system-wide; in
 contrast, `package-user-dir' contains packages for personal use."
   :type '(repeat directory)
   :risky t
-  :group 'package
   :version "24.1")
 
 (defvar epg-gpg-program)
@@ -309,14 +327,12 @@ contents of the archive."
                  (const allow-unsigned :tag "Allow unsigned")
                  (const t :tag "Check always"))
   :risky t
-  :group 'package
   :version "24.4")
 
 (defcustom package-unsigned-archives nil
   "List of archives where we do not check for package signatures."
   :type '(repeat (string :tag "Archive name"))
   :risky t
-  :group 'package
   :version "24.4")
 
 (defcustom package-selected-packages nil
@@ -330,9 +346,15 @@ by running `package-user-selected-packages-install'.
 To check if a package is contained in this list here, use
 `package--user-selected-p', as it may populate the variable with
 a sane initial value."
-  :group 'package
   :type '(repeat symbol))
 
+(defcustom package-menu-async t
+  "If non-nil, package-menu will use async operations when possible.
+This includes refreshing archive contents as well as installing
+packages."
+  :type 'boolean
+  :version "25.1")
+
 
 ;;; `package-desc' object definition
 ;; This is the struct used internally to represent packages.
@@ -467,6 +489,10 @@ This is, approximately, the inverse of `version-to-list'.
         (nth 1 keywords)
       keywords)))
 
+(defun package-desc-priority (p)
+  "Return the priority of the archive of package-desc object P."
+  (package-archive-priority (package-desc-archive p)))
+
 ;; Package descriptor format used in finder-inf.el and package--builtins.
 (cl-defstruct (package--bi-desc
                (:constructor package-make-builtin (version summary))
@@ -862,6 +888,8 @@ untar into a directory named DIR; otherwise, signal an 
error."
 (defvar generated-autoload-file)
 (defvar version-control)
 
+(defvar package--silence nil)
+
 (defun package-generate-autoloads (name pkg-dir)
   (let* ((auto-name (format "%s-autoloads.el" name))
          ;;(ignore-name (concat name "-pkg.el"))
@@ -1107,7 +1135,8 @@ arguments see `package--with-work-buffer'."
                              (signal (cdar status) (cddr status)))
                          (goto-char (point-min))
                          (unless (search-forward "\n\n" nil 'noerror)
-                           (error "Invalid url response"))
+                           (error "Invalid url response in buffer %s"
+                             (current-buffer)))
                          (delete-region (point-min) (point))
                          ,@body)
                        (kill-buffer (current-buffer)))
@@ -1343,18 +1372,11 @@ it to the file."
 (defvar package--downloads-in-progress nil
   "List of in-progress asynchronous downloads.")
 
-(defvar package--all-keywords nil
-  "List of known keywords.
-Generated by `package-all-keywords'.  Reset to nil whenever the
-package archives are retrieved.")
-
 (declare-function epg-check-configuration "epg-config"
                   (config &optional minimum-version))
 (declare-function epg-configuration "epg-config" ())
 (declare-function epg-import-keys-from-file "epg" (context keys))
 
-(defvar package--silence nil)
-
 (defun package--message (format &rest args)
   "Like `message', except sometimes don't print to minibuffer.
 If the variable `package--silence' is non-nil, the message is not
@@ -1465,7 +1487,6 @@ downloads in the background."
   (interactive)
   (unless (file-exists-p package-user-dir)
     (make-directory package-user-dir t))
-  (setq package--all-keywords nil)
   (let ((default-keyring (expand-file-name "package-keyring.gpg"
                                            data-directory))
         (package--silence async))
@@ -1792,6 +1813,7 @@ using `package-compute-transaction'."
                       (widen)
                       (goto-char (point-min))
                       (search-forward "(package-initialize)" nil 'noerror))))
+              ;; Don't visit the file if we don't have to.
               (with-temp-buffer
                 (insert-file-contents user-init-file)
                 (goto-char (point-min))
@@ -1804,7 +1826,11 @@ using `package-compute-transaction'."
             (save-restriction
               (widen)
               (goto-char (point-min))
+              (while (and (looking-at-p "[[:blank:]]*\\(;\\|$\\)")
+                          (not (eobp)))
+                (forward-line 1))
               (insert
+               "\n"
                ";; Added by Package.el.  This must come before configurations 
of\n"
                ";; installed packages.  Don't delete this line.  If you don't 
want it,\n"
                ";; just comment it out by adding a semicolon to the start of 
the line.\n"
@@ -1929,7 +1955,7 @@ The file can either be a tar file or an Emacs Lisp file."
     (package-install-from-buffer)))
 
 ;;;###autoload
-(defun package-install-user-selected-packages ()
+(defun package-install-selected-packages ()
   "Ensure packages in `package-selected-packages' are installed.
 If some packages are not installed propose to install them."
   (interactive)
@@ -2296,6 +2322,7 @@ will be deleted."
     (define-key map "x" 'package-menu-execute)
     (define-key map "h" 'package-menu-quick-help)
     (define-key map "?" 'package-menu-describe-package)
+    (define-key map "(" #'package-menu-hide-obsolete)
     (define-key map [menu-bar package-menu] (cons "Package" menu-map))
     (define-key menu-map [mq]
       '(menu-item "Quit" quit-window
@@ -2446,14 +2473,55 @@ of these dependencies, similar to the list returned by
       (let* ((ins (cadr (assq name package-alist)))
              (ins-v (if ins (package-desc-version ins))))
         (cond
-         ((or (null ins) (version-list-< ins-v version))
+         ;; Installed obsolete packages are handled in the `dir'
+         ;; clause above.  Here we handle available obsolete, which
+         ;; are displayed depending on `package-menu--hide-obsolete'.
+         ((and ins (version-list-<= version ins-v)) "avail-obso")
+         (t
           (if (memq name package-menu--new-package-list)
-              "new" "available"))
-         ((version-list-< version ins-v) "obsolete")
-         ((version-list-= version ins-v)
-          (if (not signed) "unsigned"
-            (if (package--user-selected-p name)
-                "installed" "dependency")))))))))
+              "new" "available"))))))))
+
+(defvar package-menu--hide-obsolete t
+  "Whether available obsolete packages should be hidden.
+Can be toggled with \\<package-menu-mode-map> \\[package-menu-hide-obsolete].
+Installed obsolete packages are always displayed.")
+
+(defun package-menu-hide-obsolete ()
+  "Toggle visibility of obsolete available packages."
+  (interactive)
+  (unless (derived-mode-p 'package-menu-mode)
+    (user-error "The current buffer is not a Package Menu"))
+  (setq package-menu--hide-obsolete
+        (not package-menu--hide-obsolete))
+  (message "%s available-obsolete packages" (if package-menu--hide-obsolete
+                                                "Hiding" "Displaying"))
+  (revert-buffer nil 'no-confirm))
+
+(defun package--remove-hidden (pkg-list)
+  "Filter PKG-LIST according to `package-archive-priorities'.
+PKG-LIST must be a list of package-desc objects sorted by
+decreasing version number.
+Return a list of packages tied for the highest priority according
+to their archives."
+  (when pkg-list
+    ;; The first is a variable toggled with
+    ;; `package-menu-hide-obsolete', the second is a static user
+    ;; option that defines *what* we hide.
+    (if (and package-menu--hide-obsolete
+             package-menu-hide-low-priority)
+        (let ((max-priority (package-desc-priority (car pkg-list)))
+              (out (list (pop pkg-list))))
+          (dolist (p pkg-list (nreverse out))
+            (let ((priority (package-desc-priority p)))
+              (cond
+               ((> priority max-priority)
+                (setq max-priority priority)
+                (setq out (list p)))
+               ;; This assumes pkg-list is sorted by version number.
+               ((and (= priority max-priority)
+                     (eq package-menu-hide-low-priority 'archive))
+                (push p out))))))
+      pkg-list)))
 
 (defun package-menu--refresh (&optional packages keywords)
   "Re-populate the `tabulated-list-entries'.
@@ -2484,10 +2552,11 @@ KEYWORDS should be nil or a list of keywords."
     (dolist (elt package-archive-contents)
       (setq name (car elt))
       (when (or (eq packages t) (memq name packages))
-        (dolist (pkg (cdr elt))
-          ;; Hide obsolete packages.
-          (when (and (not (package-installed-p (package-desc-name pkg)
-                                               (package-desc-version pkg)))
+        (dolist (pkg (package--remove-hidden (cdr elt)))
+          ;; Hide available obsolete packages.
+          (when (and (not (and package-menu--hide-obsolete
+                               (package-installed-p (package-desc-name pkg)
+                                                    (package-desc-version 
pkg))))
                      (package--has-keyword-p pkg keywords))
             (package--push pkg (package-desc-status pkg) info-list)))))
 
@@ -2497,11 +2566,11 @@ KEYWORDS should be nil or a list of keywords."
 
 (defun package-all-keywords ()
   "Collect all package keywords"
-  (unless package--all-keywords
+  (let ((key-list))
     (package--mapc (lambda (desc)
-                     (let* ((desc-keywords (and desc (package-desc--keywords 
desc))))
-                       (setq package--all-keywords (append desc-keywords 
package--all-keywords))))))
-  package--all-keywords)
+                     (setq key-list (append (package-desc--keywords desc)
+                                            key-list))))
+    key-list))
 
 (defun package--mapc (function &optional packages)
   "Call FUNCTION for all known PACKAGES.
@@ -2580,6 +2649,7 @@ Return (PKG-DESC [NAME VERSION STATUS DOC])."
          (face (pcase status
                  (`"built-in"  'font-lock-builtin-face)
                  (`"available" 'default)
+                 (`"avail-obso" 'font-lock-comment-face)
                  (`"new"       'bold)
                  (`"held"      'font-lock-constant-face)
                  (`"disabled"  'font-lock-warning-face)
@@ -2604,6 +2674,9 @@ Return (PKG-DESC [NAME VERSION STATUS DOC])."
             ,(propertize (package-desc-summary pkg-desc)
                          'font-lock-face face)])))
 
+(defvar package-menu--old-archive-contents nil
+  "`package-archive-contents' before the latest refresh.")
+
 (defun package-menu-refresh ()
   "Download the Emacs Lisp package archive.
 This fetches the contents of each archive specified in
@@ -2637,7 +2710,7 @@ If optional arg BUTTON is non-nil, describe its 
associated package."
 (defun package-menu-mark-install (&optional _num)
   "Mark a package for installation and move to the next line."
   (interactive "p")
-  (if (member (package-menu-get-status) '("available" "new" "dependency"))
+  (if (member (package-menu-get-status) '("available" "avail-obso" "new" 
"dependency"))
       (tabulated-list-put-tag "I" t)
     (forward-line)))
 
@@ -2665,7 +2738,7 @@ If optional arg BUTTON is non-nil, describe its 
associated package."
 (defvar package--quick-help-keys
   '(("install," "delete," "unmark," ("execute" . 1))
     ("next," "previous")
-    ("refresh-contents," "g-redisplay," "filter," "help")))
+    ("refresh-contents," "g-redisplay," "filter," "(-toggle-obsolete" "help")))
 
 (defun package--prettify-quick-help-key (desc)
   "Prettify DESC to be displayed as a help menu."
@@ -2713,8 +2786,7 @@ defaults to 0."
 This allows for easy comparison of package versions from
 different archives if archive priorities are meant to be taken in
 consideration."
-  (cons (package-archive-priority
-         (package-desc-archive pkg-desc))
+  (cons (package-desc-priority pkg-desc)
         (package-desc-version pkg-desc)))
 
 (defun package-menu--find-upgrades ()
@@ -2879,8 +2951,11 @@ Optional argument NOQUERY non-nil means do not ask the 
user to confirm."
            (package-menu--name-predicate A B))
           ((string= sA "new") t)
           ((string= sB "new") nil)
-          ((string= sA "available") t)
-          ((string= sB "available") nil)
+          ((string-prefix-p "avail" sA)
+           (if (string-prefix-p "avail" sB)
+               (package-menu--name-predicate A B)
+             t))
+          ((string-prefix-p "avail" sB) nil)
           ((string= sA "installed") t)
           ((string= sB "installed") nil)
           ((string= sA "dependency") t)
@@ -2912,9 +2987,6 @@ Optional argument NOQUERY non-nil means do not ask the 
user to confirm."
   (string< (or (package-desc-archive (car A)) "")
            (or (package-desc-archive (car B)) "")))
 
-(defvar package-menu--old-archive-contents nil
-  "`package-archive-contents' before the latest refresh.")
-
 (defun package-menu--populate-new-package-list ()
   "Decide which packages are new in `package-archives-contents'.
 Store this list in `package-menu--new-package-list'."
@@ -2945,13 +3017,6 @@ after `package-menu--perform-transaction'."
         (revert-buffer nil 'noconfirm))))
   (package-menu--find-and-notify-upgrades))
 
-(defcustom package-menu-async t
-  "If non-nil, package-menu will use async operations when possible.
-This includes refreshing archive contents as well as installing
-packages."
-  :type 'boolean
-  :group 'package)
-
 ;;;###autoload
 (defun list-packages (&optional no-fetch)
   "Display a list of packages.
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index 320ee20..2f3f519 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: 1.4
+;; Version: 1.5
 ;; Package: seq
 
 ;; Maintainer: address@hidden
@@ -44,31 +44,26 @@
 
 (defmacro seq-doseq (spec &rest body)
   "Loop over a sequence.
-Similar to `dolist' but can be applied lists, strings and vectors.
+Similar to `dolist' but can be applied to lists, strings, and vectors.
 
 Evaluate BODY with VAR bound to each element of SEQ, in turn.
-Then evaluate RESULT to get return value, default nil.
 
-\(fn (VAR SEQ [RESULT]) BODY...)"
+\(fn (VAR SEQ) BODY...)"
   (declare (indent 1) (debug ((symbolp form &optional form) body)))
-  (let ((is-list (make-symbol "is-list"))
+  (let ((length (make-symbol "length"))
         (seq (make-symbol "seq"))
         (index (make-symbol "index")))
     `(let* ((,seq ,(cadr spec))
-            (,is-list (listp ,seq))
-            (,index (if ,is-list ,seq 0)))
-       (while (if ,is-list
-                  (consp ,index)
-                (< ,index (seq-length ,seq)))
-         (let ((,(car spec) (if ,is-list
-                                (car ,index)
-                              (seq-elt ,seq ,index))))
-           ,@body
-           (setq ,index (if ,is-list
-                            (cdr ,index)
-                          (+ ,index 1)))))
-       ,@(if (cddr spec)
-             `((setq ,(car spec) nil) ,@(cddr spec))))))
+            (,length (if (listp ,seq) nil (seq-length ,seq)))
+            (,index (if ,length 0 ,seq)))
+       (while (if ,length
+                  (< ,index ,length)
+                (consp ,index))
+         (let ((,(car spec) (if ,length
+                                (prog1 (seq-elt ,seq ,index)
+                                  (setq ,index (+ ,index 1)))
+                              (pop ,index))))
+           ,@body)))))
 
 (defun seq-drop (seq n)
   "Return a subsequence of SEQ without its first N elements.
@@ -350,7 +345,10 @@ This is an optimization for lists in `seq-take-while'."
 (defalias 'seq-each #'seq-do)
 (defalias 'seq-map #'mapcar)
 
-(add-to-list 'emacs-lisp-mode-hook #'seq--activate-font-lock-keywords)
+(unless (fboundp 'elisp--font-lock-flush-elisp-buffers)
+  ;; In Emacs≥25, (via elisp--font-lock-flush-elisp-buffers and a few others)
+  ;; we automatically highlight macros.
+  (add-to-list 'emacs-lisp-mode-hook #'seq--activate-font-lock-keywords))
 
 (provide 'seq)
 ;;; seq.el ends here
diff --git a/lisp/files.el b/lisp/files.el
index 152f155..045eeaf 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4659,7 +4659,7 @@ See the subroutine `basic-save-buffer' for more 
information."
              (not noninteractive)
              (not save-silently))
        (message "Saving file %s..." (buffer-file-name)))
-    (basic-save-buffer)
+    (basic-save-buffer (called-interactively-p 'any))
     (and modp (memq arg '(4 64)) (setq buffer-backed-up nil))))
 
 (defun delete-auto-save-file-if-necessary (&optional force)
@@ -4701,14 +4701,14 @@ in such cases.")
 (make-variable-buffer-local 'save-buffer-coding-system)
 (put 'save-buffer-coding-system 'permanent-local t)
 
-(defun basic-save-buffer ()
+(defun basic-save-buffer (&optional called-interactively)
   "Save the current buffer in its visited file, if it has been modified.
 The hooks `write-contents-functions' and `write-file-functions' get a chance
 to do the job of saving; if they do not, then the buffer is saved in
 the visited file in the usual way.
 Before and after saving the buffer, this function runs
 `before-save-hook' and `after-save-hook', respectively."
-  (interactive)
+  (interactive '(called-interactively))
   (save-current-buffer
     ;; In an indirect buffer, save its base buffer instead.
     (if (buffer-base-buffer)
@@ -4800,7 +4800,7 @@ Before and after saving the buffer, this function runs
          (vc-after-save)
          (run-hooks 'after-save-hook))
       (or noninteractive
-          (not (called-interactively-p 'any))
+          (not called-interactively)
           (files--message "(No changes need to be saved)")))))
 
 ;; This does the "real job" of writing a buffer into its visited file
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 1371e70..8bb0a78 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -3997,8 +3997,6 @@ This function uses `mail-citation-hook' if that is 
non-nil."
   "Cite function in the standard Message manner."
   (message-cite-original-1 nil))
 
-(defvar gnus-extract-address-components)
-
 (autoload 'format-spec "format-spec")
 (autoload 'gnus-date-get-time "gnus-util")
 
@@ -4020,7 +4018,7 @@ See `message-citation-line-format'."
     (unless from
       (setq from (mail-header-from message-reply-headers)))
     (let* ((data (condition-case ()
-                    (funcall (if (boundp gnus-extract-address-components)
+                    (funcall (if (boundp 'gnus-extract-address-components)
                                  gnus-extract-address-components
                                'mail-extract-address-components)
                              from)
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 53f4b38..9020037 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -54,20 +54,22 @@ The functions will receive the function name as argument.")
                                (and fn (symbol-name fn))))
      (list (if (equal val "")
               fn (intern val)))))
-  (if (null function)
-      (message "You didn't specify a function")
-    (help-setup-xref (list #'describe-function function)
-                    (called-interactively-p 'interactive))
-    (save-excursion
-      (with-help-window (help-buffer)
-       (prin1 function)
-       ;; Use " is " instead of a colon so that
-       ;; it is easier to get out the function name using forward-sexp.
-       (princ " is ")
-       (describe-function-1 function)
-       (with-current-buffer standard-output
-         ;; Return the text we displayed.
-         (buffer-string))))))
+  (or (and function (symbolp function))
+      (user-error "You didn't specify a function symbol"))
+  (or (fboundp function)
+      (user-error "Symbol's function definition is void: %s" function))
+  (help-setup-xref (list #'describe-function function)
+                   (called-interactively-p 'interactive))
+  (save-excursion
+    (with-help-window (help-buffer)
+      (prin1 function)
+      ;; Use " is " instead of a colon so that
+      ;; it is easier to get out the function name using forward-sexp.
+      (princ " is ")
+      (describe-function-1 function)
+      (with-current-buffer standard-output
+        ;; Return the text we displayed.
+        (buffer-string)))))
 
 
 ;; Could be this, if we make symbol-file do the work below.
@@ -479,7 +481,8 @@ FILE is the file where FUNCTION was probably defined."
              function))
         ;; Get the real definition.
         (def (if (symbolp real-function)
-                 (symbol-function real-function)
+                 (or (symbol-function real-function)
+                     (signal 'void-function (list real-function)))
                real-function))
         (aliased (or (symbolp def)
                      ;; Advised & aliased function.
diff --git a/lisp/info.el b/lisp/info.el
index 057bd77..05574ae 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -632,7 +632,7 @@ Do the right thing if the file has been compressed or 
zipped."
                                       default-directory)))
            (or (consp decoder)
                (setq decoder (list decoder)))
-           (apply 'call-process-region (point-min) (point-max)
+           (apply #'call-process-region (point-min) (point-max)
                   (car decoder) t t nil (cdr decoder))))
       (let ((inhibit-null-byte-detection t)) ; Index nodes include null bytes
        (insert-file-contents fullname visit)))
@@ -1422,10 +1422,10 @@ is non-nil)."
            (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
          ;; Merge the text from the other buffer's menu
          ;; into the menu in the like-named node in the main buffer.
-         (apply 'insert-buffer-substring (cdr node))))
+         (apply #'insert-buffer-substring (cdr node))))
       (Info-dir-remove-duplicates)
       ;; Kill all the buffers we just made, including the special one excised.
-      (mapc 'kill-buffer (cons buffer buffers))
+      (mapc #'kill-buffer (cons buffer buffers))
       (goto-char (point-min))
       (if problems
          (message "Composing main Info directory...problems encountered, see 
`*Messages*'")
@@ -1810,10 +1810,10 @@ See `completing-read' for a description of arguments 
and usage."
    ((string-match "\\`([^)]*\\'" string)
     (completion-table-with-context
      "("
-     (apply-partially 'completion-table-with-terminator ")"
-                      (apply-partially 'Info-read-node-name-2
+     (apply-partially #'completion-table-with-terminator ")"
+                      (apply-partially #'Info-read-node-name-2
                                        Info-directory-list
-                                       (mapcar 'car Info-suffix-list)))
+                                       (mapcar #'car Info-suffix-list)))
      (substring string 1)
      predicate
      code))
@@ -1827,12 +1827,11 @@ See `completing-read' for a description of arguments 
and usage."
          t
        (completion-table-with-context
         file0
-        (apply-partially
-         (lambda (string pred action)
-           (complete-with-action
-            action
-            (Info-build-node-completions (Info-find-file file1))
-            string pred)))
+         (lambda (string pred action)
+           (complete-with-action
+            action
+            (Info-build-node-completions (Info-find-file file1))
+            string pred))
         nodename predicate code))))
    ;; Otherwise use Info-read-node-completion-table.
    (t (complete-with-action
@@ -2750,7 +2749,8 @@ new buffer."
              (end-of-line)
              (if (re-search-backward (concat "\n\\* +\\("
                                              Info-menu-entry-name-re
-                                             "\\):") beg t)
+                                             "\\):")
+                                      beg t)
                  (setq default (match-string-no-properties 1))))))
      (let ((item nil))
        (while (null item)
@@ -2760,7 +2760,8 @@ new buffer."
                                           (format "Menu item (default %s): "
                                                   default)
                                         "Menu item: ")
-                                      'Info-complete-menu-item nil t)))
+                                      #'Info-complete-menu-item nil t nil nil
+                                       default)))
         ;; we rely on the fact that completing-read accepts an input
         ;; of "" even when the require-match argument is true and ""
         ;; is not a valid possibility
@@ -3496,7 +3497,7 @@ MATCHES is a list of index matches found by 
`Info-apropos-matches'.")
 
 (defun Info-apropos-toc-nodes (filename)
   "Apropos-specific implementation of `Info-toc-nodes'."
-  (let ((nodes (mapcar 'car (reverse Info-apropos-nodes))))
+  (let ((nodes (mapcar #'car (reverse Info-apropos-nodes))))
     `(,filename
       ("Top" nil nil ,nodes)
       ,@(mapcar (lambda (node) `(,node "Top" nil nil)) nodes))))
@@ -3709,13 +3710,13 @@ Build a menu of the possible matches."
      "The following packages match the keyword `" nodename "':\n\n")
     (insert "* Menu:\n\n")
     (let ((keywords
-          (mapcar 'intern (if (string-match-p "," nodename)
+          (mapcar #'intern (if (string-match-p "," nodename)
                               (split-string nodename ",[ \t\n]*" t)
                             (list nodename))))
          hits desc)
       (dolist (keyword keywords)
        (push (copy-tree (gethash keyword finder-keywords-hash)) hits))
-      (setq hits (delete-dups (apply 'append hits))
+      (setq hits (delete-dups (apply #'append hits))
            ;; Not a meaningful package.
            hits (delete 'emacs hits)
            hits (sort hits (lambda (a b) (string< (symbol-name a)
@@ -3766,8 +3767,8 @@ with a list of packages that contain all specified 
keywords."
      (list
       (completing-read-multiple
        "Keywords (separated by comma): "
-       (mapcar 'symbol-name (mapcar 'car (append finder-known-keywords
-                                                (finder-unknown-keywords))))
+       (mapcar #'symbol-name (mapcar #'car (append finder-known-keywords
+                                                   (finder-unknown-keywords))))
        nil t))))
   (require 'finder)
   (if keywords
@@ -5322,9 +5323,9 @@ completion alternatives to currently visited manuals."
                         (when (not visited-only)
                           (all-completions
                            ""
-                           (apply-partially 'Info-read-node-name-2
+                           (apply-partially #'Info-read-node-name-2
                                             Info-directory-list
-                                            (mapcar 'car 
Info-suffix-list))))))))
+                                            (mapcar #'car 
Info-suffix-list))))))))
 
 (provide 'info)
 
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 74533f8..bf439ec 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -2127,7 +2127,7 @@ Value is the size of the newly read mail after 
conversion."
 Call with point at the end of the message."
   (unless (bolp)
     (insert "\n"))
-  (unless (looking-back "\n\n" (- (point 2)))
+  (unless (looking-back "\n\n" (- (point) 2))
     (insert "\n")))
 
 (defun rmail-add-mbox-headers ()
@@ -2942,7 +2942,8 @@ buffer to the end of the headers."
                              (1+ (match-beginning 0))
                            (point-max))))
              (if (and (looking-at ignored-headers)
-                      (not (looking-at rmail-nonignored-headers)))
+                      (not (and rmail-nonignored-headers
+                                (looking-at rmail-nonignored-headers))))
                  (goto-char lim)
                (append-to-buffer rmail-view-buffer (point) lim)
                (goto-char lim))))
@@ -3830,7 +3831,8 @@ use \\[mail-yank-original] to yank the original message 
into it."
 ;;;      (setq cc resent-cc)))
     ;; Add `Re: ' to subject if not there already.
     (and (stringp subject)
-        (setq subject
+        (setq subject (rfc2047-decode-string subject)
+              subject
               (concat rmail-reply-prefix
                       (if (let ((case-fold-search t))
                             (string-match rmail-reply-regexp subject))
@@ -4691,7 +4693,7 @@ encoded string (and the same mask) will decode the 
string."
 
 ;;; Start of automatically extracted autoloads.
 
-;;;### (autoloads nil "rmailedit" "rmailedit.el" 
"f6da7267316d02c90b9d314ce95b3c22")
+;;;### (autoloads nil "rmailedit" "rmailedit.el" 
"1ed1c211e6e9c254ba3e0dd8d546e745")
 ;;; Generated autoloads from rmailedit.el
 
 (autoload 'rmail-edit-current-message "rmailedit" "\
diff --git a/lisp/mail/rmailedit.el b/lisp/mail/rmailedit.el
index 15d27a0..0b49782 100644
--- a/lisp/mail/rmailedit.el
+++ b/lisp/mail/rmailedit.el
@@ -44,6 +44,8 @@
 
 (declare-function rmail-summary-disable "rmailsum" ())
 
+;; We can't straightforwardly make this derive from text-mode, because
+;; we need to bind (rmail-buffer-swapped) around the text-mode call.  :(
 (defun rmail-edit-mode ()
   "Major mode for editing the contents of an Rmail message.
 The editing commands are the same as in Text mode, together with
diff --git a/lisp/midnight.el b/lisp/midnight.el
index dbf0c02..256ab9c 100644
--- a/lisp/midnight.el
+++ b/lisp/midnight.el
@@ -1,4 +1,4 @@
-;;; midnight.el --- run something every midnight, e.g., kill old buffers
+;;; midnight.el --- run something every midnight, e.g., kill old buffers  -*- 
lexical-binding:t -*-
 
 ;; Copyright (C) 1998, 2001-2015 Free Software Foundation, Inc.
 
@@ -36,7 +36,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
+(require 'cl-lib)
 
 (defgroup midnight nil
   "Run something every day at midnight."
@@ -48,24 +48,19 @@
 Use `cancel-timer' to stop it and `midnight-delay-set' to change
 the time when it is run.")
 
-(defcustom midnight-mode nil
-  "Non-nil means run `midnight-hook' at midnight.
-Setting this variable outside customize has no effect;
-call `cancel-timer' or `timer-activate' on `midnight-timer' instead."
-  :type 'boolean
-  :group 'midnight
-  :require 'midnight
-  :initialize 'custom-initialize-default
-  :set (lambda (symb val)
-         (set symb val) (require 'midnight)
-         (if val (timer-activate midnight-timer)
-             (cancel-timer midnight-timer))))
+;;;###autoload
+(define-minor-mode midnight-mode
+  "Non-nil means run `midnight-hook' at midnight."
+  :global t
+  :initialize #'custom-initialize-default
+  (if midnight-mode (timer-activate midnight-timer)
+    (cancel-timer midnight-timer)))
 
 ;;; time conversion
 
-(defun midnight-buffer-display-time (&optional buffer)
+(defun midnight-buffer-display-time (buffer)
   "Return the time-stamp of BUFFER, or current buffer, as float."
-  (with-current-buffer (or buffer (current-buffer))
+  (with-current-buffer buffer
     (when buffer-display-time (float-time buffer-display-time))))
 
 ;;; clean-buffer-list stuff
@@ -76,18 +71,16 @@ The autokilling is done by `clean-buffer-list' when is it 
in `midnight-hook'.
 Currently displayed and/or modified (unsaved) buffers, as well as buffers
 matching `clean-buffer-list-kill-never-buffer-names' and
 `clean-buffer-list-kill-never-regexps' are excluded."
-  :type 'integer
-  :group 'midnight)
+  :type 'integer)
 
 (defcustom clean-buffer-list-delay-special 3600
   "The number of seconds before some buffers become eligible for autokilling.
 Buffers matched by `clean-buffer-list-kill-regexps' and
 `clean-buffer-list-kill-buffer-names' are killed if they were last
 displayed more than this many seconds ago."
-  :type 'integer
-  :group 'midnight)
+  :type 'integer)
 
-(defcustom clean-buffer-list-kill-regexps '("^\\*Man ")
+(defcustom clean-buffer-list-kill-regexps '("\\`\\*Man ")
   "List of regexps saying which buffers will be killed at midnight.
 If buffer name matches a regexp in the list and the buffer was not displayed
 in the last `clean-buffer-list-delay-special' seconds, it is killed by
@@ -96,9 +89,14 @@ If a member of the list is a cons, its `car' is the regexp 
and its `cdr' is
 the number of seconds to use instead of `clean-buffer-list-delay-special'.
 See also `clean-buffer-list-kill-buffer-names',
 `clean-buffer-list-kill-never-regexps' and
-`clean-buffer-list-kill-never-buffer-names'."
-  :type '(repeat (regexp :tag "Regexp matching Buffer Name"))
-  :group 'midnight)
+`clean-buffer-list-kill-never-buffer-names'.
+
+Each element can also be a function instead of a regexp, in which case
+it takes a single argument (a buffer name) and should return non-nil
+if the buffer should be killed by `clean-buffer-list'."
+  :type '(repeat
+          (choice (regexp :tag "Regexp matching Buffer Name")
+                  (function :tag "Predicate function"))))
 
 (defcustom clean-buffer-list-kill-buffer-names
     '("*Help*" "*Apropos*" "*Buffer List*" "*Compile-Log*" "*info*"
@@ -112,8 +110,7 @@ the number of seconds to use instead of 
`clean-buffer-list-delay-special'.
 See also `clean-buffer-list-kill-regexps',
 `clean-buffer-list-kill-never-regexps' and
 `clean-buffer-list-kill-never-buffer-names'."
-  :type '(repeat (string :tag "Buffer Name"))
-  :group 'midnight)
+  :type '(repeat (string :tag "Buffer Name")))
 
 (defcustom clean-buffer-list-kill-never-buffer-names
     '("*scratch*" "*Messages*")
@@ -122,33 +119,34 @@ See also `clean-buffer-list-kill-never-regexps'.
 Note that this does override `clean-buffer-list-kill-regexps' and
 `clean-buffer-list-kill-buffer-names' so a buffer matching any of these
 two lists will NOT be killed if it is also present in this list."
-  :type '(repeat (string :tag "Buffer Name"))
-  :group 'midnight)
+  :type '(repeat (string :tag "Buffer Name")))
 
-(defcustom clean-buffer-list-kill-never-regexps '("^ \\*Minibuf-.*\\*$")
+(defcustom clean-buffer-list-kill-never-regexps '("\\` \\*Minibuf-.*\\*\\'")
   "List of regexp saying which buffers will never be killed at midnight.
 See also `clean-buffer-list-kill-never-buffer-names'.
 Killing is done by `clean-buffer-list'.
 Note that this does override `clean-buffer-list-kill-regexps' and
 `clean-buffer-list-kill-buffer-names' so a buffer matching any of these
-two lists will NOT be killed if it also matches anything in this list."
-  :type '(repeat (regexp :tag "Regexp matching Buffer Name"))
-  :group 'midnight)
+two lists will NOT be killed if it also matches anything in this list.
 
-(defun midnight-find (el ls test &optional key)
-  "A stopgap solution to the absence of `find' in ELisp."
-  (cl-dolist (rr ls)
-    (when (funcall test (if key (funcall key rr) rr) el)
-      (cl-return rr))))
+Each element can also be a function instead of a regexp, in which case
+it takes a single argument (a buffer name) and should return non-nil
+if the buffer should never be killed by `clean-buffer-list'."
+  :type '(repeat
+          (choice (regexp :tag "Regexp matching Buffer Name")
+                  (function :tag "Predicate function"))))
 
 (defun clean-buffer-list-delay (name)
   "Return the delay, in seconds, before killing a buffer named NAME.
 Uses `clean-buffer-list-kill-buffer-names', `clean-buffer-list-kill-regexps'
 `clean-buffer-list-delay-general' and `clean-buffer-list-delay-special'.
 Autokilling is done by `clean-buffer-list'."
-  (or (assoc-default name clean-buffer-list-kill-buffer-names 'string=
+  (or (assoc-default name clean-buffer-list-kill-buffer-names #'string=
                      clean-buffer-list-delay-special)
-      (assoc-default name clean-buffer-list-kill-regexps 'string-match
+      (assoc-default name clean-buffer-list-kill-regexps
+                     (lambda (re str)
+                       (if (functionp re)
+                           (funcall re str) (string-match re str)))
                      clean-buffer-list-delay-special)
       (* clean-buffer-list-delay-general 24 60 60)))
 
@@ -172,10 +170,13 @@ lifetime, i.e., its \"age\" when it will be purged."
        (setq bts (midnight-buffer-display-time buf) bn (buffer-name buf)
              delay (if bts (- tm bts) 0) cbld (clean-buffer-list-delay bn))
        (message "[%s] `%s' [%s %d]" ts bn (if bts (round delay)) cbld)
-       (unless (or (midnight-find bn clean-buffer-list-kill-never-regexps
-                                  'string-match)
-                   (midnight-find bn clean-buffer-list-kill-never-buffer-names
-                                  'string-equal)
+       (unless (or (cl-find bn clean-buffer-list-kill-never-regexps
+                             :test (lambda (bn re)
+                                     (if (functionp re)
+                                         (funcall re bn)
+                                       (string-match re bn))))
+                   (cl-find bn clean-buffer-list-kill-never-buffer-names
+                             :test #'string-equal)
                    (get-buffer-process buf)
                    (and (buffer-file-name buf) (buffer-modified-p buf))
                    (get-buffer-window buf 'visible) (< delay cbld))
@@ -190,8 +191,7 @@ lifetime, i.e., its \"age\" when it will be purged."
 (defcustom midnight-hook '(clean-buffer-list)
   "The hook run `midnight-delay' seconds after midnight every day.
 The default value is `clean-buffer-list'."
-  :type 'hook
-  :group 'midnight)
+  :type 'hook)
 
 (defun midnight-next ()
   "Return the number of seconds till the next midnight."
@@ -209,7 +209,7 @@ to its second argument TM."
   (when (timerp midnight-timer) (cancel-timer midnight-timer))
   (setq midnight-timer
         (run-at-time (if (numberp tm) (+ (midnight-next) tm) tm)
-                     midnight-period 'run-hooks 'midnight-hook)))
+                     midnight-period #'run-hooks 'midnight-hook)))
 
 (defcustom midnight-delay 3600
   "The number of seconds after the midnight when the `midnight-timer' is run.
@@ -218,8 +218,7 @@ set it by calling `midnight-delay-set', or use `custom'.
 If you wish, you can use a string instead, it will be passed as the
 first argument to `run-at-time'."
   :type 'sexp
-  :set 'midnight-delay-set
-  :group 'midnight)
+  :set #'midnight-delay-set)
 
 (provide 'midnight)
 
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 5f3fa5d..7854d32 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -152,13 +152,16 @@ items `Turn Off' and `Help'."
       (setq menu
             (if menu
                 (mouse-menu-non-singleton menu)
-             `(keymap
-                ,indicator
-                (turn-off menu-item "Turn Off minor mode" ,mm-fun)
-                (help menu-item "Help for minor mode"
-                      (lambda () (interactive)
-                        (describe-function ',mm-fun))))))
-      (popup-menu menu))))
+              (if (fboundp mm-fun)      ; bug#20201
+                  `(keymap
+                    ,indicator
+                    (turn-off menu-item "Turn Off minor mode" ,mm-fun)
+                    (help menu-item "Help for minor mode"
+                          (lambda () (interactive)
+                            (describe-function ',mm-fun)))))))
+      (if menu
+          (popup-menu menu)
+        (message "No menu available")))))
 
 (defun mouse-minor-mode-menu (event)
   "Show minor-mode menu for EVENT on minor modes area of the mode line."
diff --git a/lisp/net/eudc-vars.el b/lisp/net/eudc-vars.el
index 36a583d..5e994a3 100644
--- a/lisp/net/eudc-vars.el
+++ b/lisp/net/eudc-vars.el
@@ -312,9 +312,11 @@ arguments that should be passed to the program."
                        :inline t
                        (string :tag "Argument")))))
 
-(defcustom eudc-options-file "~/.eudc-options"
+(defcustom eudc-options-file
+  (locate-user-emacs-file "eudc-options" ".eudc-options")
   "A file where the `servers' hotlist is stored."
-  :type '(file :Tag "File Name:"))
+  :type '(file :Tag "File Name:")
+  :version "25.1")
 
 (defcustom eudc-mode-hook nil
   "Normal hook run on entry to EUDC mode."
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 9d88d1f..454332e 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -709,6 +709,9 @@ size, and full-buffer size."
          shr-base))
   (when (zerop (length url))
     (setq url nil))
+  ;; Strip leading whitespace
+  (and url (string-match "\\`\\s-+" url)
+       (setq url (substring url (match-end 0))))
   (cond ((or (not url)
             (not base)
             (string-match "\\`[a-z]*:" url))
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index ad35c48..f289068 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -30,7 +30,6 @@
 
 (require 'lisp-mode)
 
-(defvar emacs-lisp-mode-abbrev-table nil)
 (define-abbrev-table 'emacs-lisp-mode-abbrev-table ()
   "Abbrev table for Emacs Lisp mode.
 It has `lisp-mode-abbrev-table' as its parent."
@@ -1164,7 +1163,10 @@ or elsewhere, return a 1-line docstring."
                  (args
                   (cond
                    ((listp advertised) advertised)
-                   ((setq doc (help-split-fundoc (documentation sym t) sym))
+                   ((setq doc (help-split-fundoc
+                               (condition-case nil (documentation sym t)
+                                 (invalid-function nil))
+                               sym))
                     (car doc))
                    (t (help-function-arglist sym)))))
              ;; Stringify, and store before highlighting, downcasing, etc.
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index afcbbf5..9f10686 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -276,6 +276,15 @@ backward."
   :type 'integer
   :version "25.1")
 
+(defcustom xref-prompt-for-identifier nil
+  "When non-nil, always prompt for the identifier name.
+
+Otherwise, only prompt when there's no value at point we can use,
+or when the command has been called with the prefix argument."
+  :type '(choice (const :tag "always" t)
+                 (const :tag "auto" nil))
+  :version "25.1")
+
 (defvar xref--marker-ring (make-ring xref-marker-ring-length)
   "Ring of markers to implement the marker stack.")
 
@@ -559,11 +568,11 @@ Return an alist of the form ((FILENAME . (XREF ...)) 
...)."
 (defun xref--read-identifier (prompt)
   "Return the identifier at point or read it from the minibuffer."
   (let ((id (funcall xref-identifier-at-point-function)))
-    (cond ((or current-prefix-arg (not id))
+    (cond ((or current-prefix-arg xref-prompt-for-identifier (not id))
            (completing-read prompt
                             (funcall xref-identifier-completion-table-function)
-                            nil t id
-                            'xref--read-identifier-history))
+                            nil t nil
+                            'xref--read-identifier-history id))
           (t id))))
 
 
diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index 4c53632..fe54743 100644
--- a/lisp/saveplace.el
+++ b/lisp/saveplace.el
@@ -50,28 +50,10 @@ visiting file FILENAME goes automatically to position 
POSITION
 rather than the beginning of the buffer.
 This alist is saved between Emacs sessions.")
 
-(defcustom save-place nil
-  "Non-nil means automatically save place in each file.
-This means when you visit a file, point goes to the last place
-where it was when you previously visited the same file.
-
-If you wish your place in any file to always be automatically
-saved, set this to t using the Customize facility, or put the
-following code in your init file:
-
-\(setq-default save-place t)
-\(require 'saveplace)"
-  :type 'boolean
-  :require 'saveplace
-  :group 'save-place)
-
-(make-variable-buffer-local 'save-place)
-
 (defcustom save-place-file (locate-user-emacs-file "places" ".emacs-places")
   "Name of the file that records `save-place-alist' value."
   :version "24.4"                       ; added locate-user-emacs-file
-  :type 'file
-  :group 'save-place)
+  :type 'file)
 
 (defcustom save-place-version-control nil
   "Controls whether to make numbered backups of master save-place file.
@@ -82,8 +64,7 @@ value of `version-control'."
   :type '(radio (const :tag "Unconditionally" t)
                (const :tag "For VC Files" nil)
                (const never)
-               (const :tag "Use value of `version-control'" nospecial))
-  :group 'save-place)
+               (const :tag "Use value of `version-control'" nospecial)))
 
 (defvar save-place-loaded nil
   "Non-nil means that the `save-place-file' has been loaded.")
@@ -92,8 +73,7 @@ value of `version-control'."
   "Maximum number of entries to retain in the list; nil means no limit."
   :version "24.1"                       ; nil -> 400
   :type '(choice (integer :tag "Entries" :value 1)
-                (const :tag "No Limit" nil))
-  :group 'save-place)
+                (const :tag "No Limit" nil)))
 
 (defcustom save-place-forget-unreadable-files t
   "Non-nil means forget place in unreadable files.
@@ -106,7 +86,7 @@ You may do this anytime by calling the complementary 
function,
 `save-place-forget-unreadable-files'.  When this option is turned on,
 this happens automatically before saving `save-place-alist' to
 `save-place-file'."
-  :type 'boolean :group 'save-place)
+  :type 'boolean)
 
 (defcustom save-place-save-skipped t
   "If non-nil, remember files matching `save-place-skip-check-regexp'.
@@ -114,7 +94,7 @@ this happens automatically before saving `save-place-alist' 
to
 When filtering `save-place-alist' for unreadable files, some will not
 be checked, based on said regexp, and instead saved or forgotten based
 on this flag."
-  :type 'boolean :group 'save-place)
+  :type 'boolean)
 
 (defcustom save-place-skip-check-regexp
   ;; thanks to ange-ftp-name-format
@@ -127,7 +107,7 @@ subject to `save-place-save-skipped'.
 
 Files for which such a check may be inconvenient include those on
 removable and network volumes."
-  :type 'regexp :group 'save-place)
+  :type 'regexp)
 
 (defcustom save-place-ignore-files-regexp
   
"\\(?:COMMIT_EDITMSG\\|hg-editor-[[:alnum:]]+\\.txt\\|svn-commit\\.tmp\\|bzr_log\\.[[:alnum:]]+\\)$"
@@ -136,11 +116,34 @@ Useful for temporary file such as commit message files 
that are
 automatically created by the VCS.  If set to nil, this feature is
 disabled, i.e., the position is recorded for all files."
   :version "24.1"
-  :type 'regexp :group 'save-place)
+  :type 'regexp)
 
 (declare-function dired-current-directory "dired" (&optional localp))
 
-(defun toggle-save-place (&optional parg)
+(define-obsolete-variable-alias 'save-place 'save-place-mode "25.1")
+;;;###autoload
+(define-minor-mode save-place-mode
+  "Non-nil means automatically save place in each file.
+This means when you visit a file, point goes to the last place
+where it was when you previously visited the same file."
+  :global t
+  :group 'save-place
+  (cond
+   (save-place-mode
+    (add-hook 'find-file-hook 'save-place-find-file-hook t)
+    (add-hook 'dired-initial-position-hook 'save-place-dired-hook)
+    (unless noninteractive
+      (add-hook 'kill-emacs-hook 'save-place-kill-emacs-hook))
+    (add-hook 'kill-buffer-hook 'save-place-to-alist))
+   (t
+    (remove-hook 'find-file-hook 'save-place-find-file-hook t)
+    (remove-hook 'dired-initial-position-hook 'save-place-dired-hook)
+    (remove-hook 'kill-emacs-hook 'save-place-kill-emacs-hook)
+    (remove-hook 'kill-buffer-hook 'save-place-to-alist))))
+
+(make-variable-buffer-local 'save-place-mode) ; Hysterical raisins.
+
+(defun toggle-save-place (&optional parg) ;FIXME: save-place-local-mode!
   "Toggle whether to save your place in this file between sessions.
 If this mode is enabled, point is recorded when you kill the buffer
 or exit Emacs.  Visiting this file again will go to that position,
@@ -353,15 +356,5 @@ may have changed) back to `save-place-alist'."
   (if save-place-loaded
       (save-place-alist-to-file)))
 
-(add-hook 'find-file-hook 'save-place-find-file-hook t)
-
-(add-hook 'dired-initial-position-hook 'save-place-dired-hook)
-
-(unless noninteractive
-  (add-hook 'kill-emacs-hook 'save-place-kill-emacs-hook))
-
-(add-hook 'kill-buffer-hook 'save-place-to-alist)
-
-(provide 'saveplace) ; why not...
-
+(provide 'saveplace)
 ;;; saveplace.el ends here
diff --git a/lisp/server.el b/lisp/server.el
index 9585b17..29d2160 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -245,6 +245,7 @@ in this way."
   :type 'boolean
   :version "21.1")
 
+;; FIXME? This is not a minor mode; what's the point of this?  (See bug#20201)
 (or (assq 'server-buffer-clients minor-mode-alist)
     (push '(server-buffer-clients " Server") minor-mode-alist))
 
diff --git a/lisp/subr.el b/lisp/subr.el
index 1d41e01..0fec29c 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1733,7 +1733,7 @@ this instead of `run-hooks' when running their 
FOO-mode-hook."
 (defmacro delay-mode-hooks (&rest body)
   "Execute BODY, but delay any `run-mode-hooks'.
 These hooks will be executed by the first following call to
-`run-mode-hooks' that occurs outside any `delayed-mode-hooks' form.
+`run-mode-hooks' that occurs outside any `delay-mode-hooks' form.
 Only affects hooks run in the current buffer."
   (declare (debug t) (indent 0))
   `(progn
@@ -2814,17 +2814,18 @@ remove properties specified by 
`yank-excluded-properties'."
   (let ((inhibit-read-only t))
     (dolist (handler yank-handled-properties)
       (let ((prop (car handler))
-           (fun  (cdr handler))
-           (run-start start))
-       (while (< run-start end)
-         (let ((value (get-text-property run-start prop))
-               (run-end (next-single-property-change
-                         run-start prop nil end)))
-           (funcall fun value run-start run-end)
-           (setq run-start run-end)))))
-    (if (eq yank-excluded-properties t)
-       (set-text-properties start end nil)
-      (remove-list-of-text-properties start end yank-excluded-properties))))
+            (fun  (cdr handler))
+            (run-start start))
+        (while (< run-start end)
+          (let ((value (get-text-property run-start prop))
+                (run-end (next-single-property-change
+                          run-start prop nil end)))
+            (funcall fun value run-start run-end)
+            (setq run-start run-end)))))
+    (with-silent-modifications
+      (if (eq yank-excluded-properties t)
+          (set-text-properties start end nil)
+        (remove-list-of-text-properties start end yank-excluded-properties)))))
 
 (defvar yank-undo-function)
 
@@ -3730,7 +3731,8 @@ REP is either a string used as the NEWTEXT arg of 
`replace-match' or a
 function.  If it is a function, it is called with the actual text of each
 match, and its value is used as the replacement text.  When REP is called,
 the match data are the result of matching REGEXP against a substring
-of STRING.
+of STRING, the same substring that is the actual text of the match which
+is passed to REP as its argument.
 
 To replace only the first match (if any), make REGEXP match up to \\'
 and replace a sub-expression, e.g.
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 8a01852..10edefc 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -2229,7 +2229,7 @@ Optional arg COMMA is as in `bibtex-enclosing-field'."
                        bibtex-entry-kill-ring))
       ;; If we copied an entry from a buffer containing only this one entry,
       ;; it can be missing the second "\n".
-      (unless (looking-back "\n\n" (- (point 2))) (insert "\n"))
+      (unless (looking-back "\n\n" (- (point) 2)) (insert "\n"))
       (unless (functionp bibtex-reference-keys)
         ;; update `bibtex-reference-keys'
         (save-excursion
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 498def0..43003af 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -2986,10 +2986,14 @@ Keeps argument list for future Ispell invocations for 
no async support."
               (or ispell-local-dictionary ispell-dictionary "default"))
       (sit-for 0)
       (setq ispell-library-directory (ispell-check-version)
+            ;; Assign a non-nil value to ispell-process-directory
+            ;; before calling ispell-start-process, since that
+            ;; function needs it to set default-directory when
+            ;; ispell-async-processp is nil.
+           ispell-process-directory default-directory
            ispell-process (ispell-start-process)
            ispell-filter nil
-           ispell-filter-continue nil
-           ispell-process-directory default-directory)
+           ispell-filter-continue nil)
 
       (unless (equal ispell-process-directory (expand-file-name "~/"))
        ;; At this point, `ispell-process-directory' will be "~/" unless using
@@ -3015,7 +3019,12 @@ Keeps argument list for future Ispell invocations for no 
async support."
       (if (and (or (featurep 'xemacs)
                   (and (boundp 'enable-multibyte-characters)
                        enable-multibyte-characters))
-              (fboundp 'set-process-coding-system))
+              (fboundp 'set-process-coding-system)
+               ;; Evidently, some people use the synchronous mode even
+               ;; when async subprocesses are supported, in which case
+               ;; set-process-coding-system is bound, but
+               ;; ispell-process is not a process object.
+               ispell-async-processp)
          (set-process-coding-system ispell-process (ispell-get-coding-system)
                                     (ispell-get-coding-system)))
       ;; Get version ID line
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index fa09efb..b22e8b1 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -197,7 +197,7 @@ Return list with entries."
              "[" default "]: ")
             (if reftex-mode
                 (if (fboundp 'LaTeX-bibitem-list)
-                    (LaTeX-bibitem-list)
+                    (or (LaTeX-bibitem-list) '(""))
                   (cdr (assoc 'bibview-cache
                               (symbol-value reftex-docstruct-symbol))))
               nil)
@@ -228,11 +228,11 @@ Return list with entries."
               (message "No such BibTeX file %s (ignored)" buffer)
             (message "Scanning bibliography database %s" buffer1)
            (unless (verify-visited-file-modtime buffer1)
-                (when (y-or-n-p
-                       (format "File %s changed on disk.  Reread from disk? "
-                               (file-name-nondirectory
-                                (buffer-file-name buffer1))))
-                  (with-current-buffer buffer1 (revert-buffer t t)))))
+              (when (y-or-n-p
+                     (format "File %s changed on disk.  Reread from disk? "
+                             (file-name-nondirectory
+                              (buffer-file-name buffer1))))
+                (with-current-buffer buffer1 (revert-buffer t t)))))
 
           (set-buffer buffer1)
           (reftex-with-special-syntax-for-bib
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index 085f2d7..d51fb9b 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -190,8 +190,11 @@ M-%        Global search and replace to rename label at 
point.
 x          Switch to TOC of external document (with LaTeX package `xr').
 z          Jump to a specific section (e.g. '3 z' goes to section 3).")
 
+(defvar reftex--rebuilding-toc nil)
+
 ;;;###autoload
-(defun reftex-toc (&optional rebuild reuse)
+(defun reftex-toc (&optional _rebuild reuse)
+  ;; FIXME: Get rid of the `rebuild' argument.
   "Show the table of contents for the current document.
 When called with a raw C-u prefix, rescan the document first."
 
@@ -201,6 +204,9 @@ When called with a raw C-u prefix, rescan the document 
first."
   (interactive)
 
   (if (or (not (string= reftex-last-toc-master (reftex-TeX-master-file)))
+          ;; FIXME: use (interactive "P") to receive current-prefix-arg as
+          ;; an argument instead of using the var here, which forces us to set
+          ;; current-prefix-arg in the callers.
           current-prefix-arg)
       (reftex-erase-buffer "*toc*"))
 
@@ -225,7 +231,7 @@ When called with a raw C-u prefix, rescan the document 
first."
          (docstruct-symbol reftex-docstruct-symbol)
          (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol)))
          (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
-         (here-I-am (if (boundp 'reftex-rebuilding-toc)
+         (here-I-am (if reftex--rebuilding-toc
                         (get 'reftex-toc :reftex-data)
                       (car (reftex-where-am-I))))
          (unsplittable (if (fboundp 'frame-property)
@@ -414,17 +420,17 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels 
[f]ollow [x]r [?]Help
   (if reftex-toc-follow-mode
       (setq reftex-toc-follow-mode 1)))
 
-(defun reftex-toc-next (&optional arg)
+(defun reftex-toc-next (&optional _arg)
   "Move to next selectable item."
-  (interactive "p")
+  (interactive)
   (when (featurep 'xemacs) (setq zmacs-region-stays t))
   (setq reftex-callback-fwd t)
   (or (eobp) (forward-char 1))
   (goto-char (or (next-single-property-change (point) :data)
                  (point))))
-(defun reftex-toc-previous (&optional arg)
+(defun reftex-toc-previous (&optional _arg)
   "Move to previous selectable item."
-  (interactive "p")
+  (interactive)
   (when (featurep 'xemacs) (setq zmacs-region-stays t))
   (setq reftex-callback-fwd nil)
   (goto-char (or (previous-single-property-change (point) :data)
@@ -558,7 +564,7 @@ With prefix arg 1, restrict index to the section at point."
     (reftex-display-index (if restr nil arg) restr)))
 
 ;; Rescanning the document and rebuilding the TOC buffer.
-(defun reftex-toc-rescan (&rest ignore)
+(defun reftex-toc-rescan (&rest _)
   "Regenerate the *toc* buffer by reparsing file of section at point."
   (interactive)
   (if (and reftex-enable-partial-scans
@@ -576,12 +582,12 @@ With prefix arg 1, restrict index to the section at 
point."
           (switch-to-buffer-other-window
            (reftex-get-file-buffer-force file))
           (setq current-prefix-arg '(4))
-          (let ((reftex-rebuilding-toc t))
+          (let ((reftex--rebuilding-toc t))
             (reftex-toc))))
     (reftex-toc-Rescan))
   (reftex-kill-temporary-buffers))
 
-(defun reftex-toc-Rescan (&rest ignore)
+(defun reftex-toc-Rescan (&rest _)
   "Regenerate the *toc* buffer by reparsing the entire document."
   (interactive)
   (let* ((line (+ (count-lines (point-min) (point)) (if (bolp) 1 0))))
@@ -589,17 +595,17 @@ With prefix arg 1, restrict index to the section at 
point."
   (switch-to-buffer-other-window
    (reftex-get-file-buffer-force reftex-last-toc-file))
   (setq current-prefix-arg '(16))
-  (let ((reftex-rebuilding-toc t))
+  (let ((reftex--rebuilding-toc t))
     (reftex-toc)))
 
-(defun reftex-toc-revert (&rest ignore)
+(defun reftex-toc-revert (&rest _)
   "Regenerate the TOC from the internal lists."
   (interactive)
   (let ((unsplittable
          (if (fboundp 'frame-property)
              (frame-property (selected-frame) 'unsplittable)
            (frame-parameter nil 'unsplittable)))
-        (reftex-rebuilding-toc t))
+        (reftex--rebuilding-toc t))
     (if unsplittable
         (switch-to-buffer
          (reftex-get-file-buffer-force reftex-last-toc-file))
@@ -607,9 +613,9 @@ With prefix arg 1, restrict index to the section at point."
        (reftex-get-file-buffer-force reftex-last-toc-file))))
   (reftex-erase-buffer "*toc*")
   (setq current-prefix-arg nil)
-  (reftex-toc t))
+  (reftex-toc t t))
 
-(defun reftex-toc-external (&rest ignore)
+(defun reftex-toc-external (&rest _)
   "Switch to table of contents of an external document."
   (interactive)
   (reftex-toc-dframe-p nil 'error)
@@ -637,18 +643,17 @@ Useful for large TOCs."
 
 ;; Promotion/Demotion stuff
 
-(defvar pro-or-de)
-(defvar start-pos)
-(defvar start-line)
-(defvar mark-line)
+(defvar reftex--pro-or-de)
+(defvar reftex--start-line)
+(defvar reftex--mark-line)
 
-(defun reftex-toc-demote (&optional arg)
+(defun reftex-toc-demote (&optional _arg)
   "Demote section at point.  If region is active, apply to all in region."
-  (interactive "p")
+  (interactive)
   (reftex-toc-do-promote 1))
-(defun reftex-toc-promote (&optional arg)
+(defun reftex-toc-promote (&optional _arg)
   "Promote section at point.  If region is active, apply to all in region."
-  (interactive "p")
+  (interactive)
   (reftex-toc-do-promote -1))
 (defun reftex-toc-do-promote (delta)
   "Workhorse for `reftex-toc-promote' and `reftex-toc-demote'.
@@ -657,14 +662,15 @@ point."
   ;; We should not do anything unless we are sure this is going to work for
   ;; each section in the region.  Therefore we first collect information and
   ;; test.
-  (let* ((start-line (+ (count-lines (point-min) (point))
-                       (if (bolp) 1 0)))
-        (mark-line  (if (reftex-region-active-p)
-                        (save-excursion (goto-char (mark))
-                                        (+ (count-lines (point-min) (point))
-                                           (if (bolp) 1 0)))))
+  (let* ((reftex--start-line (+ (count-lines (point-min) (point))
+                                (if (bolp) 1 0)))
+        (reftex--mark-line
+          (if (reftex-region-active-p)
+              (save-excursion (goto-char (mark))
+                              (+ (count-lines (point-min) (point))
+                                 (if (bolp) 1 0)))))
          (start-pos (point))
-         (pro-or-de (if (> delta 0) "de" "pro"))
+         (reftex--pro-or-de (if (> delta 0) "de" "pro"))
          beg end entries data sections nsec msg)
     (setq msg
           (catch 'exit
@@ -713,23 +719,23 @@ point."
             ;; Rescan the document and rebuilt the toc buffer
             (save-window-excursion
               (reftex-toc-Rescan))
-            (reftex-toc-restore-region start-line mark-line)
+            (reftex-toc-restore-region reftex--start-line reftex--mark-line)
             (message "%d section%s %smoted"
-                     nsec (if (= 1 nsec) "" "s") pro-or-de)
+                     nsec (if (= 1 nsec) "" "s") reftex--pro-or-de)
             nil))
     (if msg (progn (ding) (message "%s" msg)))))
 
 
 (defun reftex-toc-restore-region (point-line &optional mark-line)
-  (let (mpos)
-    (when mark-line
-      (goto-char (point-min))
-      (forward-line (1- mark-line))
-      (setq mpos (point)))
+  (let ((mpos
+         (when mark-line
+           (goto-char (point-min))
+           (forward-line (1- mark-line))
+           (point))))
     (when point-line
       (goto-char (point-min))
       (forward-line (1- point-line)))
-    (when mark-line
+    (when mpos
       (set-mark mpos)
       (if (featurep 'xemacs)
           (zmacs-activate-region)
@@ -749,7 +755,7 @@ promotion/demotion later.  DELTA is the level change."
          (name nil)
          ;; Here follows some paranoid code to make very sure we are not
          ;; going to break anything
-         (name1         ; dummy
+         (_
           (if (and (markerp marker) (marker-buffer marker))
               ;; Buffer is still live and we have the marker.
               (progn
@@ -772,24 +778,24 @@ promotion/demotion later.  DELTA is the level change."
             ;; We don't have a live marker: scan and load files.
             (reftex-toc-load-all-files-for-promotion)))
          (level (cdr (assoc name reftex-section-levels-all)))
-         (dummy (if (not (integerp level))
-                    (progn
-                      (goto-char toc-point)
-                      (error "Cannot %smote special sections" pro-or-de))))
+         (_ (if (not (integerp level))
+                (progn
+                  (goto-char toc-point)
+                  (error "Cannot %smote special sections" reftex--pro-or-de))))
          (newlevel (if (>= level 0) (+ delta level) (- level delta)))
-         (dummy2 (if (or (and (>= level 0) (= newlevel -1))
-                         (and (< level 0)  (= newlevel 0)))
-                     (error "Cannot %smote \\%s" pro-or-de name)))
+         (_ (if (or (and (>= level 0) (= newlevel -1))
+                    (and (< level 0)  (= newlevel 0)))
+                (error "Cannot %smote \\%s" reftex--pro-or-de name)))
          (newname (reftex-toc-newhead-from-alist newlevel name
                                                  reftex-section-levels-all)))
     (if (and name newname)
         (list data name newname toc-point)
       (goto-char toc-point)
-      (error "Cannot %smote \\%s" pro-or-de name))))
+      (error "Cannot %smote \\%s" reftex--pro-or-de name))))
 
 (defun reftex-toc-promote-action (x)
   "Change the level of a TOC entry.
-PRO-OR-DE is assumed to be dynamically scoped into this function."
+`reftex--pro-or-de' is assumed to be dynamically scoped into this function."
   (let* ((data (car x))
          (name (nth 1 x))
          (newname (nth 2 x))
@@ -798,7 +804,7 @@ PRO-OR-DE is assumed to be dynamically scoped into this 
function."
       (goto-char (marker-position marker))
       (if (looking-at (concat "\\([ \t]*" reftex-section-pre-regexp "\\)" 
(regexp-quote name)))
           (replace-match (concat "\\1" newname))
-        (error "Fatal error during %smotion" pro-or-de)))))
+        (error "Fatal error during %smotion" reftex--pro-or-de)))))
 
 (defun reftex-toc-extract-section-number (entry)
   "Get the numbering of a TOC entry, for message purposes."
@@ -848,11 +854,11 @@ if these sets are sorted blocks in the alist."
   "Make sure all files of the document are being visited by buffers,
 and that the scanning info is absolutely up to date.
 We do this by rescanning with `reftex-keep-temporary-buffers' bound to t.
-The variable PRO-OR-DE is assumed to be dynamically scoped into this function.
+The variable `reftex--pro-or-de' is assumed to be dynamically scoped into this 
function.
 When finished, we exit with an error message."
   (let ((reftex-keep-temporary-buffers t))
     (reftex-toc-Rescan)
-    (reftex-toc-restore-region start-line mark-line)
+    (reftex-toc-restore-region reftex--start-line reftex--mark-line)
     (throw 'exit
            "TOC had to be updated first.  Please check selection and repeat 
the command.")))
 
@@ -895,7 +901,7 @@ label prefix determines the wording of a reference."
 
   (let* ((toc (get-text-property (point) :data))
          (toc-window (selected-window))
-         show-window show-buffer match)
+         match)
 
     (unless toc (error "Don't know which TOC line to visit"))
 
@@ -926,30 +932,33 @@ label prefix determines the wording of a reference."
       (setq match (reftex-show-label-location toc reftex-callback-fwd
                                                 no-revisit t))))
 
-    (setq show-window (selected-window)
-          show-buffer (current-buffer))
-
     (unless match
       (select-window toc-window)
       (error "Cannot find location"))
 
-    (select-window toc-window)
-
-    ;; use the `final' parameter to decide what to do next
+    ;; Use the `final' parameter to decide what to do next.
     (cond
      ((eq final t)
-      (reftex-unhighlight 0)
-      (select-window show-window))
+      (with-selected-window toc-window
+        (reftex-unhighlight 0)))
      ((eq final 'hide)
-      (reftex-unhighlight 0)
-      (or (one-window-p) (delete-window))
-      ;; If `show-window' is still live, show-buffer is already visible
-      ;; so let's not make it visible in yet-another-window.
-      (if (window-live-p show-window)
-         (set-buffer show-buffer)
-       (switch-to-buffer show-buffer))
-      (reftex-re-enlarge))
-     (t nil))))
+      (let ((show-window (selected-window))
+            (show-buffer (window-buffer)))
+        (unless (eq show-window toc-window) ;FIXME: Can this happen?
+          (with-selected-window toc-window
+            (reftex-unhighlight 0)
+            (or (one-window-p) (delete-window))))
+        ;; If `show-window' is still live, show-buffer is already visible
+        ;; so let's not make it visible in yet-another-window.
+        (unless (window-live-p show-window)
+          ;; FIXME: How could show-window not be live?
+          (switch-to-buffer show-buffer))
+        (reftex-re-enlarge)))
+     (t
+      (unless (eq (selected-frame) (window-frame toc-window))
+        ;; Make sure `toc-window' is not just selected but has focus.
+        (select-frame-set-input-focus (window-frame toc-window)))
+      (select-window toc-window)))))
 
 (defun reftex-toc-find-section (toc &optional no-revisit)
   (let* ((file (nth 3 toc))
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 0b7e9e0..788fdcc 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -2446,7 +2446,7 @@ of ENTRY-LIST is a list of cons cells (\"MACRONAME\" . 
LEVEL).  See
 
 ;;;***
 
-;;;### (autoloads nil "reftex-cite" "reftex-cite.el" 
"5a53c260fa01268c04ea2f558add9d7d")
+;;;### (autoloads nil "reftex-cite" "reftex-cite.el" 
"9e0690737924aef6e3836bc2c42a36c9")
 ;;; Generated autoloads from reftex-cite.el
 
 (autoload 'reftex-default-bibliography "reftex-cite" "\
@@ -3046,7 +3046,7 @@ During a selection process, these are the local bindings.
 
 ;;;***
 
-;;;### (autoloads nil "reftex-toc" "reftex-toc.el" 
"8b6d6733d445a55206e84fc119909520")
+;;;### (autoloads nil "reftex-toc" "reftex-toc.el" 
"70daa7ce5ba54f2c8d469337f64636c1")
 ;;; Generated autoloads from reftex-toc.el
 
 (autoload 'reftex-toc "reftex-toc" "\
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index c26c609..274cb4a 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1331,7 +1331,9 @@ inserts \" characters."
           (goto-char saved)
           (insert (if (> saved (mark)) tex-close-quote tex-open-quote)))
       (if (or (memq (char-syntax (preceding-char)) '(?\( ?> ?\s))
-              (memq (preceding-char) '(?~)))
+              (memq (preceding-char) '(?~ ?')))
+          ;; We're in an "opening" context
+          ;;
           (if electric-pair-mode
               (if (looking-at (regexp-quote tex-close-quote))
                   (forward-char (length tex-close-quote))
@@ -1339,6 +1341,8 @@ inserts \" characters."
                 (insert tex-close-quote)
                 (backward-char (length tex-close-quote)))
             (insert tex-open-quote))
+        ;; We're in a "closing" context.
+        ;;
         (if (looking-at (regexp-quote tex-close-quote))
             (forward-char (length tex-close-quote))
           (insert tex-close-quote))))))
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index 84b578b..1466556 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -29,7 +29,9 @@
 
 ;;; Code:
 
-(defcustom text-mode-hook nil
+;; Normally non-nil defaults for hooks are bad, but since this file is
+;; preloaded it's ok/better, and avoids this showing up in customize-rogue.
+(defcustom text-mode-hook '(text-mode-hook-identify)
   "Normal hook run when entering Text mode and many related modes."
   :type 'hook
   :options '(turn-on-auto-fill turn-on-flyspell)
@@ -147,14 +149,13 @@ Turning on Paragraph-Indent minor mode runs the normal 
hook
 (defalias 'indented-text-mode 'text-mode)
 
 ;; This can be made a no-op once all modes that use text-mode-hook
-;; are "derived" from text-mode.
+;; are "derived" from text-mode.  (As of 2015/04, and probably well before,
+;; the only one I can find that doesn't so derive is rmail-edit-mode.)
 (defun text-mode-hook-identify ()
   "Mark that this mode has run `text-mode-hook'.
 This is how `toggle-text-mode-auto-fill' knows which buffers to operate on."
   (set (make-local-variable 'text-mode-variant) t))
 
-(add-hook 'text-mode-hook 'text-mode-hook-identify)
-
 (defun toggle-text-mode-auto-fill ()
   "Toggle whether to use Auto Fill in Text mode and related modes.
 This command affects all buffers that use modes related to Text mode,
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index 811f9e8..9c52106 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -954,6 +954,12 @@ stream.  Standard error output is discarded."
        (translated nil)
        (result nil))
       (goto-char (point-min))
+      ;; Skip a warning message that can occur in some bzr installations.
+      ;; vc-bzr-dir-extra-headers already reports it.
+      ;; Perhaps we should just discard stderr?
+      (and (looking-at "bzr: WARNING: bzrlib version doesn't match")
+           (re-search-forward "^bzr is version" nil t)
+           (forward-line 1))
       (while (not (eobp))
         ;; Bzr 2.3.0 added this if there are shelves.  (Bug#8170)
         (unless (looking-at "[0-9]+ shel\\(f\\|ves\\) exists?\\.")
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index bec36fd..c8b696a 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -771,6 +771,9 @@ This prompts for a branch to merge from."
           (vc-git--run-command-string directory "status" "--porcelain" "--"))
          (lines (when status (split-string status "\n" 'omit-nulls)))
          files)
+    ;; TODO: Look into reimplementing `vc-git-state', as well as
+    ;; `vc-git-dir-status-files', based on this output, thus making the
+    ;; extra process call in `vc-git-find-file-hook' unnecessary.
     (dolist (line lines files)
       (when (string-match "\\([ MADRCU?!][ MADRCU?!]\\) \\(.+\\)\\(?: -> 
\\(.+\\)\\)?"
                           line)
@@ -786,32 +789,30 @@ This prompts for a branch to merge from."
   (save-excursion
     (goto-char (point-min))
     (unless (re-search-forward "^<<<<<<< " nil t)
-      (vc-git-command nil 0 buffer-file-name "add")
+      (if (file-exists-p (expand-file-name ".git/MERGE_HEAD"
+                                           (vc-git-root buffer-file-name)))
+          ;; Doing a merge.
+          (vc-git-command nil 0 buffer-file-name "add")
+        ;; Doing something else.  Likely applying a stash (bug#20292).
+        (vc-git-command nil 0 buffer-file-name "reset"))
       ;; Remove the hook so that it is not called multiple times.
       (remove-hook 'after-save-hook 'vc-git-resolve-when-done t))))
 
 (defun vc-git-find-file-hook ()
   "Activate `smerge-mode' if there is a conflict."
-  (let (stashed)
-    (when (and buffer-file-name
-               ;; FIXME
-               ;; 1) the net result is to call git twice per file.
-               ;; 2) v-g-c-f is documented to take a directory.
-               ;; 
http://lists.gnu.org/archive/html/emacs-devel/2014-01/msg01126.html
-               ;; XXX: Should we first look for the markers, and only
-               ;; call this function when see some?
-               (vc-git-conflicted-files buffer-file-name)
-               (save-excursion
-                 (goto-char (point-min))
-                 (when (re-search-forward "^>>>>>>> " nil 'noerror)
-                   (setq stashed (looking-at "Stashed changes"))
-                   t)))
-      (vc-file-setprop buffer-file-name 'vc-state 'conflict)
-      (smerge-start-session)
-      (unless stashed
-        ;; Stashes are tricky (bug#20292).
-        (add-hook 'after-save-hook 'vc-git-resolve-when-done nil 'local))
-      (message "There are unresolved conflicts in this file"))))
+  (when (and buffer-file-name
+             ;; FIXME
+             ;; 1) the net result is to call git twice per file.
+             ;; 2) v-g-c-f is documented to take a directory.
+             ;; 
http://lists.gnu.org/archive/html/emacs-devel/2014-01/msg01126.html
+             (vc-git-conflicted-files buffer-file-name)
+             (save-excursion
+               (goto-char (point-min))
+               (re-search-forward "^<<<<<<< " nil 'noerror)))
+    (vc-file-setprop buffer-file-name 'vc-state 'conflict)
+    (smerge-start-session)
+    (add-hook 'after-save-hook 'vc-git-resolve-when-done nil 'local)
+    (message "There are unresolved conflicts in this file")))
 
 ;;; HISTORY FUNCTIONS
 
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 04a900f..0a95783 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -2846,9 +2846,17 @@ The following properties have special meanings for this 
widget:
     (if (and (fboundp symbol) (boundp symbol))
        ;; If there are two doc strings, give the user a way to pick one.
        (apropos (concat "\\`" (regexp-quote string) "\\'"))
-      (if (fboundp symbol)
-         (describe-function symbol)
-       (describe-variable symbol)))))
+      (cond
+       ((fboundp symbol)
+       (describe-function symbol))
+       ((facep symbol)
+       (describe-face symbol))
+       ((featurep symbol)
+       (describe-package symbol))
+       ((or (boundp symbol) (get symbol 'variable-documentation))
+       (describe-variable symbol))
+       (t
+       (message "No documentation available for %s" symbol))))))
 
 (defcustom widget-documentation-links t
   "Add hyperlinks to documentation strings when non-nil."
diff --git a/lisp/window.el b/lisp/window.el
index 46a7dd0..a6c60e9 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5474,10 +5474,16 @@ element is BUFFER."
   (cond
    ((eq type 'reuse)
     (if (eq (window-buffer window) buffer)
-       ;; WINDOW shows BUFFER already.
-       (when (consp (window-parameter window 'quit-restore))
-         ;; If WINDOW has a quit-restore parameter, reset its car.
-         (setcar (window-parameter window 'quit-restore) 'same))
+       ;; WINDOW shows BUFFER already.  Update WINDOW's quit-restore
+       ;; parameter, if any.
+       (let ((quit-restore (window-parameter window 'quit-restore)))
+         (when (consp quit-restore)
+           (setcar quit-restore 'same)
+           ;; The selected-window might have changed in
+           ;; between (Bug#20353).
+           (unless (or (eq window (selected-window))
+                        (eq window (nth 2 quit-restore)))
+             (setcar (cddr quit-restore) (selected-window)))))
       ;; WINDOW shows another buffer.
       (with-current-buffer (window-buffer window)
        (set-window-parameter
@@ -7619,7 +7625,8 @@ Return non-nil if the window was shrunk, nil otherwise."
 
 (defvar recenter-last-op nil
   "Indicates the last recenter operation performed.
-Possible values: `top', `middle', `bottom', integer or float numbers.")
+Possible values: `top', `middle', `bottom', integer or float numbers.
+It can also be nil, which means the first value in `recenter-positions'.")
 
 (defcustom recenter-positions '(middle top bottom)
   "Cycling order for `recenter-top-bottom'.
diff --git a/m4/acl.m4 b/m4/acl.m4
index c77f0ed..186353c 100644
--- a/m4/acl.m4
+++ b/m4/acl.m4
@@ -1,5 +1,5 @@
 # acl.m4 - check for access control list (ACL) primitives
-# serial 17
+# serial 18
 
 # Copyright (C) 2002, 2004-2015 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -8,23 +8,29 @@
 
 # Written by Paul Eggert and Jim Meyering.
 
-AC_DEFUN([gl_FUNC_ACL],
+AC_DEFUN([gl_FUNC_ACL_ARG],
 [
+  gl_need_lib_has_acl=
   AC_ARG_ENABLE([acl],
     AS_HELP_STRING([--disable-acl], [do not support ACLs]),
     , [enable_acl=auto])
+])
+
 
+AC_DEFUN([gl_FUNC_ACL],
+[
+  AC_REQUIRE([gl_FUNC_ACL_ARG])
   AC_CHECK_FUNCS_ONCE([fchmod])
   LIB_ACL=
   use_acl=0
-  if test "x$enable_acl" != "xno"; then
+  if test "$enable_acl" != no; then
     dnl On all platforms, the ACL related API is declared in <sys/acl.h>.
     AC_CHECK_HEADERS([sys/acl.h])
     if test $ac_cv_header_sys_acl_h = yes; then
       ac_save_LIBS=$LIBS
 
-      dnl Test for POSIX-draft-like API (Linux, FreeBSD, Mac OS X, IRIX, 
Tru64).
-      dnl -lacl is needed on Linux, -lpacl is needed on OSF/1.
+      dnl Test for POSIX-draft-like API (GNU/Linux, FreeBSD, Mac OS X,
+      dnl IRIX, Tru64).  -lacl is needed on GNU/Linux, -lpacl on OSF/1.
       if test $use_acl = 0; then
         AC_SEARCH_LIBS([acl_get_file], [acl pacl],
           [if test "$ac_cv_search_acl_get_file" != "none required"; then
@@ -40,7 +46,7 @@ AC_DEFUN([gl_FUNC_ACL],
            # If the acl_get_file bug is detected, don't enable the ACL support.
            gl_ACL_GET_FILE([use_acl=1], [])
            if test $use_acl = 1; then
-             dnl On Linux, additional API is declared in <acl/libacl.h>.
+             dnl On GNU/Linux, an additional API is declared in <acl/libacl.h>.
              AC_CHECK_HEADERS([acl/libacl.h])
              AC_REPLACE_FUNCS([acl_entries])
              AC_CACHE_CHECK([for ACL_FIRST_ENTRY],
@@ -124,13 +130,15 @@ int type = ACL_TYPE_EXTENDED;]])],
 
       LIBS=$ac_save_LIBS
     fi
-    if test "x$enable_acl$use_acl" = "xyes0"; then
+
+    if test "$enable_acl$use_acl" = yes0; then
       AC_MSG_ERROR([ACLs enabled but support not detected])
-    elif test "x$enable_acl$use_acl" = "xauto0"; then
+    elif test "$enable_acl$use_acl" = auto0; then
       AC_MSG_WARN([libacl development library was not found or not usable.])
       AC_MSG_WARN([AC_PACKAGE_NAME will be built without ACL support.])
     fi
   fi
+  test $gl_need_lib_has_acl && LIB_HAS_ACL=$LIB_ACL
   AC_SUBST([LIB_ACL])
   AC_DEFINE_UNQUOTED([USE_ACL], [$use_acl],
     [Define to nonzero if you want access control list support.])
@@ -139,7 +147,7 @@ int type = ACL_TYPE_EXTENDED;]])],
 ])
 
 # gl_ACL_GET_FILE(IF-WORKS, IF-NOT)
-# -------------------------------------
+# ---------------------------------
 # If 'acl_get_file' works (does not have a particular bug),
 # run IF-WORKS, otherwise, IF-NOT.
 # When building natively, test for a Darwin 8.7.0 bug, whereby acl_get_file
@@ -166,3 +174,24 @@ AC_DEFUN([gl_ACL_GET_FILE],
         fi])])
   AS_IF([test "$gl_cv_func_working_acl_get_file" != no], [$1], [$2])
 ])
+
+# On GNU/Linux, testing if a file has an acl can be done with the getxattr
+# syscall which doesn't require linking against additional libraries.
+AC_DEFUN([gl_FILE_HAS_ACL],
+[
+  AC_REQUIRE([gl_FUNC_ACL_ARG])
+  if test "$enable_acl" != no; then
+    AC_CHECK_HEADERS([linux/xattr.h],
+      [AC_CHECK_HEADERS([sys/xattr.h],
+         [AC_CHECK_FUNCS([getxattr])])])
+  fi
+  if test 
"$ac_cv_header_sys_xattr_h,$ac_cv_header_linux_xattr_h,$ac_cv_func_getxattr" = 
yes,yes,yes; then
+    LIB_HAS_ACL=
+  else
+    dnl Set gl_need_lib_has_acl to a nonempty value, so that any
+    dnl later gl_FUNC_ACL call will set LIB_HAS_ACL=$LIB_ACL.
+    gl_need_lib_has_acl=1
+    LIB_HAS_ACL=$LIB_ACL
+  fi
+  AC_SUBST([LIB_HAS_ACL])
+])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index f32a4dd..06636cf 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -818,6 +818,7 @@ AC_DEFUN([gl_FILE_LIST], [
   build-aux/snippet/warn-on-use.h
   build-aux/update-copyright
   lib/acl-errno-valid.c
+  lib/acl-internal.c
   lib/acl-internal.h
   lib/acl.h
   lib/acl_entries.c
@@ -856,7 +857,6 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/fcntl.in.h
   lib/fdatasync.c
   lib/fdopendir.c
-  lib/file-has-acl.c
   lib/filemode.c
   lib/filemode.h
   lib/fpending.c
diff --git a/m4/lstat.m4 b/m4/lstat.m4
index f6c7dd1..adf752c 100644
--- a/m4/lstat.m4
+++ b/m4/lstat.m4
@@ -1,4 +1,4 @@
-# serial 26
+# serial 27
 
 # Copyright (C) 1997-2001, 2003-2015 Free Software Foundation, Inc.
 #
@@ -37,30 +37,28 @@ AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
     [gl_cv_func_lstat_dereferences_slashed_symlink],
     [rm -f conftest.sym conftest.file
      echo >conftest.file
-     if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
-       AC_RUN_IFELSE(
-         [AC_LANG_PROGRAM(
-            [AC_INCLUDES_DEFAULT],
-            [[struct stat sbuf;
-              /* Linux will dereference the symlink and fail, as required by
-                 POSIX.  That is better in the sense that it means we will not
-                 have to compile and use the lstat wrapper.  */
-              return lstat ("conftest.sym/", &sbuf) == 0;
-            ]])],
-         [gl_cv_func_lstat_dereferences_slashed_symlink=yes],
-         [gl_cv_func_lstat_dereferences_slashed_symlink=no],
-         [case "$host_os" in
-                    # Guess yes on glibc systems.
-            *-gnu*) gl_cv_func_lstat_dereferences_slashed_symlink="guessing 
yes" ;;
-                    # If we don't know, assume the worst.
-            *)      gl_cv_func_lstat_dereferences_slashed_symlink="guessing 
no" ;;
-          esac
-         ])
-     else
-       # If the 'ln -s' command failed, then we probably don't even
-       # have an lstat function.
-       gl_cv_func_lstat_dereferences_slashed_symlink="guessing no"
-     fi
+     AC_RUN_IFELSE(
+       [AC_LANG_PROGRAM(
+          [AC_INCLUDES_DEFAULT],
+          [[struct stat sbuf;
+            if (symlink ("conftest.file", "conftest.sym") != 0)
+              return 1;
+            /* Linux will dereference the symlink and fail, as required by
+               POSIX.  That is better in the sense that it means we will not
+               have to compile and use the lstat wrapper.  */
+            return lstat ("conftest.sym/", &sbuf) == 0;
+          ]])],
+       [gl_cv_func_lstat_dereferences_slashed_symlink=yes],
+       [gl_cv_func_lstat_dereferences_slashed_symlink=no],
+       [case "$host_os" in
+          *-gnu*)
+            # Guess yes on glibc systems.
+            gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
+          *)
+            # If we don't know, assume the worst.
+            gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
+        esac
+       ])
      rm -f conftest.sym conftest.file
     ])
   case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index 44da98e..b4e38d9 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -108,12 +108,13 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Waddress \
     -Waggressive-loop-optimizations \
     -Wall \
-    -Warray-bounds \
     -Wattributes \
     -Wbad-function-cast \
+    -Wbool-compare \
     -Wbuiltin-macro-redefined \
     -Wcast-align \
     -Wchar-subscripts \
+    -Wchkp \
     -Wclobbered \
     -Wcomment \
     -Wcomments \
@@ -122,7 +123,10 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wdate-time \
     -Wdeprecated \
     -Wdeprecated-declarations \
+    -Wdesignated-init \
     -Wdisabled-optimization \
+    -Wdiscarded-array-qualifiers \
+    -Wdiscarded-qualifiers \
     -Wdiv-by-zero \
     -Wdouble-promotion \
     -Wempty-body \
@@ -133,6 +137,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wformat-extra-args \
     -Wformat-nonliteral \
     -Wformat-security \
+    -Wformat-signedness \
     -Wformat-y2k \
     -Wformat-zero-length \
     -Wfree-nonheap-object \
@@ -140,15 +145,19 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wimplicit \
     -Wimplicit-function-declaration \
     -Wimplicit-int \
+    -Wincompatible-pointer-types \
     -Winit-self \
     -Winline \
+    -Wint-conversion \
     -Wint-to-pointer-cast \
     -Winvalid-memory-model \
     -Winvalid-pch \
     -Wjump-misses-init \
+    -Wlogical-not-parentheses \
     -Wlogical-op \
     -Wmain \
     -Wmaybe-uninitialized \
+    -Wmemset-transposed-args \
     -Wmissing-braces \
     -Wmissing-declarations \
     -Wmissing-field-initializers \
@@ -159,6 +168,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wnarrowing \
     -Wnested-externs \
     -Wnonnull \
+    -Wodr \
     -Wold-style-declaration \
     -Wold-style-definition \
     -Wopenmp-simd \
@@ -176,6 +186,9 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wreturn-type \
     -Wsequence-point \
     -Wshadow \
+    -Wshift-count-negative \
+    -Wshift-count-overflow \
+    -Wsizeof-array-argument \
     -Wsizeof-pointer-memaccess \
     -Wstack-protector \
     -Wstrict-aliasing \
@@ -185,7 +198,10 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     -Wsuggest-attribute=format \
     -Wsuggest-attribute=noreturn \
     -Wsuggest-attribute=pure \
+    -Wsuggest-final-methods \
+    -Wsuggest-final-types \
     -Wswitch \
+    -Wswitch-bool \
     -Wswitch-default \
     -Wsync-nand \
     -Wsystem-headers \
@@ -217,8 +233,9 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
     gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
   done
 
-  # gcc --help=warnings outputs an unusual form for this option; list
-  # it here so that the above 'comm' command doesn't report a false match.
+  # gcc --help=warnings outputs an unusual form for these options; list
+  # them here so that the above 'comm' command doesn't report a false match.
+  gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2"
   gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc"
 
   # These are needed for older GCC versions.
diff --git a/nt/gnulib.mk b/nt/gnulib.mk
index 4be3c2c..26a9ea9 100644
--- a/nt/gnulib.mk
+++ b/nt/gnulib.mk
@@ -523,7 +523,7 @@ EXTRA_libgnu_a_SOURCES += putenv.c
 
 ## begin gnulib module qacl
 
-libgnu_a_SOURCES += acl-errno-valid.c file-has-acl.c qcopy-acl.c
+libgnu_a_SOURCES += acl-errno-valid.c acl-internal.c qcopy-acl.c
 
 EXTRA_DIST += acl-internal.h acl.h acl_entries.c
 
diff --git a/src/ccl.c b/src/ccl.c
index 053544c..88307a3 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1713,7 +1713,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int 
*destination, int src_size
        case CCL_STAT_INVALID_CMD:
          msglen = sprintf (msg,
                            "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
-                           code & 0x1F, code, this_ic);
+                           code & 0x1Fu, code + 0u, this_ic);
 #ifdef CCL_DEBUG
          {
            int i = ccl_backtrace_idx - 1;
diff --git a/src/character.c b/src/character.c
index c143c0f..f51d971 100644
--- a/src/character.c
+++ b/src/character.c
@@ -841,7 +841,7 @@ string_escape_byte8 (Lisp_Object string)
          {
            c = STRING_CHAR_ADVANCE (src);
            c = CHAR_TO_BYTE8 (c);
-           dst += sprintf ((char *) dst, "\\%03o", c);
+           dst += sprintf ((char *) dst, "\\%03o", c + 0u);
          }
        else
          while (len--) *dst++ = *src++;
@@ -851,7 +851,7 @@ string_escape_byte8 (Lisp_Object string)
       {
        c = *src++;
        if (c >= 0x80)
-         dst += sprintf ((char *) dst, "\\%03o", c);
+         dst += sprintf ((char *) dst, "\\%03o", c + 0u);
        else
          *dst++ = c;
       }
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 54e92cc..fa26f9e 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -874,7 +874,7 @@ xd_retrieve_arg (int dtype, DBusMessageIter *iter)
        uprintmax_t pval;
        dbus_message_iter_get_basic (iter, &val);
        pval = val;
-       XD_DEBUG_MESSAGE ("%c %"pMd, dtype, pval);
+       XD_DEBUG_MESSAGE ("%c %"pMu, dtype, pval);
        return make_fixnum_or_float (val);
       }
 
@@ -990,7 +990,7 @@ xd_add_watch (DBusWatch *watch, void *data)
   unsigned int flags = dbus_watch_get_flags (watch);
   int fd = xd_find_watch_fd (watch);
 
-  XD_DEBUG_MESSAGE ("fd %d, write %d, enabled %d",
+  XD_DEBUG_MESSAGE ("fd %d, write %u, enabled %u",
                    fd, flags & DBUS_WATCH_WRITABLE,
                    dbus_watch_get_enabled (watch));
 
diff --git a/src/editfns.c b/src/editfns.c
index 7d3e462..dead48c 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2728,7 +2728,15 @@ DEFUN ("insert-buffer-substring", 
Finsert_buffer_substring, Sinsert_buffer_subst
        doc: /* Insert before point a substring of the contents of BUFFER.
 BUFFER may be a buffer or a buffer name.
 Arguments START and END are character positions specifying the substring.
-They default to the values of (point-min) and (point-max) in BUFFER.  */)
+They default to the values of (point-min) and (point-max) in BUFFER.
+
+Point and before-insertion markers move forward to end up after the
+inserted text.
+Any other markers at the point of insertion remain before the text.
+
+If the current buffer is multibyte and BUFFER is unibyte, or vice
+versa, strings are converted from unibyte to multibyte or vice versa
+using `string-make-multibyte' or `string-make-unibyte', which see.  */)
   (Lisp_Object buffer, Lisp_Object start, Lisp_Object end)
 {
   register EMACS_INT b, e, temp;
diff --git a/src/gnutls.c b/src/gnutls.c
index ddd36a9..9b8ae2b 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -1512,7 +1512,7 @@ one trustfile (usually a CA bundle).  */)
           || !NILP (Fmember (QCgnutls_bootprop_trustfiles, verify_error)))
         {
          emacs_gnutls_deinit (proc);
-         error ("Certificate validation failed %s, verification code %d",
+         error ("Certificate validation failed %s, verification code %u",
                 c_hostname, peer_verification);
         }
       else
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 41cc7a7..b51d338 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -579,9 +579,9 @@ xg_check_special_colors (struct frame *f,
       gtk_style_context_get_background_color (gsty, state, &col);
 
     sprintf (buf, "rgb:%04x/%04x/%04x",
-             (int)(col.red * 65535),
-             (int)(col.green * 65535),
-             (int)(col.blue * 65535));
+             (unsigned) (col.red * 65535),
+             (unsigned) (col.green * 65535),
+             (unsigned) (col.blue * 65535));
     success_p = (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
                              buf, color)
                 != 0);
diff --git a/src/image.c b/src/image.c
index df299bb..5e48438 100644
--- a/src/image.c
+++ b/src/image.c
@@ -4964,7 +4964,8 @@ x_build_heuristic_mask (struct frame *f, struct image 
*img, Lisp_Object how)
       if (i == 3 && NILP (how))
        {
          char color_name[30];
-         sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
+         sprintf (color_name, "#%04x%04x%04x",
+                  rgb[0] + 0u, rgb[1] + 0u, rgb[2] + 0u);
          bg = (
 #ifdef HAVE_NTGUI
                0x00ffffff & /* Filter out palette info.  */
@@ -5729,6 +5730,7 @@ png_load_body (struct frame *f, struct image *img, struct 
png_load_context *c)
   /* Find out what file to load.  */
   specified_file = image_spec_value (img->spec, QCfile, NULL);
   specified_data = image_spec_value (img->spec, QCdata, NULL);
+  IF_LINT (Lisp_Object volatile specified_data_volatile = specified_data);
 
   if (NILP (specified_data))
     {
@@ -5825,6 +5827,7 @@ png_load_body (struct frame *f, struct image *img, struct 
png_load_context *c)
 
   /* Silence a bogus diagnostic; see GCC bug 54561.  */
   IF_LINT (fp = c->fp);
+  IF_LINT (specified_data = specified_data_volatile);
 
   /* Read image info.  */
   if (!NILP (specified_data))
@@ -6467,6 +6470,7 @@ jpeg_load_body (struct frame *f, struct image *img,
   /* Open the JPEG file.  */
   specified_file = image_spec_value (img->spec, QCfile, NULL);
   specified_data = image_spec_value (img->spec, QCdata, NULL);
+  IF_LINT (Lisp_Object volatile specified_data_volatile = specified_data);
 
   if (NILP (specified_data))
     {
@@ -6528,6 +6532,9 @@ jpeg_load_body (struct frame *f, struct image *img,
       return 0;
     }
 
+  /* Silence a bogus diagnostic; see GCC bug 54561.  */
+  IF_LINT (specified_data = specified_data_volatile);
+
   /* Create the JPEG decompression object.  Let it read from fp.
         Read the JPEG image header.  */
   jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo);
diff --git a/src/keyboard.c b/src/keyboard.c
index d1d0c71..8bb06b9 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2192,7 +2192,7 @@ read_event_from_main_queue (struct timespec *end_time,
   save_getcjmp (save_jump);
   restore_getcjmp (local_getcjmp);
   if (!end_time)
-       timer_start_idle ();
+    timer_start_idle ();
   c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time);
   restore_getcjmp (save_jump);
 
diff --git a/src/lread.c b/src/lread.c
index fa9a63e..a84450a 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3024,7 +3024,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool 
first_in_list)
 
                ch = read_escape (readcharfun, 1);
 
-               /* CH is -1 if \ newline has just been seen.  */
+               /* CH is -1 if \ newline or \ space has just been seen.  */
                if (ch == -1)
                  {
                    if (p == read_buffer)
diff --git a/src/print.c b/src/print.c
index fd943b9..d826fb7 100644
--- a/src/print.c
+++ b/src/print.c
@@ -41,6 +41,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 # include "xwidget.h"
 #endif
 
+#include <c-ctype.h>
 #include <float.h>
 #include <ftoastr.h>
 
@@ -797,9 +798,12 @@ safe_debug_print (Lisp_Object arg)
   if (valid > 0)
     debug_print (arg);
   else
-    fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n",
-            !valid ? "INVALID" : "SOME",
-            XLI (arg));
+    {
+      EMACS_UINT n = XLI (arg);
+      fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n",
+              !valid ? "INVALID" : "SOME",
+              n);
+    }
 }
 
 
@@ -1389,9 +1393,9 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, 
bool escapeflag)
          register ptrdiff_t i, i_byte;
          struct gcpro gcpro1;
          ptrdiff_t size_byte;
-         /* 1 means we must ensure that the next character we output
+         /* True means we must ensure that the next character we output
             cannot be taken as part of a hex character escape.  */
-         bool need_nonhex = 0;
+         bool need_nonhex = false;
          bool multibyte = STRING_MULTIBYTE (obj);
 
          GCPRO1 (obj);
@@ -1415,60 +1419,46 @@ print_object (Lisp_Object obj, Lisp_Object 
printcharfun, bool escapeflag)
 
              QUIT;
 
-             if (c == '\n' && print_escape_newlines)
-               print_c_string ("\\n", printcharfun);
-             else if (c == '\f' && print_escape_newlines)
-               print_c_string ("\\f", printcharfun);
-             else if (multibyte
-                      && (CHAR_BYTE8_P (c)
-                          || (! ASCII_CHAR_P (c) && print_escape_multibyte)))
-               {
-                 /* When multibyte is disabled,
-                    print multibyte string chars using hex escapes.
-                    For a char code that could be in a unibyte string,
-                    when found in a multibyte string, always use a hex escape
-                    so it reads back as multibyte.  */
-                 char outbuf[50];
-                 int len;
-
-                 if (CHAR_BYTE8_P (c))
-                   len = sprintf (outbuf, "\\%03o", CHAR_TO_BYTE8 (c));
-                 else
-                   {
-                     len = sprintf (outbuf, "\\x%04x", c);
-                     need_nonhex = 1;
-                   }
-                 strout (outbuf, len, len, printcharfun);
-               }
-             else if (! multibyte
-                      && SINGLE_BYTE_CHAR_P (c) && ! ASCII_CHAR_P (c)
-                      && print_escape_nonascii)
+             if (multibyte
+                 ? (CHAR_BYTE8_P (c) && (c = CHAR_TO_BYTE8 (c), true))
+                 : (SINGLE_BYTE_CHAR_P (c) && ! ASCII_CHAR_P (c)
+                    && print_escape_nonascii))
                {
-                 /* When printing in a multibyte buffer
-                    or when explicitly requested,
+                 /* When printing a raw 8-bit byte in a multibyte buffer, or
+                    (when requested) a non-ASCII character in a unibyte buffer,
                     print single-byte non-ASCII string chars
                     using octal escapes.  */
                  char outbuf[5];
-                 int len = sprintf (outbuf, "\\%03o", c);
+                 int len = sprintf (outbuf, "\\%03o", c + 0u);
+                 strout (outbuf, len, len, printcharfun);
+                 need_nonhex = false;
+               }
+             else if (multibyte
+                      && ! ASCII_CHAR_P (c) && print_escape_multibyte)
+               {
+                 /* When requested, print multibyte chars using hex escapes.  
*/
+                 char outbuf[sizeof "\\x" + INT_STRLEN_BOUND (c)];
+                 int len = sprintf (outbuf, "\\x%04x", c + 0u);
                  strout (outbuf, len, len, printcharfun);
+                 need_nonhex = true;
                }
              else
                {
                  /* If we just had a hex escape, and this character
                     could be taken as part of it,
                     output `\ ' to prevent that.  */
-                 if (need_nonhex)
-                   {
-                     need_nonhex = 0;
-                     if ((c >= 'a' && c <= 'f')
-                         || (c >= 'A' && c <= 'F')
-                         || (c >= '0' && c <= '9'))
-                       print_c_string ("\\ ", printcharfun);
-                   }
-
-                 if (c == '\"' || c == '\\')
+                 if (need_nonhex && c_isxdigit (c))
+                   print_c_string ("\\ ", printcharfun);
+
+                 if (c == '\n' && print_escape_newlines
+                     ? (c = 'n', true)
+                     : c == '\f' && print_escape_newlines
+                     ? (c = 'f', true)
+                     : c == '\"' || c == '\\')
                    printchar ('\\', printcharfun);
+
                  printchar (c, printcharfun);
+                 need_nonhex = false;
                }
            }
          printchar ('\"', printcharfun);
@@ -2124,11 +2114,11 @@ print_object (Lisp_Object obj, Lisp_Object 
printcharfun, bool escapeflag)
           Probably should just emacs_abort ().  */
        print_c_string ("#<EMACS BUG: INVALID DATATYPE ", printcharfun);
        if (MISCP (obj))
-         len = sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj));
+         len = sprintf (buf, "(MISC 0x%04x)", (unsigned) XMISCTYPE (obj));
        else if (VECTORLIKEP (obj))
-         len = sprintf (buf, "(PVEC 0x%08"pD"x)", ASIZE (obj));
+         len = sprintf (buf, "(PVEC 0x%08zx)", (size_t) ASIZE (obj));
        else
-         len = sprintf (buf, "(0x%02x)", (int) XTYPE (obj));
+         len = sprintf (buf, "(0x%02x)", (unsigned) XTYPE (obj));
        strout (buf, len, len, printcharfun);
        print_c_string ((" Save your buffers immediately"
                         " and please report this bug>"),
diff --git a/src/process.c b/src/process.c
index c745507..3e04cb7 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4785,37 +4785,41 @@ wait_reading_process_output (intmax_t time_limit, int 
nsecs, int read_kbd,
       if (wait_proc && wait_proc->raw_status_new)
        update_status (wait_proc);
       if (wait_proc
-         && wait_proc->infd >= 0
          && ! EQ (wait_proc->status, Qrun)
          && ! EQ (wait_proc->status, Qconnect))
        {
          bool read_some_bytes = false;
 
          clear_waiting_for_input ();
-         XSETPROCESS (proc, wait_proc);
 
-         /* Read data from the process, until we exhaust it.  */
-         while (true)
+         /* If data can be read from the process, do so until exhausted.  */
+         if (wait_proc->infd >= 0)
            {
-             int nread = read_process_output (proc, wait_proc->infd);
-             if (nread < 0)
+             XSETPROCESS (proc, wait_proc);
+
+             while (true)
                {
-                 if (errno == EIO || errno == EAGAIN)
-                   break;
+                 int nread = read_process_output (proc, wait_proc->infd);
+                 if (nread < 0)
+                   {
+                   if (errno == EIO || errno == EAGAIN)
+                     break;
 #ifdef EWOULDBLOCK
-                 if (errno == EWOULDBLOCK)
-                   break;
+                   if (errno == EWOULDBLOCK)
+                     break;
 #endif
-               }
-             else
-               {
-                 if (got_some_input < nread)
-                   got_some_input = nread;
-                 if (nread == 0)
-                   break;
-                 read_some_bytes = true;
+                   }
+                 else
+                   {
+                     if (got_some_input < nread)
+                       got_some_input = nread;
+                     if (nread == 0)
+                       break;
+                     read_some_bytes = true;
+                   }
                }
            }
+
          if (read_some_bytes && do_display)
            redisplay_preserve_echo_area (10);
 
diff --git a/src/term.c b/src/term.c
index 15d33b4..d2a9c3d 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1862,9 +1862,11 @@ produce_glyphless_glyph (struct it *it, Lisp_Object 
acronym)
       else
        {
          eassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE);
-         len = (it->c < 0x10000 ? sprintf (buf, "\\u%04X", it->c)
-                : it->c <= MAX_UNICODE_CHAR ? sprintf (buf, "\\U%06X", it->c)
-                : sprintf (buf, "\\x%06X", it->c));
+         len = sprintf (buf,
+                        (it->c < 0x10000 ? "\\u%04X"
+                         : it->c <= MAX_UNICODE_CHAR ? "\\U%06X"
+                         : "\\x%06X"),
+                        it->c + 0u);
        }
       str = buf;
     }
diff --git a/src/textprop.c b/src/textprop.c
index 108c226..0a591d0 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -711,11 +711,12 @@ DEFUN ("next-char-property-change", 
Fnext_char_property_change,
 This scans characters forward in the current buffer from POSITION till
 it finds a change in some text property, or the beginning or end of an
 overlay, and returns the position of that.
-If none is found up to (point-max), the function returns (point-max).
+If none is found, and LIMIT is nil or omitted, the function
+returns (point-max).
 
-If the optional second argument LIMIT is non-nil, don't search
-past position LIMIT; return LIMIT if nothing is found before LIMIT.
-LIMIT is a no-op if it is greater than (point-max).  */)
+If the optional second argument LIMIT is non-nil, the function doesn't
+search past position LIMIT, and returns LIMIT if nothing is found
+before LIMIT.  LIMIT is a no-op if it is greater than (point-max).  */)
   (Lisp_Object position, Lisp_Object limit)
 {
   Lisp_Object temp;
@@ -736,11 +737,12 @@ DEFUN ("previous-char-property-change", 
Fprevious_char_property_change,
 Scans characters backward in the current buffer from POSITION till it
 finds a change in some text property, or the beginning or end of an
 overlay, and returns the position of that.
-If none is found since (point-min), the function returns (point-min).
+If none is found, and LIMIT is nil or omitted, the function
+returns (point-min).
 
-If the optional second argument LIMIT is non-nil, don't search
-past position LIMIT; return LIMIT if nothing is found before LIMIT.
-LIMIT is a no-op if it is less than (point-min).  */)
+If the optional second argument LIMIT is non-nil, the function doesn't
+search before position LIMIT, and returns LIMIT if nothing is found
+before LIMIT.  LIMIT is a no-op if it is less than (point-min).  */)
   (Lisp_Object position, Lisp_Object limit)
 {
   Lisp_Object temp;
@@ -765,14 +767,15 @@ If the optional third argument OBJECT is a buffer (or 
nil, which means
 the current buffer), POSITION is a buffer position (integer or marker).
 If OBJECT is a string, POSITION is a 0-based index into it.
 
-In a string, scan runs to the end of the string.
-In a buffer, it runs to (point-max), and the value cannot exceed that.
+In a string, scan runs to the end of the string, unless LIMIT is non-nil.
+In a buffer, if LIMIT is nil or omitted, it runs to (point-max), and the
+value cannot exceed that.
+If the optional fourth argument LIMIT is non-nil, don't search
+past position LIMIT; return LIMIT if nothing is found before LIMIT.
 
 The property values are compared with `eq'.
 If the property is constant all the way to the end of OBJECT, return the
-last valid position in OBJECT.
-If the optional fourth argument LIMIT is non-nil, don't search
-past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
+last valid position in OBJECT.  */)
   (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object 
limit)
 {
   if (STRINGP (object))
@@ -849,14 +852,15 @@ If the optional third argument OBJECT is a buffer (or 
nil, which means
 the current buffer), POSITION is a buffer position (integer or marker).
 If OBJECT is a string, POSITION is a 0-based index into it.
 
-In a string, scan runs to the start of the string.
-In a buffer, it runs to (point-min), and the value cannot be less than that.
+In a string, scan runs to the start of the string, unless LIMIT is non-nil.
+In a buffer, if LIMIT is nil or omitted, it runs to (point-min), and the
+value cannot be less than that.
+If the optional fourth argument LIMIT is non-nil, don't search back past
+position LIMIT; return LIMIT if nothing is found before reaching LIMIT.
 
 The property values are compared with `eq'.
 If the property is constant all the way to the start of OBJECT, return the
-first valid position in OBJECT.
-If the optional fourth argument LIMIT is non-nil, don't search back past
-position LIMIT; return LIMIT if nothing is found before reaching LIMIT.  */)
+first valid position in OBJECT.  */)
   (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object 
limit)
 {
   if (STRINGP (object))
@@ -940,8 +944,9 @@ a change in some text property, then returns the position 
of the change.
 If the optional second argument OBJECT is a buffer (or nil, which means
 the current buffer), POSITION is a buffer position (integer or marker).
 If OBJECT is a string, POSITION is a 0-based index into it.
-Return nil if the property is constant all the way to the end of OBJECT.
-If the value is non-nil, it is a position greater than POSITION, never equal.
+Return nil if LIMIT is nil or omitted, and the property is constant all
+the way to the end of OBJECT; if the value is non-nil, it is a position
+greater than POSITION, never equal.
 
 If the optional third argument LIMIT is non-nil, don't search
 past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
@@ -1005,8 +1010,9 @@ If the optional third argument OBJECT is a buffer (or 
nil, which means
 the current buffer), POSITION is a buffer position (integer or marker).
 If OBJECT is a string, POSITION is a 0-based index into it.
 The property values are compared with `eq'.
-Return nil if the property is constant all the way to the end of OBJECT.
-If the value is non-nil, it is a position greater than POSITION, never equal.
+Return nil if LIMIT is nil or omitted, and the property is constant all
+the way to the end of OBJECT; if the value is non-nil, it is a position
+greater than POSITION, never equal.
 
 If the optional fourth argument LIMIT is non-nil, don't search
 past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
@@ -1052,8 +1058,9 @@ a change in some text property, then returns the position 
of the change.
 If the optional second argument OBJECT is a buffer (or nil, which means
 the current buffer), POSITION is a buffer position (integer or marker).
 If OBJECT is a string, POSITION is a 0-based index into it.
-Return nil if the property is constant all the way to the start of OBJECT.
-If the value is non-nil, it is a position less than POSITION, never equal.
+Return nil if LIMIT is nil or omitted, and the property is constant all
+the way to the start of OBJECT; if the value is non-nil, it is a position
+less than POSITION, never equal.
 
 If the optional third argument LIMIT is non-nil, don't search
 back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
@@ -1100,8 +1107,9 @@ If the optional third argument OBJECT is a buffer (or 
nil, which means
 the current buffer), POSITION is a buffer position (integer or marker).
 If OBJECT is a string, POSITION is a 0-based index into it.
 The property values are compared with `eq'.
-Return nil if the property is constant all the way to the start of OBJECT.
-If the value is non-nil, it is a position less than POSITION, never equal.
+Return nil if LIMIT is nil or omitted, and the property is constant all
+the way to the start of OBJECT; if the value is non-nil, it is a position
+less than POSITION, never equal.
 
 If the optional fourth argument LIMIT is non-nil, don't search
 back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
diff --git a/src/w32fns.c b/src/w32fns.c
index 6abb433..b9d7bd4 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -29,6 +29,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <fcntl.h>
 #include <unistd.h>
 
+#include <c-ctype.h>
+
 #include "lisp.h"
 #include "w32term.h"
 #include "frame.h"
@@ -7038,7 +7040,28 @@ a ShowWindow flag:
 
 #else  /* !CYGWIN */
 
-  current_dir = ENCODE_FILE (current_dir);
+  const char file_url_str[] = "file:///";
+  const int file_url_len = sizeof (file_url_str) - 1;
+  if (strncmp (SSDATA (document), file_url_str, file_url_len) == 0)
+    {
+      /* Passing "file:///" URLs to ShellExecute causes shlwapi.dll to
+        start a thread in some rare system configurations, for
+        unknown reasons.  That thread is started in the context of
+        the Emacs process, but out of control of our code, and seems
+        to never exit afterwards.  Each such thread reserves 8MB of
+        stack space (because that's the value recorded in the Emacs
+        executable at link time: Emacs needs a large stack).  So a
+        large enough number of invocations of w32-shell-execute can
+        potentially cause the Emacs process to run out of available
+        address space, which is nasty.  To work around this, we
+        convert such URLs to local file names, which seems to prevent
+        those threads from starting.  See bug #20220.  */
+      char *p = SSDATA (document) + file_url_len;
+
+      if (c_isalpha (*p) && p[1] == ':' && IS_DIRECTORY_SEP (p[2]))
+       document = Fsubstring_no_properties (document,
+                                            make_number (file_url_len), Qnil);
+    }
   /* We have a situation here.  If DOCUMENT is a relative file name,
      but its name includes leading directories, i.e. it lives not in
      CURRENT_DIR, but in its subdirectory, then ShellExecute below
@@ -7071,6 +7094,8 @@ a ShowWindow flag:
   else
     document = ENCODE_FILE (document);
   UNGCPRO;
+
+  current_dir = ENCODE_FILE (current_dir);
   if (use_unicode)
     {
       wchar_t document_w[MAX_PATH], current_dir_w[MAX_PATH];
diff --git a/src/xdisp.c b/src/xdisp.c
index da470db..7ddd36b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -7009,7 +7009,7 @@ get_next_display_element (struct it *it)
                if (CHAR_BYTE8_P (c))
                  /* Display \200 instead of \17777600.  */
                  c = CHAR_TO_BYTE8 (c);
-               len = sprintf (str, "%03o", c);
+               len = sprintf (str, "%03o", c + 0u);
 
                XSETINT (it->ctl_chars[0], escape_glyph);
                for (i = 0; i < len; i++)
@@ -10104,8 +10104,8 @@ message3 (Lisp_Object m)
       message_dolog (buffer, nbytes, true, multibyte);
       SAFE_FREE ();
     }
-  message3_nolog (m);
-
+  if (! inhibit_message)
+    message3_nolog (m);
   UNGCPRO;
 }
 
@@ -13410,6 +13410,13 @@ redisplay_internal (void)
          if (f->fonts_changed)
            {
              adjust_frame_glyphs (f);
+             /* Disable all redisplay optimizations for this frame.
+                This is because adjust_frame_glyphs resets the
+                enabled_p flag for all glyph rows of all windows, so
+                many optimizations will fail anyway, and some might
+                fail to test that flag and do bogus things as
+                result.  */
+             SET_FRAME_GARBAGED (f);
              f->fonts_changed = false;
            }
          /* If cursor type has been changed on the frame
@@ -13804,6 +13811,10 @@ redisplay_internal (void)
                  if (f->fonts_changed)
                    {
                      adjust_frame_glyphs (f);
+                     /* Disable all redisplay optimizations for this
+                        frame.  For the reasons, see the comment near
+                        the previous call to adjust_frame_glyphs above.  */
+                     SET_FRAME_GARBAGED (f);
                      f->fonts_changed = false;
                      goto retry_frame;
                    }
@@ -26463,7 +26474,7 @@ produce_glyphless_glyph (struct it *it, bool 
for_no_font, Lisp_Object acronym)
       else
        {
          eassert (it->glyphless_method == GLYPHLESS_DISPLAY_HEX_CODE);
-         sprintf (buf, "%0*X", it->c < 0x10000 ? 4 : 6, it->c);
+         sprintf (buf, "%0*X", it->c < 0x10000 ? 4 : 6, it->c + 0u);
          str = buf;
        }
       for (len = 0; str[len] && ASCII_CHAR_P (str[len]) && len < 6; len++)
@@ -30668,6 +30679,11 @@ syms_of_xdisp (void)
 
   DEFSYM (Qredisplay_internal, "redisplay_internal (C function)");
 
+  DEFVAR_BOOL("inhibit-message", inhibit_message,
+              doc:  /* Non-nil means calls to `message' are not displayed.
+They are still logged to the *Messages* buffer.  */);
+  inhibit_message = 0;
+
   message_dolog_marker1 = Fmake_marker ();
   staticpro (&message_dolog_marker1);
   message_dolog_marker2 = Fmake_marker ();
diff --git a/src/xterm.c b/src/xterm.c
index 6e16544..d660155 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1288,7 +1288,7 @@ x_draw_glyphless_glyph_string_foreground (struct 
glyph_string *s)
        {
          sprintf (buf, "%0*X",
                   glyph->u.glyphless.ch < 0x10000 ? 4 : 6,
-                  glyph->u.glyphless.ch);
+                  glyph->u.glyphless.ch + 0u);
          str = buf;
        }
 
diff --git a/test/automated/message-mode-tests.el 
b/test/automated/message-mode-tests.el
index 4354b23..49a72b0 100644
--- a/test/automated/message-mode-tests.el
+++ b/test/automated/message-mode-tests.el
@@ -24,13 +24,15 @@
 ;; This file contains tests for message-mode.
 
 ;;; Code:
+
+(require 'message)
 (require 'ert)
 (require 'ert-x)
 
 (ert-deftest message-mode-propertize ()
   (with-temp-buffer
     (unwind-protect
-        (progn
+        (let (message-auto-save-directory)
           (message-mode)
           (insert "here's an opener (\n"
                   "here's a sad face :-(\n"
@@ -54,4 +56,5 @@
       (set-buffer-modified-p nil))))
 
 (provide 'message-mode-tests)
+
 ;;; message-mode-tests.el ends here
diff --git a/test/automated/package-test.el b/test/automated/package-test.el
index 4385ee0..1f8f8ac 100644
--- a/test/automated/package-test.el
+++ b/test/automated/package-test.el
@@ -361,10 +361,13 @@ Must called from within a `tar-mode' buffer."
                (while package--downloads-in-progress
                  (accept-process-output nil 1))
                nil))
+            ;; If the server process died, there's some non-Emacs problem.
+            ;; Eg maybe the port was already in use.
+            (skip-unless (process-live-p process))
             (goto-char (point-min))
             (should
              (search-forward-regexp "^ +simple-single" nil t)))
-        (kill-process process)))))
+        (if (process-live-p process) (kill-process process))))))
 
 (ert-deftest package-test-describe-package ()
   "Test displaying help for a package."
diff --git a/test/automated/print-tests.el b/test/automated/print-tests.el
index 2761109..fe8c565 100644
--- a/test/automated/print-tests.el
+++ b/test/automated/print-tests.el
@@ -21,6 +21,12 @@
 
 (require 'ert)
 
+(ert-deftest print-hex-backslash ()
+  (should (string= (let ((print-escape-multibyte t)
+                         (print-escape-newlines t))
+                     (prin1-to-string "\u00A2\ff"))
+                   "\"\\x00a2\\ff\"")))
+
 (ert-deftest terpri ()
   (should (string= (with-output-to-string
                      (princ 'abc)



reply via email to

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