emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] xwidget_mvp ef9db71 1/3: merge master


From: Joakim Verona
Subject: [Emacs-diffs] xwidget_mvp ef9db71 1/3: merge master
Date: Fri, 11 Dec 2015 09:40:52 +0000

branch: xwidget_mvp
commit ef9db71032e889af7a3189df164feb90e2b2ed3d
Merge: 707260f 354a1fc
Author: Joakim Verona <address@hidden>
Commit: Joakim Verona <address@hidden>

    merge master
---
 .gitignore                                         |   18 +-
 CONTRIBUTE                                         |   19 +-
 ChangeLog.2                                        | 1934 +++++++++++++++++++-
 Makefile.in                                        |   15 +-
 README                                             |    5 +-
 admin/README                                       |    4 +-
 admin/authors.el                                   |    2 +-
 admin/gitmerge.el                                  |   10 +-
 admin/notes/bugtracker                             |    3 +-
 admin/notes/versioning                             |   12 +-
 admin/{FOR-RELEASE => release-process}             |  282 ++--
 configure.ac                                       |   66 +-
 doc/lispref/os.texi                                |   41 +-
 etc/NEWS                                           |   13 +
 etc/TODO                                           |    9 +-
 lib/xalloc-oversized.h                             |   13 +-
 lisp/Makefile.in                                   |    9 +-
 lisp/abbrev.el                                     |   52 +-
 lisp/bindings.el                                   |    6 +-
 lisp/calculator.el                                 |  462 +++---
 lisp/cus-edit.el                                   |    2 +-
 lisp/emacs-lisp/eieio-core.el                      |   12 +-
 lisp/emacs-lisp/eieio.el                           |   36 +-
 lisp/emacs-lisp/let-alist.el                       |    9 +-
 lisp/emacs-lisp/package.el                         |  159 +-
 lisp/emulation/cua-rect.el                         |   26 +-
 lisp/epa.el                                        |   19 +-
 lisp/filenotify.el                                 |  101 +-
 lisp/image-mode.el                                 |    7 +-
 lisp/ldefs-boot.el                                 |  467 +++---
 lisp/linum.el                                      |   23 +-
 lisp/loadup.el                                     |    5 +
 lisp/mpc.el                                        |   17 +-
 lisp/progmodes/cc-defs.el                          |   30 +-
 lisp/progmodes/elisp-mode.el                       |   41 +-
 lisp/progmodes/etags.el                            |   21 +-
 lisp/progmodes/verilog-mode.el                     |  528 +++---
 lisp/progmodes/which-func.el                       |   45 +-
 lisp/progmodes/xref.el                             |  249 ++--
 lisp/rect.el                                       |   32 +-
 lisp/replace.el                                    |   87 +-
 lisp/simple.el                                     |  229 ++-
 lisp/url/url-handlers.el                           |   42 +-
 lisp/vc/diff-mode.el                               |    2 +-
 msdos/sed2v2.inp                                   |    2 +-
 src/Makefile.in                                    |   11 +-
 src/casefiddle.c                                   |   22 +-
 src/emacs.c                                        |   16 +-
 src/ftfont.c                                       |  106 +-
 src/inotify.c                                      |    9 +-
 src/keyboard.c                                     |    4 +-
 src/kqueue.c                                       |  520 ++++++
 src/lisp.h                                         |   16 +-
 src/xfns.c                                         |    7 +-
 src/xterm.c                                        |   16 +-
 test/{automated => }/Makefile.in                   |   40 +-
 test/automated/abbrev-tests.el                     |   43 -
 test/{automated => }/data/decompress/foo.gz        |  Bin 30 -> 30 bytes
 test/{automated => }/data/epg/pubkey.asc           |    0
 test/{automated => }/data/epg/seckey.asc           |    0
 test/{automated => }/data/files-bug18141.el.gz     |  Bin 77 -> 77 bytes
 test/file-organisation.org                         |   54 +
 test/lisp/abbrev-tests.el                          |   74 +
 .../autorevert-tests.el}                           |    2 +-
 test/{automated => lisp/calc}/calc-tests.el        |    0
 .../calendar}/icalendar-tests.el                   |    0
 test/{automated => lisp}/character-fold-tests.el   |    0
 .../comint-testsuite.el => lisp/comint-tests.el}   |    0
 .../descr-text-tests.el}                           |    0
 test/{automated => lisp}/electric-tests.el         |    0
 .../emacs-lisp}/cl-generic-tests.el                |    0
 .../{automated => lisp/emacs-lisp}/cl-lib-tests.el |    0
 .../eieio-tests}/eieio-test-methodinvoke.el        |    0
 .../emacs-lisp/eieio-tests}/eieio-test-persist.el  |    0
 .../emacs-lisp/eieio-tests}/eieio-tests.el         |    0
 test/{automated => lisp/emacs-lisp}/ert-tests.el   |    0
 test/{automated => lisp/emacs-lisp}/ert-x-tests.el |    0
 .../emacs-lisp}/generator-tests.el                 |    0
 .../emacs-lisp/let-alist-tests.el}                 |    0
 test/{automated => lisp/emacs-lisp}/map-tests.el   |    0
 .../emacs-lisp/nadvice-tests.el}                   |    0
 .../emacs-lisp/package-resources}/archive-contents |    0
 .../emacs-lisp/package-resources}/key.pub          |    0
 .../emacs-lisp/package-resources}/key.sec          |    0
 .../package-resources}/multi-file-0.2.3.tar        |  Bin 20480 -> 20480 bytes
 .../package-resources}/multi-file-readme.txt       |    0
 .../newer-versions/archive-contents                |    0
 .../newer-versions/new-pkg-1.0.el                  |    0
 .../newer-versions/simple-single-1.4.el            |    0
 .../package-resources}/package-test-server.py      |    0
 .../package-resources}/signed/archive-contents     |    0
 .../package-resources}/signed/archive-contents.sig |  Bin 287 -> 287 bytes
 .../package-resources}/signed/signed-bad-1.0.el    |    0
 .../signed/signed-bad-1.0.el.sig                   |  Bin 287 -> 287 bytes
 .../package-resources}/signed/signed-good-1.0.el   |    0
 .../signed/signed-good-1.0.el.sig                  |  Bin 287 -> 287 bytes
 .../package-resources}/simple-depend-1.0.el        |    0
 .../package-resources}/simple-single-1.3.el        |    0
 .../package-resources}/simple-single-readme.txt    |    0
 .../package-resources}/simple-two-depend-1.1.el    |    0
 .../emacs-lisp/package-tests.el}                   |   23 +-
 test/{automated => lisp/emacs-lisp}/pcase-tests.el |    0
 .../emacs-lisp/regexp-opt-tests.el}                |    0
 test/{automated => lisp/emacs-lisp}/seq-tests.el   |    0
 .../{automated => lisp/emacs-lisp}/subr-x-tests.el |    0
 .../emacs-lisp}/tabulated-list-test.el             |    0
 test/{automated => lisp/emacs-lisp}/thunk-tests.el |    0
 test/{automated => lisp/emacs-lisp}/timer-tests.el |    0
 test/{automated => lisp}/epg-tests.el              |    0
 test/{automated => lisp/eshell}/eshell.el          |    0
 test/{automated => lisp}/faces-tests.el            |    0
 .../filenotify-tests.el}                           |  584 ++++--
 test/{automated => lisp/gnus}/auth-source-tests.el |    0
 test/{automated => lisp/gnus}/gnus-tests.el        |    0
 .../gnus/message-tests.el}                         |    0
 .../help-fns.el => lisp/help-fns-tests.el}         |    0
 .../imenu-test.el => lisp/imenu-tests.el}          |    0
 .../info-xref.el => lisp/info-xref-tests.el}       |    0
 .../international/mule-util-tests.el}              |    0
 test/{automated => lisp}/isearch-tests.el          |    0
 test/{automated => lisp}/json-tests.el             |    0
 test/{automated => lisp/legacy}/bytecomp-tests.el  |    0
 test/{automated => lisp/legacy}/coding-tests.el    |    0
 .../{automated => lisp/legacy}/core-elisp-tests.el |    0
 test/{automated => lisp/legacy}/decoder-tests.el   |    0
 .../files.el => lisp/legacy/files-tests.el}        |    0
 .../{automated => lisp/legacy}/font-parse-tests.el |    0
 test/{automated => lisp/legacy}/lexbind-tests.el   |    0
 test/{automated => lisp/legacy}/occur-tests.el     |    0
 test/{automated => lisp/legacy}/process-tests.el   |    0
 test/{automated => lisp/legacy}/syntax-tests.el    |    0
 test/{automated => lisp/legacy}/textprop-tests.el  |    0
 test/{automated => lisp/legacy}/undo-tests.el      |    0
 test/{automated => lisp}/man-tests.el              |    0
 .../minibuffer-tests.el}                           |    0
 test/{automated => lisp/net}/dbus-tests.el         |    0
 test/{automated => lisp/net}/newsticker-tests.el   |    0
 .../net}/sasl-scram-rfc-tests.el                   |    0
 test/{automated => lisp/net}/tramp-tests.el        |    0
 test/{automated => lisp}/obarray-tests.el          |    0
 .../{automated => lisp/progmodes}/compile-tests.el |    0
 .../progmodes}/elisp-mode-tests.el                 |   36 +-
 test/{automated => lisp/progmodes}/f90.el          |    0
 .../progmodes/flymake-resources}/Makefile          |    0
 .../progmodes/flymake-resources}/test.c            |    0
 .../progmodes/flymake-resources}/test.pl           |    0
 .../{automated => lisp/progmodes}/flymake-tests.el |    2 +-
 test/{automated => lisp/progmodes}/python-tests.el |    0
 .../progmodes}/ruby-mode-tests.el                  |    0
 .../{automated => lisp/progmodes}/subword-tests.el |    0
 test/{automated => lisp}/replace-tests.el          |    0
 .../simple-test.el => lisp/simple-tests.el}        |    0
 test/{automated => lisp}/sort-tests.el             |    0
 test/{automated => lisp}/subr-tests.el             |    0
 test/{automated => lisp/textmodes}/reftex-tests.el |    0
 .../textmodes}/sgml-mode-tests.el                  |    0
 .../{automated => lisp/textmodes}/tildify-tests.el |    0
 .../thingatpt.el => lisp/thingatpt-tests.el}       |    0
 test/{automated => lisp/url}/url-future-tests.el   |    0
 test/{automated => lisp/url}/url-util-tests.el     |    0
 test/{automated => lisp/vc}/add-log-tests.el       |    0
 .../vc-bzr.el => lisp/vc/vc-bzr-tests.el}          |    0
 test/{automated => lisp/vc}/vc-tests.el            |    0
 .../xml-parse-tests.el => lisp/xml-tests.el}       |    0
 test/make-test-deps.emacs-lisp                     |   98 +
 test/{ => manual}/BidiCharacterTest.txt            |    0
 test/{ => manual}/biditest.el                      |    0
 test/{ => manual}/cedet/cedet-utests.el            |    0
 test/{ => manual}/cedet/ede-tests.el               |    0
 test/{ => manual}/cedet/semantic-ia-utest.el       |    0
 test/{ => manual}/cedet/semantic-tests.el          |    0
 test/{ => manual}/cedet/semantic-utest-c.el        |    0
 test/{ => manual}/cedet/semantic-utest.el          |    0
 test/{ => manual}/cedet/srecode-tests.el           |    0
 test/{ => manual}/cedet/tests/test.c               |    0
 test/{ => manual}/cedet/tests/test.el              |    0
 test/{ => manual}/cedet/tests/test.make            |    0
 test/{ => manual}/cedet/tests/testdoublens.cpp     |    0
 test/{ => manual}/cedet/tests/testdoublens.hpp     |    0
 test/{ => manual}/cedet/tests/testfriends.cpp      |    0
 test/{ => manual}/cedet/tests/testjavacomp.java    |    0
 test/{ => manual}/cedet/tests/testnsp.cpp          |    0
 test/{ => manual}/cedet/tests/testpolymorph.cpp    |    0
 test/{ => manual}/cedet/tests/testspp.c            |    0
 test/{ => manual}/cedet/tests/testsppcomplete.c    |    0
 test/{ => manual}/cedet/tests/testsppreplace.c     |    0
 test/{ => manual}/cedet/tests/testsppreplaced.c    |    0
 test/{ => manual}/cedet/tests/testsubclass.cpp     |    0
 test/{ => manual}/cedet/tests/testsubclass.hh      |    0
 test/{ => manual}/cedet/tests/testtypedefs.cpp     |    0
 test/{ => manual}/cedet/tests/testvarnames.c       |    0
 test/{ => manual}/etags/CTAGS.good                 |    0
 test/{ => manual}/etags/ETAGS.good_1               |    0
 test/{ => manual}/etags/ETAGS.good_2               |    0
 test/{ => manual}/etags/ETAGS.good_3               |    0
 test/{ => manual}/etags/ETAGS.good_4               |    0
 test/{ => manual}/etags/ETAGS.good_5               |    0
 test/{ => manual}/etags/ETAGS.good_6               |    0
 test/{ => manual}/etags/Makefile                   |    4 +-
 test/{ => manual}/etags/a-src/empty.zz             |    0
 test/{ => manual}/etags/a-src/empty.zz.gz          |    0
 test/{ => manual}/etags/ada-src/2ataspri.adb       |    0
 test/{ => manual}/etags/ada-src/2ataspri.ads       |    0
 test/{ => manual}/etags/ada-src/etags-test-for.ada |    0
 test/{ => manual}/etags/ada-src/waroquiers.ada     |    0
 test/{ => manual}/etags/c-src/a/b/b.c              |    0
 test/{ => manual}/etags/c-src/abbrev.c             |    0
 test/{ => manual}/etags/c-src/c.c                  |    0
 test/{ => manual}/etags/c-src/dostorture.c         |    0
 test/{ => manual}/etags/c-src/emacs/src/gmalloc.c  |    0
 test/{ => manual}/etags/c-src/emacs/src/keyboard.c |    0
 test/{ => manual}/etags/c-src/emacs/src/lisp.h     |    0
 test/{ => manual}/etags/c-src/emacs/src/regex.h    |    0
 test/{ => manual}/etags/c-src/etags.c              |    0
 test/{ => manual}/etags/c-src/exit.c               |    0
 test/{ => manual}/etags/c-src/exit.strange_suffix  |    0
 test/{ => manual}/etags/c-src/fail.c               |    0
 test/{ => manual}/etags/c-src/getopt.h             |    0
 test/{ => manual}/etags/c-src/h.h                  |    0
 test/{ => manual}/etags/c-src/machsyscalls.c       |    0
 test/{ => manual}/etags/c-src/machsyscalls.h       |    0
 test/{ => manual}/etags/c-src/sysdep.h             |    0
 test/{ => manual}/etags/c-src/tab.c                |    0
 test/{ => manual}/etags/c-src/torture.c            |    0
 test/{ => manual}/etags/cp-src/MDiagArray2.h       |    0
 test/{ => manual}/etags/cp-src/Range.h             |    0
 test/{ => manual}/etags/cp-src/burton.cpp          |    0
 test/{ => manual}/etags/cp-src/c.C                 |    0
 test/{ => manual}/etags/cp-src/clheir.cpp.gz       |  Bin 408 -> 408 bytes
 test/{ => manual}/etags/cp-src/clheir.hpp          |    0
 test/{ => manual}/etags/cp-src/conway.cpp          |    0
 test/{ => manual}/etags/cp-src/conway.hpp          |    0
 test/{ => manual}/etags/cp-src/fail.C              |    0
 test/{ => manual}/etags/cp-src/functions.cpp       |    0
 test/{ => manual}/etags/cp-src/screen.cpp          |    0
 test/{ => manual}/etags/cp-src/screen.hpp          |    0
 test/{ => manual}/etags/cp-src/x.cc                |    0
 test/{ => manual}/etags/el-src/TAGTEST.EL          |    0
 .../etags/el-src/emacs/lisp/progmodes/etags.el     |    0
 test/{ => manual}/etags/erl-src/gs_dialog.erl      |    0
 test/{ => manual}/etags/f-src/entry.for            |    0
 test/{ => manual}/etags/f-src/entry.strange.gz     |  Bin 3265 -> 3265 bytes
 test/{ => manual}/etags/f-src/entry.strange_suffix |    0
 test/{ => manual}/etags/forth-src/test-forth.fth   |    0
 test/{ => manual}/etags/html-src/algrthms.html     |    0
 test/{ => manual}/etags/html-src/index.shtml       |    0
 test/{ => manual}/etags/html-src/software.html     |    0
 .../etags/html-src/softwarelibero.html             |    0
 test/{ => manual}/etags/lua-src/allegro.lua        |    0
 test/{ => manual}/etags/make-src/Makefile          |    0
 test/{ => manual}/etags/objc-src/PackInsp.h        |    0
 test/{ => manual}/etags/objc-src/PackInsp.m        |    0
 test/{ => manual}/etags/objc-src/Subprocess.h      |    0
 test/{ => manual}/etags/objc-src/Subprocess.m      |    0
 test/{ => manual}/etags/objcpp-src/SimpleCalc.H    |    0
 test/{ => manual}/etags/objcpp-src/SimpleCalc.M    |    0
 test/{ => manual}/etags/pas-src/common.pas         |    0
 test/{ => manual}/etags/perl-src/htlmify-cystic    |    0
 test/{ => manual}/etags/perl-src/kai-test.pl       |    0
 test/{ => manual}/etags/perl-src/yagrip.pl         |    0
 test/{ => manual}/etags/php-src/lce_functions.php  |    0
 test/{ => manual}/etags/php-src/ptest.php          |    0
 test/{ => manual}/etags/php-src/sendmail.php       |    0
 test/{ => manual}/etags/prol-src/natded.prolog     |    0
 test/{ => manual}/etags/prol-src/ordsets.prolog    |    0
 test/{ => manual}/etags/ps-src/rfc1245.ps          |    0
 test/{ => manual}/etags/pyt-src/server.py          |    0
 test/{ => manual}/etags/tex-src/gzip.texi          |    0
 test/{ => manual}/etags/tex-src/nonewline.tex      |    0
 test/{ => manual}/etags/tex-src/testenv.tex        |    0
 test/{ => manual}/etags/tex-src/texinfo.tex        |    0
 test/{ => manual}/etags/y-src/atest.y              |    0
 test/{ => manual}/etags/y-src/cccp.c               |    0
 test/{ => manual}/etags/y-src/cccp.y               |    0
 test/{ => manual}/etags/y-src/parse.c              |    0
 test/{ => manual}/etags/y-src/parse.y              |    0
 test/{ => manual}/indent/Makefile                  |    0
 test/{ => manual}/indent/css-mode.css              |    0
 test/{ => manual}/indent/js-indent-init-dynamic.js |    0
 test/{ => manual}/indent/js-indent-init-t.js       |    0
 test/{ => manual}/indent/js-jsx.js                 |    0
 test/{ => manual}/indent/js.js                     |    0
 test/{ => manual}/indent/latex-mode.tex            |    0
 test/{ => manual}/indent/modula2.mod               |    0
 test/{ => manual}/indent/nxml.xml                  |    0
 test/{ => manual}/indent/octave.m                  |    0
 test/{ => manual}/indent/pascal.pas                |    0
 test/{ => manual}/indent/perl.perl                 |    0
 test/{ => manual}/indent/prolog.prolog             |    0
 test/{ => manual}/indent/ps-mode.ps                |    0
 test/{ => manual}/indent/ruby.rb                   |    0
 test/{ => manual}/indent/scheme.scm                |    0
 test/{ => manual}/indent/scss-mode.scss            |    0
 test/{ => manual}/indent/sgml-mode-attribute.html  |    0
 test/{ => manual}/indent/shell.rc                  |    0
 test/{ => manual}/indent/shell.sh                  |    0
 test/{ => manual}/redisplay-testsuite.el           |    0
 test/{ => manual}/rmailmm.el                       |    0
 .../finalizer-tests.el => src/alloc-tests.el}      |    2 +-
 test/{automated => src}/buffer-tests.el            |    0
 test/{automated => src}/cmds-tests.el              |    0
 test/{automated => src}/data-tests.el              |    0
 .../zlib-tests.el => src/decompress-tests.el}      |    6 +-
 test/{automated => src}/fns-tests.el               |    0
 .../inotify-test.el => src/inotify-tests.el}       |    0
 test/{automated => src}/keymap-tests.el            |    0
 test/{automated => src}/print-tests.el             |    0
 .../libxml-tests.el => src/xml-tests.el}           |    0
 308 files changed, 5051 insertions(+), 1810 deletions(-)

diff --git a/.gitignore b/.gitignore
index fda50e9..6821791 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,10 +42,10 @@ InfoPlist.strings
 Makefile
 makefile
 !etc/refcards/Makefile
-!test/automated/data/flymake/Makefile
-!test/indent/Makefile
-!test/etags/Makefile
-!test/etags/make-src/Makefile
+!test/lisp/progmodes/flymake-resources/Makefile
+!test/manual/indent/Makefile
+!test/manual/etags/Makefile
+!test/manual/etags/make-src/Makefile
 /*.cache
 /confdefs.h
 /config.status
@@ -149,10 +149,12 @@ src/*.map
 # Tests.
 test/indent/*.new
 test/biditest.txt
-test/etags/srclist
-test/etags/regexfile
-test/etags/ETAGS
-test/etags/CTAGS
+test/manual/etags/srclist
+test/manual/etags/regexfile
+test/manual/etags/ETAGS
+test/manual/etags/CTAGS
+# Generated by test/make-test-deps.emacs-lisp
+test/make-test-deps.mk
 
 # ctags, etags.
 TAGS
diff --git a/CONTRIBUTE b/CONTRIBUTE
index 2aae251..b385d68 100644
--- a/CONTRIBUTE
+++ b/CONTRIBUTE
@@ -144,10 +144,10 @@ messages:
   "2014-01-16T05:43:address@hidden".  Often, "my previous commit"
   will suffice.
 
-- There is no need to mention files such as NEWS, MAINTAINERS, and
-  FOR-RELEASE, or to indicate regeneration of files such as
-  'configure', in the ChangeLog entry.  "There is no need" means you
-  don't have to, but you can if you want to.
+- There is no need to mention files such as NEWS and MAINTAINERS, or
+  to indicate regeneration of files such as 'configure', in the
+  ChangeLog entry.  "There is no need" means you don't have to, but
+  you can if you want to.
 
 ** Generating ChangeLog entries
 
@@ -177,13 +177,6 @@ before possibly being merged to the trunk.
 
 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 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.
 
@@ -258,9 +251,9 @@ for more information on writing and running tests.
 
 To run tests on the entire Emacs tree, run "make check" from the
 top-level directory.  Most tests are in the directory
-"test/automated".  From the "test/automated" directory, run "make
+"test/".  From the "test/" directory, run "make
 <filename>" to run the tests for <filename>.el(c).  See
-"test/automated/Makefile" for more information.
+"test/Makefile" for more information.
 
 ** Understanding Emacs Internals.
 
diff --git a/ChangeLog.2 b/ChangeLog.2
index 3636e38..3ebd2da 100644
--- a/ChangeLog.2
+++ b/ChangeLog.2
@@ -1,3 +1,1933 @@
+2015-11-28  Michael Albinus  <address@hidden>
+
+       Fix a problem with gfilenotify in filenotify-tests.el
+
+       * test/lisp/filenotify-tests.el
+       (file-notify--test-expected-events): Remove.
+       (file-notify--test-cleanup): Do not set that variable.
+       (file-notify--test-with-events): EVENTS can also be a list of lists.
+       (file-notify-test02-events, file-notify-test04-file-validity):
+       Adapt expected result.
+
+2015-11-28  Eli Zaretskii  <address@hidden>
+
+       * .gitignore: Adjust to changes in 'test' directory structure.
+
+2015-11-28  Eli Zaretskii  <address@hidden>
+
+       Fix test/manual/etags/Makefile
+
+       * test/manual/etags/Makefile (ETAGS_PROG, CTAGS_PROG): Adjust to
+       changes in 'test' directory structure.
+
+2015-11-27  Phillip Lord  <address@hidden>
+
+       Exclude resource dirs from search for tests.
+
+       * test/Makefile.in: Test file locations are now found with find
+         rather than using finds native functions.
+
+2015-11-27  Phillip Lord  <address@hidden>
+
+       Add test targets without directory names.
+
+        * (test/Makefile.in): Extend test_template to add two targets for each
+          file.
+
+2015-11-27  Artur Malabarba  <address@hidden>
+
+       * lisp/emacs-lisp/package.el: Require url-handlers
+
+2015-11-27  Phillip Lord  <address@hidden>
+
+       Move elisp-mode-tests to new function names.
+
+        * test/lisp/progmodes/elisp-mode-tests.el (find-defsdefun-c-defvar-c,
+        find-defs-defun-el-defvar-c): Call `elisp--xref-find-definitions'.
+
+2015-11-27  Juanma Barranquero  <address@hidden>
+
+       * lisp/emacs-lisp/package.el: Declare `url-insert-buffer-contents'
+
+2015-11-26  Phillip Lord  <address@hidden>
+
+       Merge branch 'feature/standard-test-location'
+
+2015-11-25  Stefan Monnier  <address@hidden>
+
+       * lisp/emacs-lisp/eieio.el: Add some default implementations
+
+       (standard-class): Mark it obsolete.
+       (slot-missing): Give it a default implementation.
+       (destructor): Simplify and mark it obsolete.
+       (object-print): Give it a default implementation.
+       (eieio-change-class): Rename from change-class.
+       (change-class): Redefine as obsolete alias.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Some final fixes in file notification before merging with master
+
+       * lisp/filenotify.el (file-notify--rm-descriptor): Remove WHAT arg.
+       (file-notify-callback): Improve check for `stopped' event.  Call
+       `file-notify-rm-watch' rather than `file-notify--rm-descriptor'.
+       (file-notify-add-watch): In case FILE is not a directory, call the
+       file monitor for the kqueue backend.  Otherwise, call the
+       directory monitor for the upper directory.
+
+       * src/inotify.c (inotifyevent_to_event): Extract file name from
+       watch_object if the event doesn't provide it.
+       (Finotify_add_watch): Add file name to watch_object.
+
+       * test/automated/file-notify-tests.el (file-notify--test-timeout):
+       Use different timeouts for different libraries.
+       (file-notify--test-with-events): Suppress lock files.  Flush
+       outstanding events before running the body.
+       (file-notify-test02-events, file-notify-test04-file-validity): Do
+       not skip cygwin tests.  Add additional test for file creation.
+       Adapt expected result for different backends.
+       (file-notify-test03-autorevert): Some of the tests don't work for
+       w32notify.
+       (file-notify-test06-many-events): Rename into both directions.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Rework file notifications, kqueue has problems with directory monitors
+
+       * lisp/filenotify.el (file-notify-add-watch): Call the native
+       add-watch function on the file, not on the dir.
+
+       * src/kqueue.c (kqueue_compare_dir_list): Make also bookkeeping
+       about already deleted entries.
+
+       * test/automated/auto-revert-tests.el
+       (auto-revert-test01-auto-revert-several-files): Do not call "cp -f"
+       since this deletes the target file first.
+
+       * test/automated/file-notify-tests.el (file-notify--test-event-test):
+       Make stronger checks.
+       (file-notify-test01-add-watch, file-notify-test02-events)
+       (file-notify-test04-file-validity, file-notify-test05-dir-validity):
+       Rewrite in order to call file monitors but directory monitors.
+       (file-notify-test06-many-events): Ler rename work in both directions.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Continue with pending events
+
+       * src/kqueue.c (pending_events): Remove global variable.
+       (kqueue_compare_dir_list): Create `write' event for not used
+       pending events.
+       (globals_of_kqueue): Remove initialization of pending_events.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Improve loops in file-notify-test06-many-events
+
+       * test/automated/file-notify-tests.el (file-notify-test06-many-events):
+       Use `read-event' pauses for the `write-file' loops; otherwise
+       events are lost in inotify and gfilenotify cases.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Handle more complex rename operation in kqueue
+
+       * src/kqueue.c (pending_events): New variable.
+       (kqueue_compare_dir_list): Handle more complex rename operation.
+       (globals_of_kqueue): Initialize pending_events.
+
+       * test/automated/file-notify-tests.el (file-notify-test06-many-events):
+       Adapt expected events in the `rename-file' case.
+       (file-notify-test06-many-events-remote): Declare.
+
+2015-11-25  Wolfgang Jenkner  <address@hidden>
+
+       New test with a larger number of events
+
+       * test/automated/file-notify-tests.el (file-notify--test-with-events):
+       Make timeout heuristically depend on the number of events.
+
+       (file-notify-test06-many-events): Use it for new test.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Further fixes for kqueue
+
+       * lisp/filenotify.el (file-notify-callback): Raise also event if
+       directory name matches.
+       (file-notify-add-watch): Add `create' to the flags for `kqueue'.
+
+       * src/kqueue.c (kqueue_generate_event): Use watch_object as
+       argument instead of ident.  Remove callback argument.  Adapt
+       callees.  Check actions whether they are monitored flags.
+
+       * test/automated/file-notify-tests.el (file-notify--test-library):
+       New defun.
+       (file-notify-test00-availability, file-notify-test02-events)
+       (file-notify-test04-file-validity)
+       (file-notify-test05-dir-validity): Use it.
+       (file-notify-test02-events, file-notify-test04-file-validity): Add
+       `read-event' calls between different file actions, in order to
+       give the backends a chance to rais an event.  Needed especially
+       for kqueue.  In case of deleting a directory, there are two
+       `deleted' events.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Code cleanup of kqueue.c
+
+       * src/kqueue.c (kqueue_directory_listing): Skip "." and "..".
+       (kqueue_compare_dir_list): Do not loop when calling
+       directory_files_internal.  Remove checks for "." and "..", this is
+       done in kqueue_directory_listing now.
+       (Fkqueue_add_watch): Check for proper emacs_open flags.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Doc changes for kqueue
+
+       * doc/lispref/os.texi (File Notifications): Add kqueue as backend.
+       Fix some glitches in the example.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Finish implementation in kqueue.c
+
+       * src/kqueue.c (kqueue_directory_listing, kqueue_callback):
+       Simplify access to list.
+       (kqueue_compare_dir_list): Simplify access to list.  Raise
+       `delete' event if directory does not exist any longer.  Otherwise,
+       wait until directory contents has changed.  Fix error in check.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       * lisp/filenotify.el (file-notify-add-watch): Fix thinko.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       More work on kqueue
+
+       * lisp/filenotify.el (file-notify-callback): Handle also the
+       `rename' event from kqueue.
+       (file-notify-add-watch): Do not register an entry twice.
+
+       * src/kqueue.c (kqueue_directory_listing): New function.
+       (kqueue_generate_event): New argument FILE1.  Adapt callees.
+       (kqueue_compare_dir_list): Rewrite in order to make it more robust.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Implement directory events
+
+       * lisp/filenotify.el (file-notify-handle-event)
+       (file-notify-callback): Remove traces.
+
+       * src/kqueue.c: Include <sys/time.h>.
+       (kqueue_generate_event, kqueue_compare_dir_list): New functions.
+       (kqueue_callback): Use them.  Call kevent() with a zero timeout.
+       (Fkqueue_add_watch): Adapt docstring.  Support directory events.
+       Compute initial directory listing.  Close file descriptor in case
+       of errors.
+       (syms_of_kqueue): Declare Qcreate.
+
+2015-11-25  Wolfgang Jenkner  <address@hidden>
+
+       Build fixes for kqueue support
+
+       * src/kqueue.c (Fkqueue_add_watch): O_BINARY is not a POSIX open(3)
+       flag.
+
+       * configure.ac (HAVE_KQUEUE): There is no pkg-config module for native
+       kqueue on *BSD.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Continue kqueue implementation
+
+       * lisp/filenotify.el (file-notify-handle-event)
+       (file-notify-callback): Enable trace messages.
+
+       * src/kqueue.c: Include also <sys/types.h>.
+       (kqueue_callback): Remove watch in case of NOTE_DELETE or NOTE_RENAME.
+       (Fkqueue_rm_watch, Fkqueue_valid_p): New functions.
+       (syms_of_kqueue): Add them.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Work on kqueue
+
+       * lisp/filenotify.el (file-notify--library)
+       (file-notify-descriptors, file-notify-callback)
+       (file-notify-add-watch, file-notify-rm-watch)
+       (file-notify-valid-p): Add kqueue support.
+
+       * src/keyboard.c (make_lispy_event): Check also for HAVE_KQUEUE.
+
+2015-11-25  Michael Albinus  <address@hidden>
+
+       Add kqueue support
+
+       * configure.ac (--with-file-notification): Add kqueue.
+       (top): Remove special test for "${HAVE_NS}" and
+       ${with_file_notification}, this is handled inside gfilenotify
+       tests.  Add kqueue tests.  Use NOTIFY_CFLAGS and NOTIFY_LIBS
+       instead of library specific variables.
+
+       * src/Makefile.in: Use NOTIFY_CFLAGS and NOTIFY_LIBS.
+
+       * src/emacs.c (main): Call globals_of_kqueue and syms_of_kqueue.
+
+       * src/kqueue.c: New file.
+
+       * src/lisp.h: Declare extern globals_of_kqueue and syms_of_kqueue.
+
+2015-11-24  Phillip Lord  <address@hidden>
+
+       Update elisp-mode-tests for changed file location.
+
+        * test/lisp/progmodes/elisp-mode-tests.el:
+
+2015-11-24  Phillip Lord  <address@hidden>
+
+       Exclude manual tests from Makefile
+
+        * test/Makefile.in:
+
+2015-11-24  Phillip Lord  <address@hidden>
+
+       Move package test files to new directory.
+
+        * test/lisp/emacs-lisp/package-tests.el: Update resoruce file location.
+        * test/data/package: Moved to test/lisp/emacs-lisp/package-resources
+
+2015-11-24  Phillip Lord  <address@hidden>
+
+       Restore delete Makefiles and fix .gitignore.
+
+        * .gitignore: Update Makefiles to changed locations
+        * test/lisp/progmodes/flymake-resources/Makefile,
+          test/manual/etags/Makefile,
+          test/manual/etags/make-src/Makefile,
+          test/manual/indent/Makefile: Restored and moved to new location.
+
+2015-11-24  Phillip Lord  <address@hidden>
+
+       Test infrastructure: updates after directory move
+
+        * (test/Makefile.in): Support directories several levels deep.
+        * (test/data/flymake): Rename to test/lisp/progmodes/flymake-resources.
+        * (test/lisp/progmodes/flymake-tests.el): Support renamed resource 
directory.
+
+2015-11-24  Phillip Lord  <address@hidden>
+
+       Rename all test files to reflect source layout.
+
+        * CONTRIBUTE,Makefile.in,configure.ac: Update to reflect
+          test directory moves.
+        * test/file-organisation.org: New file.
+        * test/automated/Makefile.in
+          test/automated/data/decompress/foo.gz
+          test/automated/data/epg/pubkey.asc
+          test/automated/data/epg/seckey.asc
+          test/automated/data/files-bug18141.el.gz
+          test/automated/data/flymake/test.c
+          test/automated/data/flymake/test.pl
+          test/automated/data/package/archive-contents
+          test/automated/data/package/key.pub
+          test/automated/data/package/key.sec
+          test/automated/data/package/multi-file-0.2.3.tar
+          test/automated/data/package/multi-file-readme.txt
+          test/automated/data/package/newer-versions/archive-contents
+          test/automated/data/package/newer-versions/new-pkg-1.0.el
+          test/automated/data/package/newer-versions/simple-single-1.4.el
+          test/automated/data/package/package-test-server.py
+          test/automated/data/package/signed/archive-contents
+          test/automated/data/package/signed/archive-contents.sig
+          test/automated/data/package/signed/signed-bad-1.0.el
+          test/automated/data/package/signed/signed-bad-1.0.el.sig
+          test/automated/data/package/signed/signed-good-1.0.el
+          test/automated/data/package/signed/signed-good-1.0.el.sig
+          test/automated/data/package/simple-depend-1.0.el
+          test/automated/data/package/simple-single-1.3.el
+          test/automated/data/package/simple-single-readme.txt
+          test/automated/data/package/simple-two-depend-1.1.el
+          test/automated/abbrev-tests.el
+          test/automated/auto-revert-tests.el
+          test/automated/calc-tests.el
+          test/automated/icalendar-tests.el
+          test/automated/character-fold-tests.el
+          test/automated/comint-testsuite.el
+          test/automated/descr-text-test.el
+          test/automated/electric-tests.el
+          test/automated/cl-generic-tests.el
+          test/automated/cl-lib-tests.el
+          test/automated/eieio-test-methodinvoke.el
+          test/automated/eieio-test-persist.el
+          test/automated/eieio-tests.el
+          test/automated/ert-tests.el
+          test/automated/ert-x-tests.el
+          test/automated/generator-tests.el
+          test/automated/let-alist.el
+          test/automated/map-tests.el
+          test/automated/advice-tests.el
+          test/automated/package-test.el
+          test/automated/pcase-tests.el
+          test/automated/regexp-tests.el
+          test/automated/seq-tests.el
+          test/automated/subr-x-tests.el
+          test/automated/tabulated-list-test.el
+          test/automated/thunk-tests.el
+          test/automated/timer-tests.el
+          test/automated/epg-tests.el
+          test/automated/eshell.el
+          test/automated/faces-tests.el
+          test/automated/file-notify-tests.el
+          test/automated/auth-source-tests.el
+          test/automated/gnus-tests.el
+          test/automated/message-mode-tests.el
+          test/automated/help-fns.el
+          test/automated/imenu-test.el
+          test/automated/info-xref.el
+          test/automated/mule-util.el
+          test/automated/isearch-tests.el
+          test/automated/json-tests.el
+          test/automated/bytecomp-tests.el
+          test/automated/coding-tests.el
+          test/automated/core-elisp-tests.el
+          test/automated/decoder-tests.el
+          test/automated/files.el
+          test/automated/font-parse-tests.el
+          test/automated/lexbind-tests.el
+          test/automated/occur-tests.el
+          test/automated/process-tests.el
+          test/automated/syntax-tests.el
+          test/automated/textprop-tests.el
+          test/automated/undo-tests.el
+          test/automated/man-tests.el
+          test/automated/completion-tests.el
+          test/automated/dbus-tests.el
+          test/automated/newsticker-tests.el
+          test/automated/sasl-scram-rfc-tests.el
+          test/automated/tramp-tests.el
+          test/automated/obarray-tests.el
+          test/automated/compile-tests.el
+          test/automated/elisp-mode-tests.el
+          test/automated/f90.el
+          test/automated/flymake-tests.el
+          test/automated/python-tests.el
+          test/automated/ruby-mode-tests.el
+          test/automated/subword-tests.el
+          test/automated/replace-tests.el
+          test/automated/simple-test.el
+          test/automated/sort-tests.el
+          test/automated/subr-tests.el
+          test/automated/reftex-tests.el
+          test/automated/sgml-mode-tests.el
+          test/automated/tildify-tests.el
+          test/automated/thingatpt.el
+          test/automated/url-future-tests.el
+          test/automated/url-util-tests.el
+          test/automated/add-log-tests.el
+          test/automated/vc-bzr.el
+          test/automated/vc-tests.el
+          test/automated/xml-parse-tests.el
+          test/BidiCharacterTest.txt
+          test/biditest.el
+          test/cedet/cedet-utests.el
+          test/cedet/ede-tests.el
+          test/cedet/semantic-ia-utest.el
+          test/cedet/semantic-tests.el
+          test/cedet/semantic-utest-c.el
+          test/cedet/semantic-utest.el
+          test/cedet/srecode-tests.el
+          test/cedet/tests/test.c
+          test/cedet/tests/test.el
+          test/cedet/tests/test.make
+          test/cedet/tests/testdoublens.cpp
+          test/cedet/tests/testdoublens.hpp
+          test/cedet/tests/testfriends.cpp
+          test/cedet/tests/testjavacomp.java
+          test/cedet/tests/testnsp.cpp
+          test/cedet/tests/testpolymorph.cpp
+          test/cedet/tests/testspp.c
+          test/cedet/tests/testsppcomplete.c
+          test/cedet/tests/testsppreplace.c
+          test/cedet/tests/testsppreplaced.c
+          test/cedet/tests/testsubclass.cpp
+          test/cedet/tests/testsubclass.hh
+          test/cedet/tests/testtypedefs.cpp
+          test/cedet/tests/testvarnames.c
+          test/etags/CTAGS.good
+          test/etags/ETAGS.good_1
+          test/etags/ETAGS.good_2
+          test/etags/ETAGS.good_3
+          test/etags/ETAGS.good_4
+          test/etags/ETAGS.good_5
+          test/etags/ETAGS.good_6
+          test/etags/a-src/empty.zz
+          test/etags/a-src/empty.zz.gz
+          test/etags/ada-src/2ataspri.adb
+          test/etags/ada-src/2ataspri.ads
+          test/etags/ada-src/etags-test-for.ada
+          test/etags/ada-src/waroquiers.ada
+          test/etags/c-src/a/b/b.c
+          test/etags/c-src/abbrev.c
+          test/etags/c-src/c.c
+          test/etags/c-src/dostorture.c
+          test/etags/c-src/emacs/src/gmalloc.c
+          test/etags/c-src/emacs/src/keyboard.c
+          test/etags/c-src/emacs/src/lisp.h
+          test/etags/c-src/emacs/src/regex.h
+          test/etags/c-src/etags.c
+          test/etags/c-src/exit.c
+          test/etags/c-src/exit.strange_suffix
+          test/etags/c-src/fail.c
+          test/etags/c-src/getopt.h
+          test/etags/c-src/h.h
+          test/etags/c-src/machsyscalls.c
+          test/etags/c-src/machsyscalls.h
+          test/etags/c-src/sysdep.h
+          test/etags/c-src/tab.c
+          test/etags/c-src/torture.c
+          test/etags/cp-src/MDiagArray2.h
+          test/etags/cp-src/Range.h
+          test/etags/cp-src/burton.cpp
+          test/etags/cp-src/c.C
+          test/etags/cp-src/clheir.cpp.gz
+          test/etags/cp-src/clheir.hpp
+          test/etags/cp-src/conway.cpp
+          test/etags/cp-src/conway.hpp
+          test/etags/cp-src/fail.C
+          test/etags/cp-src/functions.cpp
+          test/etags/cp-src/screen.cpp
+          test/etags/cp-src/screen.hpp
+          test/etags/cp-src/x.cc
+          test/etags/el-src/TAGTEST.EL
+          test/etags/el-src/emacs/lisp/progmodes/etags.el
+          test/etags/erl-src/gs_dialog.erl
+          test/etags/f-src/entry.for
+          test/etags/f-src/entry.strange.gz
+          test/etags/f-src/entry.strange_suffix
+          test/etags/forth-src/test-forth.fth
+          test/etags/html-src/algrthms.html
+          test/etags/html-src/index.shtml
+          test/etags/html-src/software.html
+          test/etags/html-src/softwarelibero.html
+          test/etags/lua-src/allegro.lua
+          test/etags/objc-src/PackInsp.h
+          test/etags/objc-src/PackInsp.m
+          test/etags/objc-src/Subprocess.h
+          test/etags/objc-src/Subprocess.m
+          test/etags/objcpp-src/SimpleCalc.H
+          test/etags/objcpp-src/SimpleCalc.M
+          test/etags/pas-src/common.pas
+          test/etags/perl-src/htlmify-cystic
+          test/etags/perl-src/kai-test.pl
+          test/etags/perl-src/yagrip.pl
+          test/etags/php-src/lce_functions.php
+          test/etags/php-src/ptest.php
+          test/etags/php-src/sendmail.php
+          test/etags/prol-src/natded.prolog
+          test/etags/prol-src/ordsets.prolog
+          test/etags/ps-src/rfc1245.ps
+          test/etags/pyt-src/server.py
+          test/etags/tex-src/gzip.texi
+          test/etags/tex-src/nonewline.tex
+          test/etags/tex-src/testenv.tex
+          test/etags/tex-src/texinfo.tex
+          test/etags/y-src/atest.y
+          test/etags/y-src/cccp.c
+          test/etags/y-src/cccp.y
+          test/etags/y-src/parse.c
+          test/etags/y-src/parse.y
+          test/indent/css-mode.css
+          test/indent/js-indent-init-dynamic.js
+          test/indent/js-indent-init-t.js
+          test/indent/js-jsx.js
+          test/indent/js.js
+          test/indent/latex-mode.tex
+          test/indent/modula2.mod
+          test/indent/nxml.xml
+          test/indent/octave.m
+          test/indent/pascal.pas
+          test/indent/perl.perl
+          test/indent/prolog.prolog
+          test/indent/ps-mode.ps
+          test/indent/ruby.rb
+          test/indent/scheme.scm
+          test/indent/scss-mode.scss
+          test/indent/sgml-mode-attribute.html
+          test/indent/shell.rc
+          test/indent/shell.sh
+          test/redisplay-testsuite.el
+          test/rmailmm.el
+          test/automated/buffer-tests.el
+          test/automated/cmds-tests.el
+          test/automated/data-tests.el
+          test/automated/finalizer-tests.el
+          test/automated/fns-tests.el
+          test/automated/inotify-test.el
+          test/automated/keymap-tests.el
+          test/automated/print-tests.el
+          test/automated/libxml-tests.el
+          test/automated/zlib-tests.el: Files Moved.
+
+2015-11-20  Michael Albinus  <address@hidden>
+
+       Rework file notifications, kqueue has problems with directory monitors
+
+       * lisp/filenotify.el (file-notify-add-watch): Call the native
+       add-watch function on the file, not on the dir.
+
+       * src/kqueue.c (kqueue_compare_dir_list): Make also bookkeeping
+       about already deleted entries.
+
+       * test/automated/auto-revert-tests.el
+       (auto-revert-test01-auto-revert-several-files): Do not call "cp -f"
+       since this deletes the target file first.
+
+       * test/automated/file-notify-tests.el (file-notify--test-event-test):
+       Make stronger checks.
+       (file-notify-test01-add-watch, file-notify-test02-events)
+       (file-notify-test04-file-validity, file-notify-test05-dir-validity):
+       Rewrite in order to call file monitors but directory monitors.
+       (file-notify-test06-many-events): Ler rename work in both directions.
+
+2015-11-19  Michael Albinus  <address@hidden>
+
+       Continie with pending events
+
+       * src/kqueue.c (pending_events): Remove global variable.
+       (kqueue_compare_dir_list): Create `write' event for not used
+       pending events.
+       (globals_of_kqueue): Remove initialization of pending_events.
+
+2015-11-19  Michael Albinus  <address@hidden>
+
+       Improve loops in file-notify-test06-many-events
+
+       * test/automated/file-notify-tests.el (file-notify-test06-many-events):
+       Use `read-event' pauses for the `write-file' loops; otherwise
+       events are lost in inotify and gfilenotify cases.
+
+2015-11-19  Michael Albinus  <address@hidden>
+
+       Handle more complex rename operation in kqueue
+
+       * src/kqueue.c (pending_events): New variable.
+       (kqueue_compare_dir_list): Handle more complex rename operation.
+       (globals_of_kqueue): Initialize pending_events.
+
+       * test/automated/file-notify-tests.el (file-notify-test06-many-events):
+       Adapt expected events in the `rename-file' case.
+       (file-notify-test06-many-events-remote): Declare.
+
+2015-11-18  Wolfgang Jenkner  <address@hidden>
+
+       New test with a larger number of events.
+
+       * test/automated/file-notify-tests.el (file-notify--test-with-events):
+       Make timeout heuristically depend on the number of events.
+
+       (file-notify-test06-many-events): Use it for new test.
+
+2015-11-18  Michael Albinus  <address@hidden>
+
+       Further fixes for kqueue.
+
+       * lisp/filenotify.el (file-notify-callback): Raise also event if
+       directory name matches.
+       (file-notify-add-watch): Add `create' to the flags for `kqueue'.
+
+       * src/kqueue.c (kqueue_generate_event): Use watch_object as
+       argument instead of ident.  Remove callback argument.  Adapt
+       callees.  Check actions whether they are monitored flags.
+
+       * test/automated/file-notify-tests.el (file-notify--test-library):
+       New defun.
+       (file-notify-test00-availability, file-notify-test02-events)
+       (file-notify-test04-file-validity)
+       (file-notify-test05-dir-validity): Use it.
+       (file-notify-test02-events, file-notify-test04-file-validity): Add
+       `read-event' calls between different file actions, in order to
+       give the backends a chance to rais an event.  Needed especially
+       for kqueue.  In case of deleting a directory, there are two
+       `deleted' events.
+
+2015-11-17  Michael Albinus  <address@hidden>
+
+       Code cleanup of kqueue.c
+
+       * src/kqueue.c (kqueue_directory_listing): Skip "." and "..".
+       (kqueue_compare_dir_list): Do not loop when calling
+       directory_files_internal.  Remove checks for "." and "..", this is
+       done in kqueue_directory_listing now.
+       (Fkqueue_add_watch): Check for proper emacs_open flags.
+
+2015-11-16  Michael Albinus  <address@hidden>
+
+       Doc changes for kqueue
+
+       * doc/lispref/os.texi (File Notifications): Add kqueue as backend.
+       Fix some glitches in the example.
+
+2015-11-16  Michael Albinus  <address@hidden>
+
+       Finish implementation in kqueue.c
+
+       * src/kqueue.c (kqueue_directory_listing, kqueue_callback):
+       Simplify access to list.
+       (kqueue_compare_dir_list): Simplify access to list.  Raise
+       `delete' event if directory does not exist any longer.  Otherwise,
+       wait until directory contents has changed.  Fix error in check.
+
+2015-11-16  Michael Albinus  <address@hidden>
+
+       * lisp/filenotify.el (file-notify-add-watch): Fix thinko.
+
+2015-11-15  Michael Albinus  <address@hidden>
+
+       More work on kqueue
+
+       * lisp/filenotify.el (file-notify-callback): Handle also the
+       `rename' event from kqueue.
+       (file-notify-add-watch): Do not register an entry twice.
+
+       * src/kqueue.c (kqueue_directory_listing): New function.
+       (kqueue_generate_event): New argument FILE1.  Adapt callees.
+       (kqueue_compare_dir_list): Rewrite in order to make it more robust.
+
+2015-11-14  Michael Albinus  <address@hidden>
+
+       Implement directory events
+
+       * lisp/filenotify.el (file-notify-handle-event)
+       (file-notify-callback): Remove traces.
+
+       * src/kqueue.c: Include <sys/time.h>.
+       (kqueue_generate_event, kqueue_compare_dir_list): New functions.
+       (kqueue_callback): Use them.  Call kevent() with a zero timeout.
+       (Fkqueue_add_watch): Adapt docstring.  Support directory events.
+       Compute initial directory listing.  Close file descriptor in case
+       of errors.
+       (syms_of_kqueue): Declare Qcreate.
+
+2015-11-11  Wolfgang Jenkner  <address@hidden>
+
+       Build fixes for kqueue support.
+
+       * src/kqueue.c (Fkqueue_add_watch): O_BINARY is not a POSIX open(3)
+       flag.
+
+       * configure.ac (HAVE_KQUEUE): There is no pkg-config module for native
+       kqueue on *BSD.
+
+2015-11-11  Michael Albinus  <address@hidden>
+
+       Continue kqueue implementation
+
+       * lisp/filenotify.el (file-notify-handle-event)
+       (file-notify-callback): Enable trace messages.
+
+       * src/kqueue.c: Include also <sys/types.h>.
+       (kqueue_callback): Remove watch in case of NOTE_DELETE or NOTE_RENAME.
+       (Fkqueue_rm_watch, Fkqueue_valid_p): New functions.
+       (syms_of_kqueue): Add them.
+
+2015-11-11  Michael Albinus  <address@hidden>
+
+       Work on kqueue
+
+       * lisp/filenotify.el (file-notify--library)
+       (file-notify-descriptors, file-notify-callback)
+       (file-notify-add-watch, file-notify-rm-watch)
+       (file-notify-valid-p): Add kqueue support.
+
+       * src/keyboard.c (make_lispy_event): Check also for HAVE_KQUEUE.
+
+2015-11-11  Michael Albinus  <address@hidden>
+
+       Add kqueue support
+
+       * configure.ac (--with-file-notification): Add kqueue.
+       (top): Remove special test for "${HAVE_NS}" and
+       ${with_file_notification}, this is handled inside gfilenotify
+       tests.  Add kqueue tests.  Use NOTIFY_CFLAGS and NOTIFY_LIBS
+       instead of library specific variables.
+
+       * src/Makefile.in: Use NOTIFY_CFLAGS and NOTIFY_LIBS.
+
+       * src/emacs.c (main): Call globals_of_kqueue and syms_of_kqueue.
+
+       * src/kqueue.c: New file.
+
+       * src/lisp.h: Declare extern globals_of_kqueue and syms_of_kqueue.
+
+2015-11-21  Wilson Snyder  <address@hidden>
+
+       verilog-mode.el: Commentary and fix pre-Emacs 21 behavior.
+
+       * verilog-mode.el (verilog-save-font-no-change-functions):
+       Commentary and fix pre-Emacs 21 behavior.
+
+2015-11-19  Przemysław Wojnowski  <address@hidden>
+
+       Use obarray functions from obarray.
+
+       * lisp/abbrev.el (copy-abbrev-table, abbrev-table-p, make-abbrev-table,
+         abbrev-table-get, abbrev-table-put, abbrev-table-empty-p,
+         clear-abbrev-table, define-abbrev, abbrev--symbol, abbrev-table-menu):
+         delegate to obarray.el functions.
+       * lisp/loadup.el: load obarray before abbrev
+       * test/automated/abbrev-tests.el: new tests
+
+2015-11-18  Christian Schwarzgruber  <address@hidden>  (tiny change)
+
+       epa.el: Add option to replace original text
+
+       * lisp/epa.el (epa-replace-original-text): New user option.
+       (Bug#21947)
+
+2015-11-18  Mark Oteiza  <address@hidden>
+
+       Add interactive seek command.
+
+       * lisp/mpc.el (mpc-cmd-seekcur): New function.
+       (mpc-seek-current): New command.
+       (mpc-mode-menu): Add entry for mpc-seek-current
+       (mpc-mode-map): Bind mpc-seek-current to "g"
+
+2015-11-18  Mark Oteiza  <address@hidden>
+
+       Fix issue where a new tempfile was created every refresh
+
+       * lisp/mpc.el (mpc-format): Leave dir as relative path
+
+2015-11-18  Stefan Monnier  <address@hidden>
+
+       * lisp/progmodes/cc-defs.el: Use with-silent-modifications
+
+       (c-save-buffer-state): Use with-silent-modifications when available.
+       (c--macroexpand-all): Check macroexpand-all directly rather than
+       c--mapcan-status.
+
+2015-11-18  Stefan Monnier  <address@hidden>
+
+       * lisp/loadup.el: Set max-lisp-eval-depth here
+
+       * lisp/Makefile.in (BIG_STACK_DEPTH, BIG_STACK_OPTS): Remove.
+       (BYTE_COMPILE_FLAGS): Adjust accordingly.
+
+2015-11-17  João Távora  <address@hidden>
+
+       Minor fix to comment indentation and typo in last commit
+
+       * linum.el (linum-update-window): Fix comment indentation and a
+       typo.
+
+2015-11-17  João Távora  <address@hidden>
+
+       linum-mode plays more nicely with other margin-setting extensions
+
+       linum.el will only modify the left margin if it needs to, and will
+       only reset the it back to 0 if it guesses that no-one has touched that
+       margin in the meantime.
+
+       As such, this is a more of a workaround than an actual fix, but fixes
+       the problems described in bug#20674 regarding the interaction with
+       modes such as darkroom-mode and olivetti-mode.
+
+       A similar fix was commited to nlinum.el in ELPA.git's
+       e7f5f549fbfb740b911fb7f33b42381ecece56d8
+
+       * linum.el (linum-delete-overlays): Restore margins more
+       criteriously.
+       (linum-update-window): Set margins more criteriously.
+
+2015-11-16  Daiki Ueno  <address@hidden>
+
+       * lisp/image-mode.el: Support encrypted file
+
+       (image-toggle-display-image): Read content from the buffer instead
+       of the file, if the buffer holds a decrypted data.  (Bug#21870)
+
+2015-11-15  Juanma Barranquero  <address@hidden>
+
+       * lisp/progmodes/verilog-mode.el (verilog-save-buffer-state): Add 
backquote
+
+2015-11-15  Artur Malabarba  <address@hidden>
+
+       * lisp/emacs-lisp/package.el: Fix a decoding issue
+
+       (package--with-response-buffer): Use `url-insert-buffer-contents'.
+       The previous code had some issues with decoding. Refactoring that
+       function allows us to use the decoding from url-handlers while still
+       treating both sync and async requests the same.
+
+       * lisp/url/url-handlers.el (url-insert-file-contents): Move some code to
+       `url-insert-buffer-contents'.
+       (url-insert-buffer-contents): New function
+
+2015-11-15  Artur Malabarba  <address@hidden>
+
+       * lisp/emacs-lisp/package.el: Refactor -with-work-buffer-async
+
+       (package--with-work-buffer-async): Reimplement as
+       `package--with-response-buffer'.
+       (package--with-work-buffer): Mark obsolete.
+       (package--with-response-buffer): New macro. This is a more self
+       contained and less contrived version of
+       `package--with-work-buffer-async'.  It uses keyword arguments,
+       doesn't have async on the name, doesn't fallback on
+       `package--with-work-buffer', and has _much_ simpler error
+       handling.
+
+       (package--check-signature, package--download-one-archive)
+       (package-install-from-archive, describe-package-1): Use it.
+
+       (package--download-and-read-archives): Let
+       `package--download-one-archive' take care of calling
+       `package--update-downloads-in-progress'.
+
+2015-11-15  Stefan Monnier  <address@hidden>
+
+       * lisp/progmodes/verilog-mode.el: Use with-silent-modifications
+
+       (verilog-save-buffer-state): Use with-silent-modifications when 
available.
+       (verilog-save-font-no-change-functions): Don't bind
+       before/after-change-functions if it's not needed.
+
+2015-11-14  Xue Fuqiao  <address@hidden>
+
+       * CONTRIBUTE: Remove information about feature freeze.
+
+       Merge branch 'release-process-lowercase'
+
+2015-11-14  Xue Fuqiao  <address@hidden>
+
+       Document the release process
+
+       * admin/notes/versioning: Add information about RC releases.
+       * admin/release-process: Document the release process.
+       * admin/authors.el (authors-ignored-files):
+       * admin/README: Change FOR-RELEASE to release-process.
+       * CONTRIBUTE:
+       * admin/notes/bugtracker: Don't mention FOR-RELEASE.
+
+2015-11-14  Xue Fuqiao  <address@hidden>
+
+       * admin/release-process: Rename from admin/FOR-RELEASE.
+
+2015-11-14  David Engster  <address@hidden>
+
+       gitmerge: Fix git log command
+
+       * admin/gitmerge.el (gitmerge-missing): Use '--left-only' since we
+       only want commits from the branch that is to be merged.
+       (gitmerge-setup-log-buffer): Use the same symmetric range as in
+       `gitmerge-missing'.
+
+2015-11-14  David Engster  <address@hidden>
+
+       gitmerge: Try to detect cherry-picks
+
+       * admin/gitmerge.el (gitmerge-default-branch): Change to
+       origin/emacs-25.
+       (gitmerge-missing): Use symmetric difference ('...') between
+       branch and master so that cherry-picks can be detected.
+
+2015-11-14  Eli Zaretskii  <address@hidden>
+
+       Increment Emacs version on master branch
+
+       * lisp/cus-edit.el (customize-changed-options-previous-release):
+       Increase previous version to 24.5.
+
+       * configure.ac:
+       * msdos/sed2v2.inp: Bump version to 25.1.50.
+
+2015-11-14  Xue Fuqiao  <address@hidden>
+
+       Mention CONTRIBUTE in README, since it was moved from etc/ to root.
+       * etc/TODO: Remove the reference to `etc/CONTRIBUTE'.
+       * README: Mention CONTRIBUTE.
+
+2015-11-13  Wilson Snyder  <address@hidden>
+
+       Update verilog-mode.el to 2015-11-09-b121d60-vpo
+
+       * verilog-mode.el (verilog-auto, verilog-delete-auto)
+       (verilog-modi-cache-results, verilog-save-buffer-state)
+       (verilog-save-font-no-change-functions): When internally suppressing
+       change functions, use `inhibit-modification-hooks' and call
+       `after-change-funtions' to more nicely work with user hooks.
+       Reported by Stefan Monnier.
+       (verilog-auto, verilog-delete-auto, verilog-delete-auto-buffer):
+       Create `verilog-delete-auto-buffer' to avoid double-calling
+       fontification hooks.
+       (verilog-restore-buffer-modified-p, verilog-auto)
+       (verilog-save-buffer-state): Prefer restore-buffer-modified-p over
+       set-buffer-modified-p.  Reported by Stefan Monnier.
+       (verilog-diff-auto, verilog-diff-buffers-p)
+       (verilog-diff-ignore-regexp): Add `verilog-diff-ignore-regexp'.
+       (verilog-auto-inst-port, verilog-read-sub-decls-expr): Fix
+       AUTOINST with unpacked dimensional parameters, bug981.  Reported by
+       by Amol Nagapurkar.
+       (verilog-read-decls, verilog-read-sub-decls-line): Avoid unneeded
+       properties inside internal structures.  No functional change
+       intended.
+
+2015-11-13  Dmitry Gutov  <address@hidden>
+
+       Use generic dispatch for xref backends
+
+       * lisp/progmodes/xref.el (xref-backend-functions):
+       New variable.
+       (xref-find-function): Remove.
+       (xref-find-backend)
+       (xref--etags-backend): New functions.
+       (xref-identifier-at-point-function)
+       (xref-identifier-completion-table-function): Remove.
+       (xref-backend-definitions, xref-backend-references)
+       (xref-backend-apropos, xref-backend-identifier-at-point)
+       (xref-backend-identifier-completion-table):
+       New generic functions.
+
+       * lisp/progmodes/elisp-mode.el (emacs-lisp-mode):
+       Add `elisp--xref-backend' to the beginning of
+       `xref-backend-functions', locally.  Delete references to
+       removed functions and vars.
+       (elisp-xref-find): Remove.
+       (elisp--xref-backend): New function.
+       (elisp--xref-find-references, elisp--xref-find-apropos)
+       (elisp--xref-identifier-completion-table):
+       Turn into appropriately named generic methods.
+
+       * lisp/progmodes/etags.el (etags-xref-find): Remove.
+       (xref-backend-identifier-completion-table)
+       (xref-backend-references, xref-backend-definitions)
+       (xref-backend-apropos): New generic methods.
+
+2015-11-13  Juri Linkov  <address@hidden>
+
+       Support rectangular regions for more commands
+
+       * lisp/simple.el (region-extract-function): Handle the arg
+       value ‘bounds’.
+       (region-insert-function): New function.
+       (shell-command-on-region): Add arg ‘region-noncontiguous-p’.
+       If non-nil, operate on multiple chunks.
+       (region-noncontiguous-p): New function.
+
+       * lisp/rect.el: Add function rectangle--insert-region
+       around region-insert-function.
+       (extract-rectangle-bounds): New function.
+       (rectangle--extract-region): Handle the arg value ‘bounds’.
+       (rectangle--insert-region): New function.
+
+       * lisp/emulation/cua-rect.el: Add function cua--insert-rectangle
+       around region-insert-function.
+       (cua--extract-rectangle-bounds): New function.
+       (cua--rectangle-region-extract): Handle the arg value ‘bounds’.
+
+       * lisp/replace.el (query-replace, query-replace-regexp): Add arg
+       ‘region-noncontiguous-p’.  Use ‘use-region-p’.
+       (query-replace-regexp-eval, map-query-replace-regexp)
+       (replace-string, replace-regexp): Use ‘use-region-p’.
+       (keep-lines, flush-lines, how-many): Use ‘use-region-p’.
+       (perform-replace): Add arg ‘region-noncontiguous-p’.
+       If non-nil, operate on multiple chunks.
+
+       * src/casefiddle.c (Fdowncase_region): Add arg ‘region-noncontiguous-p’.
+       If non-nil, operate on multiple chunks.  (Bug#19829)
+
+2015-11-13  Dmitry Gutov  <address@hidden>
+
+       Handle multiple matches on the same line; add highlighting
+
+       * lisp/progmodes/xref.el (xref-location-marker): Interpret the
+       column value in characters.
+       (xref--collect-matches): Rename from `xref--collect-match'.
+       Search for all matches in the hit line.  Add `highlight' face to
+       the matched region in the summary.  Update both callers.
+
+2015-11-13  Dmitry Gutov  <address@hidden>
+
+       Replace xref-match-bounds with xref-match-length
+
+       Relying on xref-location-marker to point to the beginning of the match
+
+       * lisp/progmodes/xref.el (xref-match-bounds): Remove.
+       (xref-match-length): Add.
+       (xref-make-match): Change the arguments.
+       (xref--match-buffer-bounds): Remove.
+       (xref-match-item): Store length, instead of end-column.
+       (xref-pulse-momentarily)
+       (xref--collect-match)
+       (xref--query-replace-1): Update accordingly.
+       (xref-query-replace): Ditto.  And check that the search results
+       are up-to-date.
+
+2015-11-13  Paul Eggert  <address@hidden>
+
+       Merge from gnulib
+
+       This incorporates:
+       2015-11-13 xalloc-oversized: improve performance with GCC 5
+       * lib/xalloc-oversized.h: Copy from gnulib.
+
+2015-11-13  Paul Eggert  <address@hidden>
+
+       Spruce up ftfont.c memory allocation
+
+       * src/ftfont.c (setup_otf_gstring):
+       Avoid O(N**2) behavior when reallocating.
+       (ftfont_shape_by_flt): Prefer xpalloc to xrealloc when
+       reallocating buffers; this simplifies the code.  Do not trust
+       mflt_run to leave the output areas unchanged on failure, as
+       this isn’t part of its interface spec.
+
+2015-11-13  Paul Eggert  <address@hidden>
+
+       Port recent XCB changes to 64-bit ‘long int’
+
+       For historical reasons, libX11 represents 32-bit values like Atoms as
+       ‘long int’ even on platforms where ‘long int’ is 64 bits.  XCB doesn’t
+       do that, so adapt the recent XCB code to behave properly on 64-bit
+       platforms.  Also, fix what appears to be a bug in the interpretation
+       of xcb_get_property_value_length, at least on my Fedora platform
+       which is running libxcb-1.11-5.fc21.
+       * src/xfns.c (x_real_pos_and_offsets):
+       * src/xterm.c (get_current_wm_state):
+       xcb_get_property_value_length returns a byte count, not a word count.
+       For 32-bit quantities, xcb_get_property_value returns a vector
+       of 32-bit words, not of (possibly 64-bit) long int.
+
+2015-11-13  Paul Eggert  <address@hidden>
+
+       * src/undo.c (run_undoable_change): Now static.
+
+2015-11-13  Eli Zaretskii  <address@hidden>
+
+       Remove support for ':timeout' from w32 tray notifications
+
+       * src/w32fns.c (Fw32_notification_notify): Delete the code that
+       supports ':timeout'.
+       (syms_of_w32fns): Don't DEFSYM ':timeout'.  This avoids clashes
+       with dbusbind.c when D-Bus is compiled in.
+
+       * doc/lispref/os.texi (Desktop Notifications): Don't mention
+       ':timeout'.
+
+2015-11-13  Juanma Barranquero  <address@hidden>
+
+       * test/automated/simple-test.el: Add test for bug#20698 (bug#21885)
+       (simple-test--transpositions): New macro.
+       (simple-transpose-subr): New test.
+
+2015-11-13  Juanma Barranquero  <address@hidden>
+
+       * lisp/progmodes/elisp-mode.el: Declare function `project-roots'
+
+2015-11-13  Juanma Barranquero  <address@hidden>
+
+       * src/undo.c: Small fixes for previous change
+       (run_undoable_change): Mark void argument list.
+       (record_property_change): Remove unused variable `boundary'.
+
+2015-11-13  Eli Zaretskii  <address@hidden>
+
+       Add a few more variables to redisplay--variables
+
+       * lisp/frame.el (redisplay--variables): Add bidi-paragraph-direction
+       and bidi-display-reordering to the list.
+
+2015-11-13  Eli Zaretskii  <address@hidden>
+
+       * lisp/loadup.el: Enlarge the size of the hash table to 80000.
+
+2015-11-13  Eli Barzilay  <address@hidden>
+
+       Fix point positioning after transposing with negative arg
+
+       * lisp/simple.el (transpose-subr): When invoked with a negative
+       argument, move point to after the transposed text, like we do
+       when invoked with a positive argument.  (Bug#21885)
+
+2015-11-13  Eli Zaretskii  <address@hidden>
+
+       Fix last change in shr.el
+
+       * lisp/net/shr.el (shr--have-one-fringe-p): Rename from
+       have-fringes-p.  All callers changed.  Doc fix.  (Bug#21895)
+
+2015-11-13  Eli Zaretskii  <address@hidden>
+
+       Fix last change
+
+       * src/w32fns.c (syms_of_w32fns) [WINDOWSNT && !HAVE_DBUS]:
+       Don't DEFSYM tray notification symbols if D-Bus is being used.
+
+2015-11-13  Eli Zaretskii  <address@hidden>
+
+       Another fix for MinGW64 and Cygwin builds due to notifications
+
+       * src/w32fns.c: Ifdef away tray notification code if D-Bus is
+       being compiled into Emacs.
+       (syms_of_w32fns) [WINDOWSNT && !HAVE_DBUS]: Don't defsubr
+       Sw32_notification_notify and Sw32_notification_close if the code
+       is not compiled.  Reported by Andy Moreton <address@hidden>.
+
+2015-11-12  YAMAMOTO Mitsuharu  <address@hidden>
+
+       Remove intern calls and XXX comments from Fx_export_frames
+
+       * src/xfns.c (Fx_export_frames): Use Qpdf, Qpng, Qpostscript, and
+       Qsvg instead of intern calls.  Use "postscript" instead of "ps"
+       for consistency with image types.  Remove XXX comments.
+       (syms_of_xfns) <Qpdf>: DEFSYM it.
+
+2015-11-12  Eric Hanchrow  <address@hidden>
+
+       shr: don't invoke unbound function (Bug#21895)
+
+       * lisp/net/shr.el (have-fringes-p): New function.
+       (shr-insert-document, shr-fill-text): Use it.
+
+2015-11-12  Juanma Barranquero  <address@hidden>
+
+       * test/automated/keymaps-test.el: Fix test to make it repeatable
+
+       (keymap-store_in_keymap-FASTINT-on-nonchars): Reset Buffer-menu-mode-map
+       entry to its initial value to make the test repeatable in interactive
+       sessions (assuming it doesn't fail and crashes Emacs, of course).
+
+2015-11-12  Artur Malabarba  <address@hidden>
+
+       * test/automated/cl-lib-tests.el (cl-lib-struct-constructors):
+       Small fix.
+
+2015-11-12  Phillip Lord  <address@hidden>
+
+       The heuristic that Emacs uses to add an `undo-boundary' has been
+       reworked, as it interacts poorly with functions on `post-command-hook'
+       or `after-change-functions'.
+
+       * lisp/simple.el: New section added.
+       * src/cmds.c (remove_excessive_undo_boundaries): Now in lisp.
+       (self_insert_command): Calls simple.el to amalgamate.
+       (delete_char): Calls simple.el to amalgamate.
+       * src/keyboard.c (last_undo_boundary): Removed.
+       * src/undo.c (run_undoable_change): New function.
+
+2015-11-12  Juri Linkov  <address@hidden>
+
+       Bind [?\S-\ ] to previous line command in Dired-like modes
+
+       * lisp/arc-mode.el (archive-mode-map):
+       * lisp/dired.el (dired-mode-map):
+       * lisp/proced.el (proced-mode-map):
+       * lisp/vc/vc-dir.el (vc-dir-mode-map):
+       Bind [?\S-\ ] to previous line command.
+       (Bug#20790)
+
+2015-11-12  Eli Zaretskii  <address@hidden>
+
+       Fix the MinGW64 and Cygwin-w32 builds
+
+       * src/w32fns.c (MYNOTIFYICONDATAW_V1_SIZE)
+       (MYNOTIFYICONDATAW_V2_SIZE, MYNOTIFYICONDATAW_V3_SIZE): Define and
+       use instead of the corresponding NOTIFYICONDATAW_Vn_SIZE macros,
+       which cause trouble with MinGW42 headers.  Ifdef away tray
+       notifications code for Cygwin.  Reported by Andy Moreton
+       <address@hidden>.
+
+2015-11-12  Simen Heggestøyl  <address@hidden>
+
+       Enable sorting of JSON object keys when encoding
+
+       * lisp/json.el (json-encoding-object-sort-predicate): New variable
+       for specifying a sorting predicate for JSON objects during encoding.
+       (json--plist-to-alist): New utility function.
+       (json-encode-hash-table): Re-use `json-encode-alist' when object keys
+       are to be sorted.
+       (json-encode-alist): Sort output by
+       `json-encoding-object-sort-predicate, when set.
+       (json-encode-plist): Re-use `json-encode-alist' when object keys are
+       to be sorted.
+       (json-pretty-print-buffer-ordered): New command to pretty print the
+       buffer with object keys sorted alphabetically.
+       (json-pretty-print-ordered): New command to pretty print the region
+       with object keys sorted alphabetically.
+
+       * test/automated/json-tests.el (test-json-plist-to-alist)
+       (test-json-encode-plist, test-json-encode-hash-table)
+       (test-json-encode-alist-with-sort-predicate)
+       (test-json-encode-plist-with-sort-predicate): New tests.
+
+       * etc/NEWS: Add an entry for the new commands.
+
+2015-11-12  Juanma Barranquero  <address@hidden>
+
+       * test/automated/keymap-tests.el: New test file.
+
+2015-11-12  Ken Raeburn  <address@hidden>
+
+       Speed up x_real_pos_and_offsets using XCB
+
+       * src/xfns.c (x_real_pos_and_offsets) [USE_XCB]: Add XCB flavors of
+       all X calls, and pipeline requests when possible, collecting results
+       later.  Eliminate use of x_catch_errors (and thus XSync) in XCB case.
+
+2015-11-12  Ken Raeburn  <address@hidden>
+
+       Enable use of XCB for checking window manager state
+
+       * src/xterm.c (get_current_wm_state) [USE_XCB]: Use XCB calls instead
+       of XGetWindowProperty plus error-catching, since we can explicitly
+       check for errors in the XCB version.  This eliminates 3 XSync calls on
+       top of the round-trip actually fetching the information.
+
+2015-11-12  Ken Raeburn  <address@hidden>
+
+       Detect XCB and save a connection handle
+
+       * configure.ac: If using X11, check for XCB libraries and header.
+       * src/Makefile.in (XCB_LIBS): Define.
+       (LIBX_EXTRA): Include it.
+
+       * src/xterm.h [USE_XCB]: Include X11/Xlib-xcb.h.
+       (struct x_display_info) [USE_XCB]: Add an XCB connection handle field.
+       * src/xterm.c (x_term_init) [USE_XCB]: Initialize the new field.
+
+2015-11-12  Ken Raeburn  <address@hidden>
+
+       Reduce some data dependencies between X calls
+
+       Gains nothing in the traditional-Xlib code, but more closely aligns
+       with how the XCB version will work.
+
+       * src/xfns.c (x_real_pos_and_offsets): When translating coordinates,
+       send coordinates (0,0) to the X server and add in the real coordinates
+       after getting the response.  Move XGetGeometry for outer window inside
+       error-trapping block.  Use DPY variable more, since it's available.
+
+2015-11-12  Ken Raeburn  <address@hidden>
+
+       Use color cache for creating bitmap
+
+       * src/image.c (x_create_bitmap_from_xpm_data) [ALLOC_XPM_COLORS]:
+       Set attributes to use the caching color allocator.  Initialize and
+       free the cache.
+
+2015-11-12  Eli Barzilay  <address@hidden>
+
+       Add "^" to the interactive specs of `dired-next/previous-line'
+
+       * lisp/dired.el (dired-next-line, dired-previous-line): It makes sense
+       to bind these commands to the arrow keys, and that means that they work
+       better with a "^" in the `interactive' declaration so selection works
+       as expected.
+
+2015-11-11  Thomas Fitzsimmons  <address@hidden>
+
+       Sync with soap-client repository, version 3.0.2
+
+       * soap-client.el: Bump version to 3.0.2.
+
+       * soap-client.el (soap-warning): Use format, not format-message.
+
+       * soap-client.el: Add cl-lib to Package-Requires.  Require cl-lib.
+       (soap-validate-xs-simple-type): Use cl-labels instead of cl-flet.
+
+       * soap-client.el: Support Emacs versions that do not have
+       define-error.
+
+       * soap-inspect.el: Remove version header.
+
+       * soap-client.el, soap-inspect.el, jira2.el: Fix first line header
+       format.
+
+2015-11-11  Alan Mackenzie  <address@hidden>
+
+       CC Mode: Respect users' settings of 
open-paren-in-column-0-is-defun-start
+
+       * lisp/progmodes/cc-engine.el (c-backward-single-comment)
+       (c-backward-comments, c-invalidate-state-cache-1, c-parse-state-1)
+       (c-guess-basic-syntax):
+       Remove bindings of open-paren-in-column-0-is-defun-start to nil.
+       (c-get-fallback-scan-pos): "New" function (existed several years ago).
+       (c-parse-state-get-strategy): Reintroduce the 'BOD strategy, using
+       c-get-fallback-scan-pos.
+       (c-parse-state-1): Handle 'BOD strategy.
+
+       * lisp/progmodes/cc-mode.el (c-before-change, c-after-change)
+       (c-font-lock-fontify-region): Remove bindings of
+       open-paren-in-column-0-is-defun-start to nil.
+
+       * doc/misc/cc-mode.texi (Performance Issues)
+       (Limitations and Known Bugs): Fix mix up between @chapter and @appendix.
+
+2015-11-11  Artur Malabarba  <address@hidden>
+
+       * lisp/obarray.el: Fix shadowed variables.
+       (obarray-map, obarray-remove, obarray-put, obarray-get):
+       Change OBARRAY arg to OB to avoid shadowing ‘obarray’.
+
+2015-11-11  Eli Zaretskii  <address@hidden>
+
+       Avoid error in submitting a form with EWW
+
+       * lisp/gnus/mm-url.el (mm-url-form-encode-xwfu): Allow argument
+       CHUNK to be nil.  (Bug#21881)
+
+2015-11-11  Nicolas Petton  <address@hidden>
+
+       Rename seq-p and map-p to seqp and mapp
+
+       * lisp/emacs-lisp/seq.el (seqp): New name.
+       * lisp/emacs-lisp/map.el (mapp): New name.
+       * doc/lispref/sequences.texi: Update the documentation for seqp.
+       * test/automated/map-tests.el: Update the tests for mapp.
+
+2015-11-11  Nicolas Petton  <address@hidden>
+
+       Rename obarray-p to obarrayp
+
+       * lisp/obarray.el (obarrayp): New name.
+       * test/automated/obarray-tests.el: Update the tests.
+
+2015-11-11  Nicolas Petton  <address@hidden>
+
+       Rename obarray-foreach to obarray-map
+
+       * lisp/obarray.el (obarray-map): New name.
+       * test/automated/obarray-tests.el: Update the corresponding tests.
+
+2015-11-11  Przemysław Wojnowski  <address@hidden>
+
+       New file with obarray functions
+
+       * lisp/obarray.el: Basic obarray functions extracted from abbrev.el.
+       * test/automated/obarray-tests.el: New file.
+
+2015-11-11  Eli Zaretskii  <address@hidden>
+
+       Implement tray notifications for MS-Windows
+
+       * src/w32fns.c (MY_NOTIFYICONDATAW): New typedef.
+       (NOTIFYICONDATAW_V1_SIZE, NOTIFYICONDATAW_V2_SIZE)
+       (NOTIFYICONDATAW_V3_SIZE, NIF_INFO, NIIF_NONE, NIIF_INFO)
+       (NIIF_WARNING, NIIF_ERROR, EMACS_TRAY_NOTIFICATION_ID)
+       (EMACS_NOTIFICATION_MSG): New macros.
+       (NI_Severity): New enumeration.
+       (get_dll_version, utf8_mbslen_lim, add_tray_notification)
+       (delete_tray_notification, Fw32_notification_notify)
+       (Fw32_notification_close): New functions.
+       (syms_of_w32fns): Defsubr functions exposed to Lisp.  DEFSYM
+       keywords used by w32-notification-notify.
+
+       * doc/lispref/os.texi (Desktop Notifications): Describe the native
+       w32 tray notifications.
+
+2015-11-11  Michael Albinus  <address@hidden>
+
+       Optimize `file-equal-p' and `file-in-directory-p' in Tramp
+
+       * lisp/net/tramp.el (tramp-handle-file-equal-p)
+       (tramp-handle-file-in-directory-p): New defuns.  Suggested by
+       Harvey Chapman <address@hidden>.
+
+       * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
+       * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
+       * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
+       * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): Use them.
+
+2015-11-10  Karl Fogel  <address@hidden>
+
+       * CONTRIBUTE: Encourage adding tests.
+
+       Based on this post from John Wiegley:
+
+         From: "John Wiegley" <address@hidden>
+         Subject: Re: [Emacs-diffs] master 1f02cbe: Fix bug#21766 and add test
+         To: Juanma Barranquero <address@hidden>
+         Cc: address@hidden, address@hidden,
+             emacs-devel <address@hidden>
+         Date: Wed, 28 Oct 2015 18:45:29 -0700
+         Message-ID: <address@hidden>
+
+         https://lists.gnu.org/archive/html/emacs-devel/2015-10/msg02372.html
+
+2015-11-10  David Reitter  <address@hidden>
+
+       Avoid creating notification objects when possible
+
+       * src/nsterm.m (windowWillEnterFullScreen, windowWillExitFullScreen:)
+       (windowDidEnterFullScreen, windowDidExitFullScreen): Provide convenience
+       functions that do not require a notification object.  When needed,
+       define NSWindowDidEnterFullScreenNotification to allow for compilation
+       on OS X 10.6.8.
+
+2015-11-10  Paul Eggert  <address@hidden>
+
+       Move INTEGER_TO_CONS body out of .h file
+
+       * src/data.c (INTBIG_TO_LISP): New macro, with most
+       of the contents of the old INTEGER_TO_CONS.
+       (intbig_to_lisp, uintbig_to_lisp): New functions.
+       * src/lisp.h (INTEGER_TO_CONS):
+       Simplify by using EXPR_SIGNED and the new functions.
+       This shrinks code size a bit, and makes it easier to
+       put a breakpoint on handling of large integers.
+
+2015-11-10  Paul Eggert  <address@hidden>
+
+       Merge from gnulib
+
+       This incorporates:
+       2015-11-10 intprops: new public macro EXPR_SIGNED
+       2015-11-10 intprops: fix typo in clang port
+       * lib/intprops.h: Copy from gnulib.
+
+2015-11-10  Paul Eggert  <address@hidden>
+
+       Spelling fixes
+
+       * lisp/net/soap-inspect.el (soap-inspect-xs-simple-type):
+       Fix misspelling in output.
+
+2015-11-10  Artur Malabarba  <address@hidden>
+
+       * doc/lispref/variables.texi (Directory Local Variables):
+       Document dir-locals wildcards.
+
+       * lisp/files.el (dir-locals-file): Point to Info node.
+
+       * doc/emacs/custom.texi (Directory Variables):
+       Document dir-locals wildcards.
+
+       * etc/NEWS: Document new functionality.
+
+2015-11-10  Artur Malabarba  <address@hidden>
+
+       * lisp/files.el: Don't allow customization of dir-locals sorting.
+       In retrospect, this is not a good idea for the same reason that
+       `dir-locals-file' is a defconst, because it is important that this
+       behaviour be "uniform across different environments and users".
+       Sure, the user can still change the sorting with a hack, but we
+       shouldn't encourage them to change it.
+       (dir-locals--all-files): Return list in the order returned by
+       `file-expand-wildcards'.
+       (file-expand-wildcards): Document the sorting predicate used.
+       (dir-locals-sort-predicate): Delete variable.
+
+2015-11-10  Artur Malabarba  <address@hidden>
+
+       * lisp/files.el (dir-locals-read-from-file): Better handle errors.
+
+       * lisp/isearch.el (search-default-regexp-mode): Change default value.
+
+2015-11-10  Artur Malabarba  <address@hidden>
+
+       * lisp/files.el (dir-locals-find-file): Don't stop at unreadable files.
+       `locate-dominating-file' will now keep looking if the files it finds in
+       a given directory are unreadable (or not files).
+
+2015-11-10  Artur Malabarba  <address@hidden>
+
+       * lisp/files.el (dir-locals-file): Allow wildcards.
+       (dir-locals-find-file, dir-locals-collect-variables)
+       (dir-locals-read-from-file): Update accordingly.
+       (hack-dir-local-variables): Rename a local variable.
+
+       * lisp/files-x.el (modify-dir-local-variable): Update accordingly.
+
+       * lisp/help-fns.el (describe-variable): Update accordingly.
+
+       * .gitignore: Add .dir-locals?.el.
+
+2015-11-10  Artur Malabarba  <address@hidden>
+
+       * lisp/emacs-lisp/map.el (map-merge-with): New function.
+
+       * test/automated/map-tests.el (test-map-merge-with): New test.
+
+2015-11-09  Karl Fogel  <address@hidden>
+
+       Fix some recently-perturbed bookmark autoloads
+
+       * lisp/bookmark.el (bookmark-set-internal): Remove unnecessary autoload.
+       (bookmark-set): Restore autoload.
+       (bookmark-set-no-overwrite): Add autoload.
+
+       Thanks to Juanma Barranquero for noticing the autoload problems
+       introduced by my recent commit adding/changing the above functions
+       (Sun Nov 8 14:16:43 2015 -0500, git commit 3812e17978).
+
+2015-11-09  Noah Friedman  <address@hidden>
+
+       * etc/emacs-buffer.gdb (ydump-buffer): Handle case where gap is at
+       the start of buffer.  I don't recall if older versions of gdb were
+       less strict but you cannot dump a 0-length range in gdb 7.9.1.
+
+2015-11-09  Dmitry Gutov  <address@hidden>
+
+       * lisp/progmodes/project.el: Update Commentary.
+
+       Merge branch 'project-next'
+
+2015-11-09  Dmitry Gutov  <address@hidden>
+
+       Fold `project-ask-user' into `project-current'
+
+       * lisp/progmodes/project.el (project-find-functions):
+       Remove `project-ask-user'.
+       (project-ask-user): Remove function and the corresponding
+       `project-roots' implementation.
+       (project-current): Add a new argument, MAYBE-PROMPT.  Prompt the
+       user in case there's no project in the current directory.  Update
+       all callers.
+
+2015-11-09  Karl Fogel  <address@hidden>
+
+       When VC detects a conflict, specify which file
+
+       * lisp/vc/vc.el (vc-message-unresolved-conflicts): New function.
+       * lisp/vc/vc-svn.el (vc-svn-find-file-hook):
+       * lisp/vc/vc-hg.el (vc-hg-find-file-hook):
+       * lisp/vc/vc-bzr.el (vc-bzr-find-file-hook):
+       * lisp/vc/vc-git.el (vc-git-find-file-hook): Use above new function
+         to display a standard message that specifies the conflicted file.
+
+       Before this change, the message VC used for indicating a conflicted
+       file was just "There are unresolved conflicts in this file" without
+       naming the file (and this language was duplicated in several places).
+       After this change, it's "There are unresolved conflicts in file FOO"
+       (and this language is now centralized in one function in vc.el).
+
+       Justification: It's important for the message to name the conflicted
+       file because the moment when VC realizes a file is conflicted does not
+       always come interactively.  For example, some people automatically
+       find a set of Org Mode files on startup, and may keep those .org files
+       under version control.  If any of the files are conflicted, the user
+       just sees some messages fly by, and might later check the "*Messages*"
+       buffer to find out what files were conflicted.  I'm not saying this
+       happened to me or anything; it's a purely hypothetical example.
+
+2015-11-09  Eli Zaretskii  <address@hidden>
+
+       Fix assertion violation in define-key
+
+       * src/keymap.c (store_in_keymap): Don't use XFASTINT on non-character
+       objects.  Reported by Drew Adams <address@hidden>
+       and Juanma Barranquero <address@hidden>.
+
+2015-11-09  Dima Kogan  <address@hidden>
+
+       Fix a memory leak in GC of font cache
+
+       * src/alloc.c (compact_font_cache_entry): Don't GC unmarked font
+       entities if some of the fonts it references are marked.  This
+       plugs a memory leak.  (Bug#21556)
+
+2015-11-09  Paul Eggert  <address@hidden>
+
+       Use INT_ADD_WRAPV etc. to check integer overflow
+
+       * src/alloc.c (xnmalloc, xnrealloc, xpalloc, Fmake_string):
+       * src/buffer.c (record_overlay_string, overlay_strings):
+       * src/casefiddle.c (casify_object):
+       * src/ccl.c (Fccl_execute_on_string):
+       * src/character.c (char_width, c_string_width, lisp_string_width)
+       (count_size_as_multibyte, string_escape_byte8):
+       * src/coding.c (coding_alloc_by_realloc, produce_chars):
+       * src/data.c (arith_driver):
+       * src/dispnew.c (realloc_glyph_pool, init_display):
+       * src/editfns.c (styled_format):
+       * src/fns.c (Ffillarray):
+       * src/ftfont.c (ftfont_shape_by_flt):
+       * src/gnutls.c (gnutls_hex_string):
+       * src/gtkutil.c (get_utf8_string):
+       * src/image.c (x_to_xcolors, x_detect_edges, png_load_body):
+       * src/keymap.c (Fkey_description):
+       * src/lisp.h (SAFE_ALLOCA_LISP):
+       * src/term.c (encode_terminal_code):
+       * src/tparam.c (tparam1):
+       * src/xselect.c (x_property_data_to_lisp):
+       * src/xsmfns.c (smc_save_yourself_CB):
+       * src/xterm.c (x_term_init):
+       When checking for integer overflow, prefer INT_MULTIPLY_WRAPV to
+       more-complicated code involving division and/or
+       INT_MULTIPLY_OVERFLOW, and similarly for INT_ADD_WRAPV and
+       subtraction and/or INT_ADD_OVERFLOW.
+       * src/casefiddle.c (casify_object): Simplify multibyte size check.
+       * src/character.c: Remove some obsolete ‘#ifdef emacs’s.
+       * src/data.c (arith_driver): Also check for division overflow,
+       as that’s now possible given that the accumulator can now contain
+       any Emacs integer.
+       * src/lisp.h (lisp_word_count): Remove; no longer used.
+
+2015-11-08  Dmitry Gutov  <address@hidden>
+
+       Make sure that the ignore file exists
+
+       * lisp/vc/vc.el (vc-default-ignore-completion-table):
+       Make sure that the ignore file exists.
+
+2015-11-08  Michael Sperber  <address@hidden>
+
+       * gnus-sum.el (gnus-summary-backend-map): Bind B-backspace to
+       `gnus-summary-delete-article` in a way that also works on XEmacs.
+
+2015-11-08  Simen Heggestøyl  <address@hidden>
+
+       Add support for retrieving paths to JSON elements
+
+       Add support for retrieving the path to a JSON element. This can for
+       instance be useful to retrieve paths in deeply nested JSON
+       structures.
+
+       * lisp/json.el (json-pre-element-read-function)
+       (json-post-element-read-function): New variables to hold pre- and post
+       read callback functions for `json-read-array' and `json-read-object'.
+       (json--path): New variable used internally by `json-path-to-position'.
+       (json--record-path, json--check-position): New functions used
+       internally by `json-path-to-position'.
+       (json-path-to-position): New function for retrieving the path to a
+       JSON element at a given position.
+       (json-read-object, json-read-array): Call
+       `json-pre-element-read-function' and `json-post-element-read-function'
+       when set.
+
+       * test/automated/json-tests.el (test-json-path-to-position-with-objects)
+       (test-json-path-to-position-with-arrays)
+       (test-json-path-to-position-no-match): New tests for
+       `json-path-to-position'.
+
+2015-11-08  Karl Fogel  <address@hidden>
+
+       * etc/NEWS: Mention new `bookmark-set-no-overwrite'.
+
+       This really should been part of my previous commit
+       (Sun Nov 8 14:16:43 2015 -0500, git commit 3812e17978).
+
+2015-11-08  Karl Fogel  <address@hidden>
+
+       Offer non-overwrite bookmark setter (Bug#15746)
+
+       * lisp/bookmark.el (bookmark-set-internal): New helper function to do
+       what `bookmark-set' used to do, but with more choices for overwrite
+       vs push, and with minor changes to the interactive prompt format.
+       (bookmark-set): Rewrite as wrapper around above.
+       If overwriting, inform the user of that in the prompt.
+       (bookmark-set-no-overwrite): New function, also done as wrapper.
+       Bind to "M" in `ctl-x-r-map' autoloads.
+       (bookmark-map): Similarly bind "M" here.
+
+2015-11-08  Paul Eggert  <address@hidden>
+
+       * src/unexelf.c (NEW_PROGRAM_H): Remove unused macro (Bug#20614).
+
+2015-11-08  Alan Modra  <address@hidden>
+
+       ELF unexec: Don't insert a new section
+
+       Reuse the .bss section instead, making it SHT_PROGBITS.  This way we
+       don't need to mess with symbol st_shndx, or section sh_link and
+       sh_info.
+
+       This does lead to eu-elflint complaints about symbols defined in .bss
+       with a needed version, because normally it is undefined symbols that
+       have needed versions;  Defined symbols have version definitions.
+       The exception is symbols defined by the linker in .dynbss for
+       variables copied from a shared library in order to avoid text
+       relocations, with copy relocs to copy their initial values from the
+       shared library.  These symbols are both defined and have needed
+       versions, and eu-elflink only expects to see them in SHT_NOBITS
+       sections.  Of course there is no real problem with having such symbols
+       in SHT_PROGBITS sections.  glibc ld.so handles them fine.
+
+       * src/unexelf.c: Delete outdated comments.
+       (PATCH_INDEX): Delete.
+       (find_section): Delete.
+       (unexec): Don't add a new section.  Instead reuse the last bss
+       section, extending it to cover dumped data.  Make bss sections
+       SHT_PROGBITS.  Remove all patching of sh_link, sh_info and
+       st_shndx.  Rename bss sections.
+
+2015-11-08  Alan Modra  <address@hidden>
+
+       ELF unexec: Drive from PT_LOAD header rather than sections
+
+       This rewrites bss handling in the ELF unexec code.  Finding bss
+       sections by name results in complicated code that
+       - does not account for all names of possible bss sections,
+       - assumes specific ordering of bss sections,
+       - can wrongly choose a SHT_NOBITS section not in the bss segment,
+       - incorrectly calculates bss size (no accounting for alignment gaps),
+       - assumes .data and .bss are in the same segment.
+
+       All of these problems and more are solved by finding the bss segment
+       in PT_LOAD headers, ie. the address range included in p_memsz but not
+       p_filesz of the last PT_LOAD header, then matching SHT_NOBITS sections
+       in that address range.
+
+       * src/unexelf.c: Delete old ppc comment.
+       (OLD_PROGRAM_H): Define.
+       (round_up): Delete.
+       (unexec): Don't search for bss style sections by name.  Instead,
+       use the last PT_LOAD header address range covered by p_memsz
+       but not p_filesz and match any SHT_NOBITS section in that
+       address range.  Simplify initialisation of section header vars.
+       Don't assume that section headers are above bss segment.  Move
+       copying of bss area out of section loop.  Align .data2 section
+       to 1, since it now covers the entire bss area.  For SHT_NOBITS
+       sections in the bss segment, leave sh_addr and sh_addralign
+       unchanged, but correct sh_offset.  Clear memory corresponding
+       to SHT_NOBITS .plt section.  Delete comment and hacks for
+       sections partly overlapping bss range now that the full range
+       is properly calculated.  Delete now dead .sbss code.
+       (Bug#20614)
+
+2015-11-08  Alan Modra  <address@hidden>
+
+       ELF unexec: R_*_NONE relocs
+
+       These should be ignored on all targets.
+
+       * src/unexelf.c (unexec): Ignore R_*_NONE relocs for any target,
+       not just Alpha.  Comment on reloc size assumption.
+
+2015-11-08  Alan Modra  <address@hidden>
+
+       ELF unexec: _OBJC_ symbols in bss sections
+
+       This code assumed that there was only one bss section.  Rather than
+       checking for a particular index, check the section type.  Also, handle
+       the possibility that the section was SHT_NOBITS originally and is
+       unchanged, in which case no clearing is needed (and sh_offset isn't
+       necessarily valid, which can lead to a wild memset).
+
+       * src/unexelf.c (unexec): Properly handle _OBJC_ symbols in
+       bss sections.
+
+2015-11-08  Alan Modra  <address@hidden>
+
+       ELF unexec: Symbol table patching
+
+       No st_shndx value larger than SHN_LORESERVE should be changed.
+       * src/unexelf.c (unexec): Don't adjust any st_shndx larger than
+       SHN_LORESERVE.  Error on SHN_XINDEX.
+
+2015-11-08  Alan Modra  <address@hidden>
+
+       ELF unexec: Merge Alpha and MIPS COFF debug handling
+
+       * src/unexelf.c (unexec): Merge Alpha and MIPS COFF debug handling.
+       Don't find .mdebug section index, find the section in the loop.
+       Allow for unlikely possibility that .mdebug is located at sh_offset
+       before bss segment, by calculating move from difference in
+       sh_offset rather than just assuming new_data2_size.  Simplify
+       cbLineOffset handling.
+
+2015-11-08  Alan Modra  <address@hidden>
+
+       ELF unexec: Tidy code
+
+       Separate out some of the more mechanical changes so following patches
+       are smaller.
+
+       * src/unexelf.c (unexec): Rearrange initialisation of program
+       header vars.  Use pointer vars in loops rather than indexing
+       section header array via macros.  Simplify _OBJC_ sym code
+       and reloc handling code.
+
+2015-11-08  Alan Modra  <address@hidden>
+
+       ELF unexec: Correct section header index
+
+       First a small fix.  The code incorrectly uses "NEW_SECTION_H (n)" when
+       it should have been using "NEW_SECTION_H (nn)" to find the name of the
+       section currently being processed.  Of course, before the bss
+       sections, n and nn have the same value, so this doesn't matter except
+       in the case of .sbss.  For .sbss this probably meant .bss (most likely
+       the next section) was copied from memory.  A later patch removes the
+       bogus .sbss handling anyway.
+
+       * src/unexelf.c (unexec): Use correct index to look up names.
+
+2015-11-08  Michael Albinus  <address@hidden>
+
+       Fix Bug#21841
+
+       * lisp/filenotify.el (file-notify--rm-descriptor):
+       Use `descriptor' instead of computing its value.
+       (file-notify--descriptor): Additional argument FILE.  Adapt all callees.
+       (file-notify-rm-watch): Use `descriptor' when calling file name handler.
+       (Bug#21841)
+
+2015-11-08  Dmitry Gutov  <address@hidden>
+
+       Remove dirs in vc project roots from the the vc project library roots
+
+       * lisp/progmodes/project.el (project-library-roots):
+       Remove directories inside the project roots from the result.
+       (http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg00536.html)
+
+2015-11-07  Dmitry Gutov  <address@hidden>
+
+       Move and rename xref-find-regexp to the project package
+
+       * lisp/progmodes/project.el (project-find-regexp)
+       (project--read-regexp)
+       (project--find-regexp-in): New functions.
+
+       * lisp/progmodes/xref.el (xref--find-xrefs): Extract from
+       xref--show-xrefs.  Use in existing callers in place of that
+       function.
+       (xref--show-xrefs): Only do the "show" part.
+       (xref-find-regexp): Rename, more or less, to
+       project-or-libraries-find-regexp.
+
+2015-11-06  Dmitry Gutov  <address@hidden>
+
+       Abolish temporary buffer management for xref
+
+       * lisp/progmodes/xref.el (xref--temporary-buffers)
+       (xref--current)
+       (xref--inhibit-mark-current)
+       (xref--mark-selected): Remove.  Remove all references.
+       (xref--show-xrefs): Do not construct the
+       list of the temporary buffers, nor pass it along.
+
+2015-11-06  Dmitry Gutov  <address@hidden>
+
+       Rename "search path" to "library roots"
+
+       * lisp/emacs-lisp/cl-seq.el (cl-set-difference): Retain the order
+       of the elements from CL-LIST1.
+
+       * test/automated/cl-lib-tests.el (cl-lib-test-set-functions):
+       Update WRT to the above change.
+
+       * lisp/progmodes/project.el (project-search-path-function): Rename
+       to project-library-roots-function, update the documentation and
+       references.
+       (project-search-path): Likewise, to project-library-roots.
+       (project-roots): Clarify documentation.
+       (project-vc-search-path): Likewise, to project-vc-library-roots.
+       (project-library-roots): In addition to the renames, thread the
+       results through file-name-as-directory.
+       (project-prune-directories): Accept a variable number of
+       arguments.  Rename to project-combine-directories.
+       (project-subtract-directories): New function.
+
+       * lisp/progmodes/elisp-mode.el (elisp--xref-find-references):
+       Append project-roots and project-library-roots together.
+
+       * lisp/progmodes/etags.el (etags--xref-find-references): Ditto.
+
 2015-11-08  Paul Eggert  <address@hidden>
 
        Prefer xpalloc to doubling buffers by hand
@@ -1764,7 +3694,7 @@
 
 2015-10-23  Anders Lindgren  <address@hidden>
 
-       NextSten maximization and NSTRACE rewrite
+       NextStep maximization and NSTRACE rewrite
 
        Full-height, full-width, and maximized windows now cover the
        entire screen (except the menu bar), including the part where the
@@ -17967,7 +19897,7 @@
 
 This file records repository revisions from
 commit 9d56a21e6a696ad19ac65c4b405aeca44785884a (exclusive) to
-commit 8a8613bcf4227dfe46a694b761e9575bdf6ca2ce (inclusive).
+commit 9a2363ec04c24a6959902da9b8eff2f1559ab3e0 (inclusive).
 See ChangeLog.1 for earlier changes.
 
 ;; Local Variables:
diff --git a/Makefile.in b/Makefile.in
index 1245f76..06e5b06 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -921,12 +921,21 @@ extraclean: $(extraclean_dirs:=_extraclean)
 TAGS tags: lib lib-src src
        $(MAKE) -C src tags
 
+
+check-maybe: all
+       @if test ! -d test; then \
+         echo "You do not seem to have the test/ directory."; \
+         echo "Maybe you are using a release tarfile, rather than a repository 
checkout."; \
+       else \
+         $(MAKE) -C test check-maybe; \
+       fi
+
 check: all
-       @if test ! -d test/automated; then \
+       @if test ! -d test; then \
          echo "You do not seem to have the test/ directory."; \
          echo "Maybe you are using a release tarfile, rather than a repository 
checkout."; \
        else \
-         $(MAKE) -C test/automated check; \
+         $(MAKE) -C test check; \
        fi
 
 dist:
@@ -943,7 +952,7 @@ $(DOCS):
        $(MAKE) -C doc/$(subst -, ,$@)
 
 .PHONY: $(DOCS) docs pdf ps
-.PHONY: info dvi dist check html info-real info-dir check-info
+.PHONY: info dvi dist check check-maybe html info-real info-dir check-info
 
 ## TODO add etc/refcards.
 docs: $(DOCS)
diff --git a/README b/README
index be99852..82a5a8f 100644
--- a/README
+++ b/README
@@ -2,7 +2,7 @@ Copyright (C) 2001-2015 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
-This directory tree holds version 25.0.50 of GNU Emacs, the extensible,
+This directory tree holds version 25.1.50 of GNU Emacs, the extensible,
 customizable, self-documenting real-time display editor.
 
 The file INSTALL in this directory says how to build and install GNU
@@ -15,6 +15,9 @@ user-visible changes in recent versions of Emacs.
 The file etc/PROBLEMS contains information on many common problems that
 occur in building, installing and running Emacs.
 
+The file CONTRIBUTE contains information on contributing to Emacs as a
+developer.
+
 You may encounter bugs in this release.  If you do, please report
 them; your bug reports are valuable contributions to the FSF, since
 they allow us to notice and fix problems on machines we don't have, or
diff --git a/admin/README b/admin/README
index 2286e35..b7621ff 100644
--- a/admin/README
+++ b/admin/README
@@ -12,9 +12,9 @@ what you do when using them.
 
 * Instructions and scripts used to prepare an Emacs release.
 
-** FOR-RELEASE
+** release-process
 
-Living list of activities that must be completed before the next release.
+The release process used by GNU Emacs.
 
 ** make-tarball.txt
 
diff --git a/admin/authors.el b/admin/authors.el
index 3d7850a..9903218 100644
--- a/admin/authors.el
+++ b/admin/authors.el
@@ -267,7 +267,7 @@ Changes to files matching one of the regexps in this list 
are not listed.")
   '("external-lisp"
     "lock" "share-lib" "local-lisp"
     "noleim-Makefile.in"
-    "NEWS" "ORDERS" "PROBLEMS" "FAQ" "AUTHORS" "FOR-RELEASE" "TODO" "todo"
+    "NEWS" "ORDERS" "PROBLEMS" "FAQ" "AUTHORS" "release-process" "TODO" "todo"
     "MACHINES" "SERVICE"
     "README.unicode" "README.multi-tty" "TUTORIAL.translators"
     "NEWS.unicode" "COPYING.DJ" "Makefile.old" "Makefile.am"
diff --git a/admin/gitmerge.el b/admin/gitmerge.el
index c8cf2dc..1e92c8c 100644
--- a/admin/gitmerge.el
+++ b/admin/gitmerge.el
@@ -65,7 +65,7 @@ Auto-commit"
   '((t (:strike-through t)))
   "Face for skipped commits.")
 
-(defconst gitmerge-default-branch "origin/emacs-24"
+(defconst gitmerge-default-branch "origin/emacs-25"
   "Default for branch that should be merged.")
 
 (defconst gitmerge-buffer "*gitmerge*"
@@ -183,8 +183,8 @@ if and why this commit should be skipped."
     ;; Go through the log and remember all commits that match
     ;; `gitmerge-skip-regexp' or are marked by --cherry-mark.
     (with-temp-buffer
-      (call-process "git" nil t nil "log" "--cherry-mark" from
-                   (concat "^" (car (vc-git-branches))))
+      (call-process "git" nil t nil "log" "--cherry-mark" "--left-only"
+                   (concat from "..." (car (vc-git-branches))))
       (goto-char (point-max))
       (while (re-search-backward "^commit \\(.+\\) \\([0-9a-f]+\\).*" nil t)
        (let ((cherrymark (match-string 1))
@@ -206,9 +206,9 @@ if and why this commit should be skipped."
   "Create the buffer for choosing commits."
   (with-current-buffer (get-buffer-create gitmerge-buffer)
     (erase-buffer)
-    (call-process "git" nil t nil "log"
+    (call-process "git" nil t nil "log" "--left-only"
                  "--pretty=format:%h %<(20,trunc) %an: %<(100,trunc) %s"
-                 from (concat "^" (car (vc-git-branches))))
+                 (concat from "..." (car (vc-git-branches))))
     (goto-char (point-min))
     (while (looking-at "^\\([a-f0-9]+\\)")
       (let ((skipreason (gitmerge-skip-commit-p (match-string 1) commits)))
diff --git a/admin/notes/bugtracker b/admin/notes/bugtracker
index fb65bbe..3d6df03 100644
--- a/admin/notes/bugtracker
+++ b/admin/notes/bugtracker
@@ -140,8 +140,7 @@ you can add an element to gnus-posting-styles to do this 
automatically, eg:
 
 ** To record a bug in the tracker without sending mail to the bug list.
 This can be useful to make a note of something discussed on
-emacs-devel that needs fixing.  In other words, this can be the
-equivalent of adding something to FOR-RELEASE.
+emacs-devel that needs fixing.
 
 To: address@hidden
 [headers end]
diff --git a/admin/notes/versioning b/admin/notes/versioning
index e422b22..ef11335 100644
--- a/admin/notes/versioning
+++ b/admin/notes/versioning
@@ -9,16 +9,20 @@ Emacs version numbers have the form
 "build" increments each time Emacs is built in the same location
 (without cleaning) and isn't really part of the version.
 
-bugfix releases increase "minor" by 1.
-non-bugfix releases increase "major" by 1, and reset "minor" to 1.
+Bugfix releases increase "minor" by 1.
+Non-bugfix releases increase "major" by 1, and reset "minor" to 1.
 (The division between bugfix and non-bugfix has not always been clear
 historically.)
 
 Unreleased (development) versions have an extra "devel" component.
 This is a fairly meaningless number that may be unchanged for a long time.
 It is normally 50.
-When the release process starts, it changes to 90, 91, ...
-When the actual release is made, this component is removed.
+
+After we cut the release branch, we’ll make pretest and release
+candidate (RC) releases.  For pretest releases, the "devel" component
+changes to 90, 91, ...  When the first RC release is made, this
+component is removed.  Normally, there is one RC release, unless an
+unexpected last-minute problem occurs.
 
 The development version for a new major release has "minor" = 0.
 The development version for a new minor release has "minor" = that of
diff --git a/admin/FOR-RELEASE b/admin/release-process
similarity index 66%
rename from admin/FOR-RELEASE
rename to admin/release-process
index 6ecec89..1cfcf54 100644
--- a/admin/FOR-RELEASE
+++ b/admin/release-process
@@ -1,7 +1,52 @@
-Tasks needed before the next release.
+This document describes the release process used by GNU Emacs.
+
+* RELEASE CYCLE
+
+Each release cycle will be split into two periods.
+
+** Phase one: development
+
+The first phase of the release schedule is the "heads-down" working
+period for new features, on the `master' branch and several feature
+branches.
+
+** Phase two: bugfixes
+
+Shortly before this phase, Emacs developers will be devoted to
+figuring out what features to include in the next release and what
+features to defer to a later release.
+
+At the beginning of this phase, a release branch called "emacs-NN"
+("NN" represents the major version number of the new Emacs release)
+will be cut from `master'.
+
+This phase is spent fixing bugs and eliminating undocumented new
+features on the "emacs-NN" branch.
+
+In parallel to this phase, `master' can receive new features, to be
+released in the next release cycle.  From time to time, the master
+branches merges bugfix commits from the "emacs-NN" branch.
+
+* RELEASE-CRITICAL BUGS
+
+Emacs uses the "blocking bug(s)" feature of Debbugs for bugs need to
+be addressed in the next release.
+
+Currently, bug#19759 is the tracking bug for release of 25.1 and
+bug#21966 is the tracking bug for release of 25.2.  Say bug#123 needs
+to be fixed for Emacs 25.1.  Send a message to address@hidden
+that says:
+
+   block 19759 by 123
+
+Change "block" to "unblock" to unblock the bug.
 
 * TO BE DONE SHORTLY BEFORE RELEASE
 
+** Make sure the Copyright date reflects the current year in the source
+files.  See `admin/notes/years' for information about maintaining
+copyright years for GNU Emacs.
+
 ** Make sure the necessary sources and scripts for any generated files
 are included in the source tarfile.  (They don't need to be installed,
 so eg admin/ is fine.)
@@ -88,13 +133,13 @@ csplain -output-format=pdf cs-refcard
 Emacs 22 translators:
 
 LANG   Translator            Status
-cs     Pavel Janík           
-de     Sven Joachim          
-fr     Eric Jacoboni         
-pl     Włodek Bzyl           
-pt-br  Rodrigo Real          
-ru     Alex Ott              
-sk     Miroslav Vaško        
+cs     Pavel Janík
+de     Sven Joachim
+fr     Eric Jacoboni
+pl     Włodek Bzyl
+pt-br  Rodrigo Real
+ru     Alex Ott
+sk     Miroslav Vaško
 
 ** For a major release, add a "New in Emacs XX" section to faq.texi.
 
@@ -148,132 +193,139 @@ SECTION                  READERS
 TUTORIAL             cyd
 TUTORIAL.bg          ogi
 TUTORIAL.cn          xfq
-TUTORIAL.cs          
+TUTORIAL.cs
 TUTORIAL.de          wl
 TUTORIAL.eo
-TUTORIAL.es          
-TUTORIAL.fr          
+TUTORIAL.es
+TUTORIAL.fr
 TUTORIAL.he          eliz
-TUTORIAL.it          
-TUTORIAL.ja          
+TUTORIAL.it
+TUTORIAL.ja
 TUTORIAL.ko
 TUTORIAL.nl         Pieter Schoenmakers
-TUTORIAL.pl          
-TUTORIAL.pt_BR       
+TUTORIAL.pl
+TUTORIAL.pt_BR
 TUTORIAL.ro
 TUTORIAL.ru          Alex Ott
-TUTORIAL.sk          
+TUTORIAL.sk
 TUTORIAL.sl          Primoz PETERLIN
 TUTORIAL.sv          Mats Lidell
-TUTORIAL.th          
+TUTORIAL.th
 TUTORIAL.zh
 
 ** Check the manual.
 
-abbrevs.texi      
-ack.texi          
-anti.texi         
-arevert-xtra.texi 
-basic.texi        
-buffers.texi      
-building.texi     
-calendar.texi     
-cal-xtra.texi     
-cmdargs.texi      
-commands.texi     
-custom.texi       
-dired.texi        
-dired-xtra.texi   
-display.texi      
-emacs.texi        
-emacs-xtra.texi   
-emerge-xtra.texi  
-entering.texi     
-files.texi        
-fixit.texi        
-fortran-xtra.texi 
-frames.texi       
-glossary.texi     
-help.texi         
-indent.texi       
-killing.texi      
-kmacro.texi       
-macos.texi        
-maintaining.texi  
-mark.texi         
-mini.texi         
-misc.texi         
-modes.texi        
-msdos.texi        
-msdos-xtra.texi   
-mule.texi         
-m-x.texi          
-package.texi      
-picture-xtra.texi 
-programs.texi     
-regs.texi         
-rmail.texi        
-screen.texi       
-search.texi       
-sending.texi      
-text.texi         
-trouble.texi      
-vc-xtra.texi      
-vc1-xtra.texi     
-windows.texi      
-xresources.texi   
+abbrevs.texi
+ack.texi
+anti.texi
+arevert-xtra.texi
+basic.texi
+buffers.texi
+building.texi
+calendar.texi
+cal-xtra.texi
+cmdargs.texi
+commands.texi
+custom.texi
+dired.texi
+dired-xtra.texi
+display.texi
+emacs.texi
+emacs-xtra.texi
+emerge-xtra.texi
+entering.texi
+files.texi
+fixit.texi
+fortran-xtra.texi
+frames.texi
+glossary.texi
+help.texi
+indent.texi
+killing.texi
+kmacro.texi
+macos.texi
+maintaining.texi
+mark.texi
+mini.texi
+misc.texi
+modes.texi
+msdos.texi
+msdos-xtra.texi
+mule.texi
+m-x.texi
+package.texi
+picture-xtra.texi
+programs.texi
+regs.texi
+rmail.texi
+screen.texi
+search.texi
+sending.texi
+text.texi
+trouble.texi
+vc-xtra.texi
+vc1-xtra.texi
+windows.texi
+xresources.texi
 
 ** Check the Lisp manual.
 
-abbrevs.texi      
-anti.texi         
-back.texi         
-backups.texi      
-buffers.texi      
-commands.texi     
-compile.texi      
-control.texi      
-customize.texi    
-debugging.texi    
-display.texi      
-edebug.texi       
+abbrevs.texi
+anti.texi
+back.texi
+backups.texi
+buffers.texi
+commands.texi
+compile.texi
+control.texi
+customize.texi
+debugging.texi
+display.texi
+edebug.texi
 elisp.texi
-errors.texi       
-eval.texi         
-files.texi        
-frames.texi       
-functions.texi    
-hash.texi         
-help.texi         
-hooks.texi        
+errors.texi
+eval.texi
+files.texi
+frames.texi
+functions.texi
+hash.texi
+help.texi
+hooks.texi
 index.texi
-internals.texi    
-intro.texi        
-keymaps.texi      
-lists.texi        
-loading.texi      
-macros.texi       
-maps.texi         
-markers.texi      
-minibuf.texi      
-modes.texi        
-nonascii.texi     
+internals.texi
+intro.texi
+keymaps.texi
+lists.texi
+loading.texi
+macros.texi
+maps.texi
+markers.texi
+minibuf.texi
+modes.texi
+nonascii.texi
 numbers.texi      Paul Eggert (24.4)
-objects.texi      
-os.texi           
-package.texi      
-positions.texi    
-processes.texi    
-searching.texi    
-sequences.texi    
-streams.texi      
-strings.texi      
-symbols.texi      
-syntax.texi       
-text.texi         
-tips.texi         
-variables.texi    
-windows.texi      
+objects.texi
+os.texi
+package.texi
+positions.texi
+processes.texi
+searching.texi
+sequences.texi
+streams.texi
+strings.texi
+symbols.texi
+syntax.texi
+text.texi
+tips.texi
+variables.texi
+windows.texi
+
+* OTHER INFORMATION
+
+For Emacs's versioning scheme, see `admin/notes/versioning'.
+
+For instructions to create pretest or release tarballs, announcements,
+etc., see `admin/make-tarball.txt'.
 
 
 Local variables:
diff --git a/configure.ac b/configure.ac
index 216bd14..71fa688 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@ dnl  along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.
 
 AC_PREREQ(2.65)
 dnl Note this is parsed by (at least) make-dist and lisp/cedet/ede/emacs.el.
-AC_INIT(GNU Emacs, 25.0.50, address@hidden)
+AC_INIT(GNU Emacs, 25.1.50, address@hidden)
 
 dnl Set emacs_config_options to the options of 'configure', quoted for the 
shell,
 dnl and then quoted again for a C string.  Separate options with spaces.
@@ -355,17 +355,18 @@ OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for 
SSL/TLS support])
 OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support])
 
 AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
- [use a file notification library (LIB one of: yes, gfile, inotify, w32, 
no)])],
+ [use a file notification library (LIB one of: yes, inotify, kqueue, gfile, 
w32, no)])],
  [ case "${withval}" in
     y | ye | yes )     val=yes ;;
     n | no )           val=no  ;;
-    g | gf | gfi | gfil | gfile )      val=gfile ;;
     i | in | ino | inot | inoti | inotif | inotify )   val=inotify ;;
+    k | kq | kqu | kque | kqueu | kqueue )     val=kqueue ;;
+    g | gf | gfi | gfil | gfile )      val=gfile ;;
     w | w3 | w32 )     val=w32 ;;
     * ) AC_MSG_ERROR(['--with-file-notification=$withval' is invalid;
-this option's value should be 'yes', 'no', 'gfile', 'inotify' or 'w32'.
+this option's value should be 'yes', 'no', 'inotify', 'kqeue', 'gfile' or 
'w32'.
 'yes' is a synonym for 'w32' on MS-Windows, for 'no' on Nextstep,
-otherwise for the first of 'inotify' or 'gfile' that is usable.])
+otherwise for the first of 'inotify', 'kqueue' or 'gfile' that is usable.])
     ;;
    esac
    with_file_notification=$val
@@ -2729,12 +2730,6 @@ AC_SUBST(LIBGNUTLS_CFLAGS)
 NOTIFY_OBJ=
 NOTIFY_SUMMARY=no
 
-dnl FIXME?  Don't auto-detect on NS, but do allow someone to specify
-dnl a particular library.  This doesn't make much sense?
-if test "${HAVE_NS}" = yes && test ${with_file_notification} = yes; then
-  with_file_notification=no
-fi
-
 dnl MS Windows native file monitor is available for mingw32 only.
 case $with_file_notification,$opsys in
   w32,cygwin)
@@ -2765,16 +2760,41 @@ case $with_file_notification,$NOTIFY_OBJ in
     fi ;;
 esac
 
+dnl kqueue is available on BSD-like systems.
+case $with_file_notification,$NOTIFY_OBJ in
+  kqueue,* | yes,)
+    EMACS_CHECK_MODULES([KQUEUE], [libkqueue])
+    if test "$HAVE_KQUEUE" = "yes"; then
+       AC_DEFINE(HAVE_KQUEUE, 1, [Define to 1 to use kqueue.])
+       CPPFLAGS="$CPPFLAGS -I/usr/include/kqueue"
+       NOTIFY_CFLAGS=$KQUEUE_CFLAGS
+       NOTIFY_LIBS=$KQUEUE_LIBS
+       NOTIFY_OBJ=kqueue.o
+       NOTIFY_SUMMARY="yes -lkqueue"
+    else
+       AC_SEARCH_LIBS(kqueue, [])
+       if test "$ac_cv_search_kqueue" != no; then
+         AC_DEFINE(HAVE_KQUEUE, 1, [Define to 1 to use kqueue.])
+        NOTIFY_OBJ=kqueue.o
+        NOTIFY_SUMMARY="yes (kqueue)"
+       fi
+    fi ;;
+esac
+
 dnl g_file_monitor exists since glib 2.18.  G_FILE_MONITOR_EVENT_MOVED
 dnl has been added in glib 2.24.  It has been tested under
 dnl GNU/Linux only.
 case $with_file_notification,$NOTIFY_OBJ in
   gfile,* | yes,)
-    EMACS_CHECK_MODULES([GFILENOTIFY], [gio-2.0 >= 2.24])
-    if test "$HAVE_GFILENOTIFY" = "yes"; then
-       AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
-       NOTIFY_OBJ=gfilenotify.o
-       NOTIFY_SUMMARY="yes -lgio (gfile)"
+    if test "${HAVE_NS}" != yes; then
+       EMACS_CHECK_MODULES([GFILENOTIFY], [gio-2.0 >= 2.24])
+       if test "$HAVE_GFILENOTIFY" = "yes"; then
+         AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
+         NOTIFY_CFLAGS=$GFILENOTIFY_CFLAGS
+         NOTIFY_LIBS=$GFILENOTIFY_LIBS
+         NOTIFY_OBJ=gfilenotify.o
+         NOTIFY_SUMMARY="yes -lgio (gfile)"
+       fi
     fi ;;
 esac
 
@@ -2786,9 +2806,9 @@ esac
 if test -n "$NOTIFY_OBJ"; then
    AC_DEFINE(USE_FILE_NOTIFY, 1, [Define to 1 if using file notifications.])
 fi
+AC_SUBST(NOTIFY_CFLAGS)
+AC_SUBST(NOTIFY_LIBS)
 AC_SUBST(NOTIFY_OBJ)
-AC_SUBST(GFILENOTIFY_CFLAGS)
-AC_SUBST(GFILENOTIFY_LIBS)
 
 dnl Do not put whitespace before the #include statements below.
 dnl Older compilers (eg sunos4 cc) choke on it.
@@ -4105,8 +4125,8 @@ OLDCFLAGS="$CFLAGS"
 OLDLIBS="$LIBS"
 CFLAGS="$CFLAGS $GTK_CFLAGS $RSVG_CFLAGS $DBUS_CFLAGS $SETTINGS_CFLAGS"
 LIBS="$LIBS $GTK_LIBS $RSVG_LIBS $DBUS_LIBS $SETTINGS_LIBS"
-CFLAGS="$CFLAGS $GFILENOTIFY_CFLAGS $CAIRO_CFLAGS"
-LIBS="$LIBS $GFILENOTIFY_LIBS $CAIRO_LIBS"
+CFLAGS="$CFLAGS $NOTIFY_CFLAGS $CAIRO_CFLAGS"
+LIBS="$LIBS $NOTIFY_LIBS $CAIRO_LIBS"
 AC_MSG_CHECKING([whether GLib is linked in])
 AC_LINK_IFELSE([AC_LANG_PROGRAM(
        [[#include <glib.h>
@@ -4186,7 +4206,7 @@ else
   SEPCHAR=':'
 fi
 AC_DEFINE_UNQUOTED(SEPCHAR, ['$SEPCHAR'], [Character that separates PATH 
elements.])
-dnl This is for MinGW, and is used in test/automated/Makefile.in.
+dnl This is for MinGW, and is used in test/Makefile.in.
 dnl The MSYS Bash has heuristics for replacing ':' with ';' when it
 dnl decides that a command-line argument to be passed to a MinGW program
 dnl is a PATH-style list of directories.  But that heuristics plays it
@@ -5343,13 +5363,13 @@ AC_CONFIG_FILES([Makefile lib/Makefile lib-src/Makefile 
oldXMenu/Makefile \
        leim/Makefile nextstep/Makefile nt/Makefile])
 
 dnl test/ is not present in release tarfiles.
-opt_makefile=test/automated/Makefile
+opt_makefile=test/Makefile
 
 if test -f "$srcdir/$opt_makefile.in"; then
   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
   dnl Again, it's best not to use a variable.  Though you can add
   dnl ", [], [opt_makefile='$opt_makefile']" and it should work.
-  AC_CONFIG_FILES([test/automated/Makefile])
+  AC_CONFIG_FILES([test/Makefile])
 fi
 
 
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index f3c4e29..17a0b47 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -2640,9 +2640,9 @@ This function removes the tray notification given by its 
unique
 
 Several operating systems support watching of filesystems for changes
 of files.  If configured properly, Emacs links a respective library
-like @file{gfilenotify}, @file{inotify}, or @file{w32notify}
-statically.  These libraries enable watching of filesystems on the
-local machine.
+like @file{inotify}, @file{kqueue}, @file{gfilenotify}, or
address@hidden statically.  These libraries enable watching of
+filesystems on the local machine.
 
 It is also possible to watch filesystems on remote machines,
 @pxref{Remote Files,, Remote Files, emacs, The GNU Emacs Manual}
@@ -2713,7 +2713,8 @@ watching @var{file} has been stopped
 Note that the @file{w32notify} library does not report
 @code{attribute-changed} events.  When some file's attribute, like
 permissions or modification time, has changed, this library reports a
address@hidden event.
address@hidden event.  Likewise, the @file{kqueue} library does not
+report reliably file attribute changes when watching a directory.
 
 The @code{stopped} event reports, that watching the file has been
 stopped.  This could be because @code{file-notify-rm-watch} was called
@@ -2752,7 +2753,7 @@ being reported.  For example:
 @group
 (write-region "bla" nil "/tmp/foo")
      @result{} Event (35025468 created "/tmp/.#foo")
-        Event (35025468 changed "/tmp/foo") [2 times]
+        Event (35025468 changed "/tmp/foo")
         Event (35025468 deleted "/tmp/.#foo")
 @end group
 
@@ -2798,14 +2799,14 @@ also makes it invalid.
 @example
 @group
 (make-directory "/tmp/foo")
-     @result{} nil
+     @result{} Event (35025468 created "/tmp/foo")
 @end group
 
 @group
 (setq desc
       (file-notify-add-watch
         "/tmp/foo" '(change) 'my-notify-callback))
-     @result{} 35025468
+     @result{} 11359632
 @end group
 
 @group
@@ -2815,32 +2816,34 @@ also makes it invalid.
 
 @group
 (write-region "bla" nil "/tmp/foo/bla")
-     @result{} Event (35025468 created "/tmp/foo/.#bla")
-        Event (35025468 created "/tmp/foo/bla")
-        Event (35025468 changed "/tmp/foo/bla")
-        Event (35025468 changed "/tmp/foo/.#bla")
+     @result{} Event (11359632 created "/tmp/foo/.#bla")
+        Event (11359632 created "/tmp/foo/bla")
+        Event (11359632 changed "/tmp/foo/bla")
+        Event (11359632 deleted "/tmp/foo/.#bla")
 @end group
 
 @group
 ;; Deleting a file in the directory doesn't invalidate the watch.
 (delete-file "/tmp/foo/bla")
-     @result{} Event (35025468 deleted "/tmp/foo/bla")
+     @result{} Event (11359632 deleted "/tmp/foo/bla")
 @end group
 
 @group
 (write-region "bla" nil "/tmp/foo/bla")
-     @result{} Event (35025468 created "/tmp/foo/.#bla")
-        Event (35025468 created "/tmp/foo/bla")
-        Event (35025468 changed "/tmp/foo/bla")
-        Event (35025468 changed "/tmp/foo/.#bla")
+     @result{} Event (11359632 created "/tmp/foo/.#bla")
+        Event (11359632 created "/tmp/foo/bla")
+        Event (11359632 changed "/tmp/foo/bla")
+        Event (11359632 deleted "/tmp/foo/.#bla")
 @end group
 
 @group
 ;; Deleting the directory invalidates the watch.
+;; Events arrive for different watch descriptors.
 (delete-directory "/tmp/foo" 'recursive)
-     @result{} Event (35025468 deleted "/tmp/foo/bla")
-        Event (35025468 deleted "/tmp/foo")
-        Event (35025468 stopped "/tmp/foo")
+     @result{} Event (35025468 deleted "/tmp/foo")
+        Event (11359632 deleted "/tmp/foo/bla")
+        Event (11359632 deleted "/tmp/foo")
+        Event (11359632 stopped "/tmp/foo")
 @end group
 
 @group
diff --git a/etc/NEWS b/etc/NEWS
index 46910b0..1ef496c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -23,6 +23,19 @@ When you add a new item, use the appropriate mark if you are 
sure it applies,
 otherwise leave it unmarked.
 
 
+* Installation Changes in Emacs 25.2
+
+** 'configure' detects the kqueue file notification library on *BSD
+and Mac OS X machines.
+
+
+* Changes in Specialized Modes and Packages in Emacs 25.2
+
+** File Notifications
+
+*** The kqueue library is integrated for *BSD and Mac OS X machines.
+
+
 * Installation Changes in Emacs 25.1
 
 +++
diff --git a/etc/TODO b/etc/TODO
index 946a4fe..7045731 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -13,9 +13,12 @@ the latest version of this file in the Emacs source code 
repository.
 
 Since Emacs is an FSF-copyrighted package, please be prepared to sign
 legal papers to transfer the copyright on your work to the FSF.
-For more details on this, see the section "Copyright Assignment"
-in etc/CONTRIBUTE.  That file also contains some more practical
-details about getting involved.
+Copyright assignment is a simple process.  Residents of some countries
+can do it entirely electronically.  We can help you get started, and
+answer any questions you may have (or point you to the people with the
+answers), at the address@hidden mailing list.
+
+For more information about getting involved, see the CONTRIBUTE file.
 
 As well as the issues listed here, there are bug reports at
 <http://debbugs.gnu.org>.  Bugs tagged "easy" ought to be suitable for
diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h
index f0e9778..0e579de 100644
--- a/lib/xalloc-oversized.h
+++ b/lib/xalloc-oversized.h
@@ -16,9 +16,13 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef XALLOC_OVERSIZED_H_
-# define XALLOC_OVERSIZED_H_
+#define XALLOC_OVERSIZED_H_
 
-# include <stddef.h>
+#include <stddef.h>
+
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
 
 /* Return 1 if an array of N objects, each of size S, cannot exist due
    to size arithmetic overflow.  S must be positive and N must be
@@ -32,7 +36,12 @@
    sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
    exactly-SIZE_MAX allocations on such hosts; this avoids a test and
    branch when S is known to be 1.  */
+#if 5 <= __GNUC__ || __has_builtin (__builtin_mul_overflow)
+# define xalloc_oversized(n, s) \
+    ({ size_t __xalloc_size; __builtin_mul_overflow (n, s, &__xalloc_size); })
+#else
 # define xalloc_oversized(n, s) \
     ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
+#endif
 
 #endif /* !XALLOC_OVERSIZED_H_ */
diff --git a/lisp/Makefile.in b/lisp/Makefile.in
index ed1246b..2ad16ed 100644
--- a/lisp/Makefile.in
+++ b/lisp/Makefile.in
@@ -89,15 +89,8 @@ AUTOGENEL = loaddefs.el \
        cedet/srecode/loaddefs.el \
        org/org-loaddefs.el
 
-# Value of max-lisp-eval-depth when compiling initially.
-# During bootstrapping the byte-compiler is run interpreted when compiling
-# itself, and uses more stack than usual.
-#
-BIG_STACK_DEPTH = 2200
-BIG_STACK_OPTS = --eval "(setq max-lisp-eval-depth $(BIG_STACK_DEPTH))"
-
 # Set load-prefer-newer for the benefit of the non-bootstrappers.
-BYTE_COMPILE_FLAGS = $(BIG_STACK_OPTS) \
+BYTE_COMPILE_FLAGS = \
   --eval '(setq load-prefer-newer t)' $(BYTE_COMPILE_EXTRA_FLAGS)
 
 # Files to compile before others during a bootstrap.  This is done to
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 43a905b..c95e1ea 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -33,6 +33,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
+(require 'obarray)
 
 (defgroup abbrev-mode nil
   "Word abbreviations mode."
@@ -87,7 +88,7 @@ be replaced by its expansion."
   "Make a new abbrev-table with the same abbrevs as TABLE.
 Does not copy property lists."
   (let ((new-table (make-abbrev-table)))
-    (mapatoms
+    (obarray-map
      (lambda (symbol)
        (define-abbrev new-table
         (symbol-name symbol)
@@ -406,12 +407,12 @@ A prefix argument means don't query; expand all abbrevs."
 
 (defun abbrev-table-get (table prop)
   "Get the PROP property of abbrev table TABLE."
-  (let ((sym (intern-soft "" table)))
+  (let ((sym (obarray-get table "")))
     (if sym (get sym prop))))
 
 (defun abbrev-table-put (table prop val)
   "Set the PROP property of abbrev table TABLE to VAL."
-  (let ((sym (intern "" table)))
+  (let ((sym (obarray-put table "")))
     (set sym nil)           ; Make sure it won't be confused for an abbrev.
     (put sym prop val)))
 
@@ -435,8 +436,7 @@ See `define-abbrev' for the effect of some special 
properties.
 (defun make-abbrev-table (&optional props)
   "Create a new, empty abbrev table object.
 PROPS is a list of properties."
-  ;; The value 59 is an arbitrary prime number.
-  (let ((table (make-vector 59 0)))
+  (let ((table (obarray-make)))
     ;; Each abbrev-table has a `modiff' counter which can be used to detect
     ;; when an abbreviation was added.  An example of use would be to
     ;; construct :regexp dynamically as the union of all abbrev names, so
@@ -451,7 +451,7 @@ PROPS is a list of properties."
 
 (defun abbrev-table-p (object)
   "Return non-nil if OBJECT is an abbrev table."
-  (and (vectorp object)
+  (and (obarrayp object)
        (numberp (abbrev-table-get object :abbrev-table-modiff))))
 
 (defun abbrev-table-empty-p (object &optional ignore-system)
@@ -460,12 +460,12 @@ If IGNORE-SYSTEM is non-nil, system definitions are 
ignored."
   (unless (abbrev-table-p object)
     (error "Non abbrev table object"))
   (not (catch 'some
-        (mapatoms (lambda (abbrev)
-                    (unless (or (zerop (length (symbol-name abbrev)))
-                                (and ignore-system
-                                     (abbrev-get abbrev :system)))
-                      (throw 'some t)))
-                  object))))
+        (obarray-map (lambda (abbrev)
+                        (unless (or (zerop (length (symbol-name abbrev)))
+                                    (and ignore-system
+                                         (abbrev-get abbrev :system)))
+                          (throw 'some t)))
+                      object))))
 
 (defvar global-abbrev-table (make-abbrev-table)
   "The abbrev table whose abbrevs affect all buffers.
@@ -529,12 +529,12 @@ the current abbrev table before abbrev lookup happens."
 (defun clear-abbrev-table (table)
   "Undefine all abbrevs in abbrev table TABLE, leaving it empty."
   (setq abbrevs-changed t)
-  (let* ((sym (intern-soft "" table)))
+  (let* ((sym (obarray-get table "")))
     (dotimes (i (length table))
       (aset table i 0))
     ;; Preserve the table's properties.
     (cl-assert sym)
-    (let ((newsym (intern "" table)))
+    (let ((newsym (obarray-put table "")))
       (set newsym nil)      ; Make sure it won't be confused for an abbrev.
       (setplist newsym (symbol-plist sym)))
     (abbrev-table-put table :abbrev-table-modiff
@@ -583,7 +583,7 @@ An obsolete but still supported calling form is:
   (setq props (plist-put props :abbrev-table-modiff
                          (abbrev-table-get table :abbrev-table-modiff)))
   (let ((system-flag (plist-get props :system))
-        (sym (intern name table)))
+        (sym (obarray-put table name)))
     ;; Don't override a prior user-defined abbrev with a system abbrev,
     ;; unless system-flag is `force'.
     (unless (and (not (memq system-flag '(nil force)))
@@ -673,10 +673,10 @@ The value is nil if that abbrev is not defined."
          ;; abbrevs do, we have to be careful.
          (sym
           ;; First try without case-folding.
-          (or (intern-soft abbrev table)
+          (or (obarray-get table abbrev)
               (when case-fold
                 ;; We didn't find any abbrev, try case-folding.
-                (let ((sym (intern-soft (downcase abbrev) table)))
+                (let ((sym (obarray-get table (downcase abbrev))))
                   ;; Only use it if it doesn't require :case-fixed.
                   (and sym (not (abbrev-get sym :case-fixed))
                        sym))))))
@@ -1005,17 +1005,17 @@ PROMPT is the prompt to use for the keymap.
 SORTFUN is passed to `sort' to change the default ordering."
   (unless sortfun (setq sortfun 'string-lessp))
   (let ((entries ()))
-    (mapatoms (lambda (abbrev)
-                (when (symbol-value abbrev)
-                  (let ((name (symbol-name abbrev)))
-                    (push `(,(intern name) menu-item ,name
-                            (lambda () (interactive)
-                              (abbrev-insert ',abbrev)))
-                          entries))))
-              table)
+    (obarray-map (lambda (abbrev)
+                   (when (symbol-value abbrev)
+                     (let ((name (symbol-name abbrev)))
+                       (push `(,(intern name) menu-item ,name
+                               (lambda () (interactive)
+                                 (abbrev-insert ',abbrev)))
+                             entries))))
+                 table)
     (nconc (make-sparse-keymap prompt)
            (sort entries (lambda (x y)
-                (funcall sortfun (nth 2 x) (nth 2 y)))))))
+                           (funcall sortfun (nth 2 x) (nth 2 y)))))))
 
 ;; Keep it after define-abbrev-table, since define-derived-mode uses
 ;; define-abbrev-table.
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 8560871..e2d0f52 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -430,11 +430,9 @@ Major modes that edit things other than ordinary files may 
change this
 (make-variable-buffer-local 'mode-line-buffer-identification)
 
 (defvar mode-line-misc-info
-  '((which-func-mode ("" which-func-format " "))
-    (global-mode-string ("" global-mode-string " ")))
+  '((global-mode-string ("" global-mode-string " ")))
   "Mode line construct for miscellaneous information.
-By default, this shows the information specified by
-`which-func-mode' and `global-mode-string'.")
+By default, this shows the information specified by `global-mode-string'.")
 (put 'mode-line-misc-info 'risky-local-variable t)
 
 (defvar mode-line-end-spaces '(:eval (unless (display-graphic-p) "-%-"))
diff --git a/lisp/calculator.el b/lisp/calculator.el
index 80b7c07..1d3715b 100644
--- a/lisp/calculator.el
+++ b/lisp/calculator.el
@@ -65,7 +65,7 @@ Note that this requires easymenu.  Must be set before 
loading."
   :group 'calculator)
 
 (defcustom calculator-unary-style 'postfix
-  "Value is either 'prefix or 'postfix.
+  "Value is either `prefix' or `postfix'.
 This determines the default behavior of unary operators."
   :type    '(choice (const prefix) (const postfix))
   :group   'calculator)
@@ -161,6 +161,8 @@ This makes it possible to paste big integers since they 
will be read as
 floats, otherwise the Emacs reader will fail on them."
   :type  'boolean
   :group 'calculator)
+(make-obsolete-variable 'calculator-paste-decimals
+                        "it is no longer used." nil)
 
 (defcustom calculator-copy-displayer nil
   "If non-nil, this is any value that can be used for
@@ -195,9 +197,9 @@ For example, use this to define the golden ratio number:
 before you load calculator."
   :type  '(repeat (cons character number))
   :set   (lambda (_ val)
-           (and (boundp 'calculator-registers)
-                (setq calculator-registers
-                      (append val calculator-registers)))
+           (when (boundp 'calculator-registers)
+             (setq calculator-registers
+                   (append val calculator-registers)))
            (setq calculator-user-registers val))
   :group 'calculator)
 
@@ -221,10 +223,10 @@ Examples:
           (\"tF\" mt-to-ft (/ X 0.3048)         1)
           (\"tM\" ft-to-mt (* X 0.3048)         1)))
 
-* Using a function-like form is very simple: use `X' for the argument
-  (`Y' for the second in case of a binary operator), `TX' is a truncated
+* Using a function-like form is simple: use `X' for the argument (`Y'
+  for a second one in case of a binary operator), `TX' is a truncated
   version of `X' and `F' for a recursive call.  Here is a [very
-  inefficient] Fibonacci number calculation:
+  inefficient] Fibonacci number operator:
 
   (add-to-list \\='calculator-user-operators
                \\='(\"F\" fib
@@ -290,7 +292,8 @@ user-defined operators, use `calculator-user-operators' 
instead.")
 (defvar calculator-operators nil
   "The calculator operators, each a list with:
 
-1. The key that is bound to for this operation (usually a string);
+1. The key(s) that is bound to for this operation, a string that is
+   used with `kbd';
 
 2. The displayed symbol for this function;
 
@@ -312,8 +315,8 @@ user-defined operators, use `calculator-user-operators' 
instead.")
 
 It it possible have a unary prefix version of a binary operator if it
 comes later in this list.  If the list begins with the symbol `nobind',
-then no key binding will take place -- this is only useful for
-predefined keys.
+then no key binding will take place -- this is only used for predefined
+keys.
 
 Use `calculator-user-operators' to add operators to this list, see its
 documentation for an example.")
@@ -332,10 +335,10 @@ documentation for an example.")
   "A table to convert input characters to corresponding radix symbols.")
 
 (defvar calculator-output-radix nil
-  "The mode for display, one of: nil (decimal), 'bin, 'oct or 'hex.")
+  "The mode for display, one of: nil (decimal), `bin', `oct' or `hex'.")
 
 (defvar calculator-input-radix nil
-  "The mode for input, one of: nil (decimal), 'bin, 'oct or 'hex.")
+  "The mode for input, one of: nil (decimal), `bin', `oct' or `hex'.")
 
 (defvar calculator-deg nil
   "Non-nil if trig functions operate on degrees instead of radians.")
@@ -370,9 +373,6 @@ Used for repeating operations in calculator-repR/L.")
           (list (cons ?e float-e) (cons ?p float-pi)))
   "The association list of calculator register values.")
 
-(defvar calculator-saved-global-map nil
-  "Saved global key map.")
-
 (defvar calculator-restart-other-mode nil
   "Used to hack restarting with the electric mode changed.")
 
@@ -382,61 +382,54 @@ Used for repeating operations in calculator-repR/L.")
 (defvar calculator-mode-map
   (let ((map (make-sparse-keymap)))
     (suppress-keymap map t)
-    (define-key map "i" nil)
-    (define-key map "o" nil)
-    (let ((p
-           '((calculator-open-paren  "[")
-             (calculator-close-paren "]")
-             (calculator-op-or-exp   "+" "-" [kp-add] [kp-subtract])
-             (calculator-digit       "0" "1" "2" "3" "4" "5" "6" "7" "8"
-                                     "9" "a" "b" "c" "d" "f"
-                                     [kp-0] [kp-1] [kp-2] [kp-3] [kp-4]
-                                     [kp-5] [kp-6] [kp-7] [kp-8] [kp-9])
-             (calculator-op          [kp-divide] [kp-multiply])
-             (calculator-decimal     "." [kp-decimal])
-             (calculator-exp         "e")
-             (calculator-dec/deg-mode "D")
-             (calculator-set-register "s")
-             (calculator-get-register "g")
-             (calculator-radix-mode        "H" "X" "O" "B")
-             (calculator-radix-input-mode  "id" "ih" "ix" "io" "ib"
-                                           "iD" "iH" "iX" "iO" "iB")
-             (calculator-radix-output-mode "od" "oh" "ox" "oo" "ob"
-                                           "oD" "oH" "oX" "oO" "oB")
-             (calculator-rotate-displayer      "'")
-             (calculator-rotate-displayer-back "\"")
-             (calculator-displayer-prev        "{")
-             (calculator-displayer-next        "}")
-             (calculator-saved-up      [up] [?\C-p])
-             (calculator-saved-down    [down] [?\C-n])
-             (calculator-quit          "q" [?\C-g])
-             (calculator-enter         [enter] [linefeed] [kp-enter]
-                                       [return] [?\r] [?\n])
-             (calculator-save-on-list  " " [space])
-             (calculator-clear-saved   [?\C-c] [(control delete)])
-             (calculator-save-and-quit [(control return)]
-                                       [(control kp-enter)])
-             (calculator-paste         [insert] [(shift insert)]
-                                       [paste] [mouse-2] [?\C-y])
-             (calculator-clear         [delete] [?\C-?] [?\C-d])
-             (calculator-help          [?h] [??] [f1] [help])
-             (calculator-copy          [(control insert)] [copy])
-             (calculator-backspace     [backspace])
-             )))
-      (while p
-        ;; reverse the keys so earlier definitions come last -- makes
-        ;; the more sensible bindings visible in the menu
-        (let ((func (caar p)) (keys (reverse (cdar p))))
-          (while keys
-            (define-key map (car keys) func)
-            (setq keys (cdr keys))))
-        (setq p (cdr p))))
+    (dolist (x '((calculator-digit
+                  "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c"
+                  "d" "f" "<kp-0>" "<kp-1>" "<kp-2>" "<kp-3>" "<kp-4>"
+                  "<kp-5>" "<kp-6>" "<kp-7>" "<kp-8>" "<kp-9>")
+                 (calculator-open-paren  "[")
+                 (calculator-close-paren "]")
+                 (calculator-op-or-exp   "+" "-"
+                                         "<kp-add>" "<kp-subtract>")
+                 (calculator-op          "<kp-divide>" "<kp-multiply>")
+                 (calculator-decimal     "." "<kp-decimal>")
+                 (calculator-exp         "e")
+                 (calculator-dec/deg-mode "D")
+                 (calculator-set-register "s")
+                 (calculator-get-register "g")
+                 (calculator-radix-mode        "H" "X" "O" "B")
+                 (calculator-radix-input-mode  "iD" "iH" "iX" "iO" "iB")
+                 (calculator-radix-output-mode "oD" "oH" "oX" "oO" "oB")
+                 (calculator-rotate-displayer      "'")
+                 (calculator-rotate-displayer-back "\"")
+                 (calculator-displayer-prev        "{")
+                 (calculator-displayer-next        "}")
+                 (calculator-saved-up     "<up>" "C-p")
+                 (calculator-saved-down   "<down>" "C-n")
+                 (calculator-quit         "q" "C-g")
+                 (calculator-enter        "<enter>" "<linefeed>"
+                                          "<kp-enter>" "<return>"
+                                          "RET" "LFD")
+                 (calculator-save-on-list "SPC" "<space>")
+                 (calculator-clear-saved  "C-c" "<C-delete>")
+                 (calculator-save-and-quit "<C-return>" "<C-kp-enter>")
+                 (calculator-paste        "<insert>" "<S-insert>"
+                                          "<paste>" "<mouse-2>" "C-y")
+                 (calculator-clear        "<delete>" "DEL" "C-d")
+                 (calculator-help         "h" "?" "<f1>" "<help>")
+                 (calculator-copy         "<C-insert>" "<copy>")
+                 (calculator-backspace    "<backspace>")
+                 ))
+      ;; reverse the keys so earlier definitions come last -- makes the
+      ;; more sensible bindings visible in the menu
+      (dolist (k (reverse (cdr x)))
+        (calculator-define-key k (car x) map)))
     (if calculator-bind-escape
-      (progn (define-key map [?\e] 'calculator-quit)
-             (define-key map [escape] 'calculator-quit))
-      (define-key map [?\e ?\e ?\e] 'calculator-quit))
+      (progn (calculator-define-key "ESC" 'calculator-quit map)
+             (calculator-define-key "<escape>" 'calculator-quit map))
+      (calculator-define-key "ESC ESC ESC" 'calculator-quit map))
     ;; make C-h work in text-mode
-    (or window-system (define-key map [?\C-h] 'calculator-backspace))
+    (unless window-system
+      (calculator-define-key "C-h" 'calculator-backspace map))
     ;; set up a menu
     (when (and calculator-use-menu (not (boundp 'calculator-menu)))
       (let ((radix-selectors
@@ -530,9 +523,9 @@ Used for repeating operations in calculator-repR/L.")
             ("Modes"
              ["Radians"
               (progn
-                (and (or calculator-input-radix calculator-output-radix)
-                     (calculator-radix-mode "D"))
-                (and calculator-deg (calculator-dec/deg-mode)))
+                (when (or calculator-input-radix calculator-output-radix)
+                  (calculator-radix-mode "D"))
+                (when calculator-deg (calculator-dec/deg-mode)))
               :keys "D"
               :style radio
               :selected (not (or calculator-input-radix
@@ -540,9 +533,9 @@ Used for repeating operations in calculator-repR/L.")
                                  calculator-deg))]
              ["Degrees"
               (progn
-                (and (or calculator-input-radix calculator-output-radix)
-                     (calculator-radix-mode "D"))
-                (or calculator-deg (calculator-dec/deg-mode)))
+                (when (or calculator-input-radix calculator-output-radix)
+                  (calculator-radix-mode "D"))
+                (unless calculator-deg (calculator-dec/deg-mode)))
               :keys "D"
               :style radio
               :selected (and calculator-deg
@@ -569,6 +562,38 @@ Used for repeating operations in calculator-repR/L.")
     map)
   "The calculator key map.")
 
+(defun calculator-define-key (key cmd &optional map)
+  ;; Arranges for unbound alphabetic keys to be used as their un/shifted
+  ;; versions if those are bound (mimics the usual Emacs global
+  ;; bindings).
+  (let* ((key  (if (stringp key) (kbd key) key))
+         (map  (or map calculator-mode-map))
+         (omap (keymap-parent map)))
+    (define-key map key cmd)
+    ;; "other" map, used for case-flipped bindings
+    (unless omap
+      (setq omap (make-sparse-keymap))
+      (suppress-keymap omap t)
+      (set-keymap-parent map omap))
+    (let ((m omap))
+      ;; Bind all case-flipped versions.
+      (dotimes (i (length key))
+        (let* ((c (aref key i))
+               (k (vector c))
+               (b (lookup-key m k))
+               (defkey (lambda (x)
+                         (define-key m k x)
+                         (when (and (characterp c)
+                                    (or (<= ?A c ?Z) (<= ?a c ?z)))
+                           (define-key m (vector (logxor 32 c)) x)))))
+          (cond ((= i (1- (length key)))
+                 ;; Prefer longer sequences.
+                 (unless (keymapp b) (funcall defkey cmd)))
+                ((keymapp b) (setq m b))
+                (t (let ((sub (make-sparse-keymap)))
+                     (funcall defkey sub)
+                     (setq m sub)))))))))
+
 ;;;---------------------------------------------------------------------
 ;;; Startup and mode stuff
 
@@ -619,16 +644,17 @@ argument.
 hex/oct/bin modes can be set for input and for display separately.
 Another toggle-able mode is for using degrees instead of radians for
 trigonometric functions.
-The keys to switch modes are (`X' is shortcut for `H'):
+The keys to switch modes are (both `H' and `X' are for hex):
 * `D'             switch to all-decimal mode, or toggle degrees/radians
 * `B' `O' `H' `X' binary/octal/hexadecimal modes for input & display
 * `i' `o'         followed by one of `D' `B' `O' `H' `X' (case
                   insensitive) sets only the input or display radix mode
 The prompt indicates the current modes:
-* \"D=\": degrees mode;
-* \"?=\": (? is B/O/H) this is the radix for both input and output;
-* \"=?\": (? is B/O/H) the display radix (when input is decimal);
-* \"??\": (? is D/B/O/H) 1st char for input radix, 2nd for display.
+* \"==\": decimal mode (using radians);
+* \"D=\": decimal mode using degrees;
+* \"?=\": ? is B/O/H, the radix for both input and output;
+* \"=?\": ? is B/O/H, the display radix (with decimal input);
+* \"??\": ? is D/B/O/H, 1st char for input radix, 2nd for display.
 
 Also, the quote key can be used to switch display modes for decimal
 numbers (double-quote rotates back), and the two brace characters
@@ -688,19 +714,14 @@ See the documentation for `calculator-mode' for more 
information."
   (if calculator-electric-mode
     (save-window-excursion
       (require 'electric) (message nil) ; hide load message
-      (let (old-g-map old-l-map
-            (old-buf (window-buffer (minibuffer-window)))
+      (let ((old-buf (window-buffer (minibuffer-window)))
             (echo-keystrokes 0)
             (garbage-collection-messages nil)) ; no gc msg when electric
         (set-window-buffer (minibuffer-window) calculator-buffer)
         (select-window (minibuffer-window))
         (calculator-reset)
         (calculator-update-display)
-        (setq old-l-map (current-local-map))
-        (setq old-g-map (current-global-map))
-        (setq calculator-saved-global-map (current-global-map))
-        (use-local-map nil)
-        (use-global-map calculator-mode-map)
+        (use-local-map calculator-mode-map)
         (run-hooks 'calculator-mode-hook)
         (unwind-protect
             (catch 'calculator-done
@@ -711,9 +732,7 @@ See the documentation for `calculator-mode' for more 
information."
                nil
                (lambda (_x _y) (calculator-update-display))))
           (set-window-buffer (minibuffer-window) old-buf)
-          (kill-buffer calculator-buffer)
-          (use-local-map old-l-map)
-          (use-global-map old-g-map))))
+          (kill-buffer calculator-buffer))))
     (progn
       (cond
         ((not (get-buffer-window calculator-buffer))
@@ -780,25 +799,11 @@ Defaults to 1."
 Adds MORE-OPS to `calculator-operator', called initially to handle
 `calculator-initial-operators' and `calculator-user-operators'."
   (let ((added-ops nil))
-    (while more-ops
-      (or (eq (caar more-ops) 'nobind)
-          (let ((i -1) (key (caar more-ops)))
-            ;; make sure the key is undefined, so it's easy to define
-            ;; prefix keys
-            (while (< (setq i (1+ i)) (length key))
-              (or (keymapp
-                   (lookup-key calculator-mode-map
-                               (substring key 0 (1+ i))))
-                  (progn
-                    (define-key
-                      calculator-mode-map (substring key 0 (1+ i)) nil)
-                    (setq i (length key)))))
-            (define-key calculator-mode-map key 'calculator-op)))
-      (setq added-ops (cons (if (eq (caar more-ops) 'nobind)
-                              (cdar more-ops)
-                              (car more-ops))
-                            added-ops))
-      (setq more-ops (cdr more-ops)))
+    (dolist (op more-ops)
+      (unless (eq (car op) 'nobind)
+        (calculator-define-key (car op) 'calculator-op))
+      (push (if (eq (car op) 'nobind) (cdr op) op)
+            added-ops))
     ;; added-ops come first, but in correct order
     (setq calculator-operators
           (append (nreverse added-ops) calculator-operators))))
@@ -808,11 +813,11 @@ Adds MORE-OPS to `calculator-operator', called initially 
to handle
 
 (defun calculator-reset ()
   "Reset calculator variables."
-  (or calculator-restart-other-mode
-      (setq calculator-stack           nil
-            calculator-curnum          nil
-            calculator-stack-display   nil
-            calculator-display-fragile nil))
+  (unless calculator-restart-other-mode
+    (setq calculator-stack           nil
+          calculator-curnum          nil
+          calculator-stack-display   nil
+          calculator-display-fragile nil))
   (setq calculator-restart-other-mode nil)
   (calculator-update-display))
 
@@ -831,7 +836,7 @@ The result should not exceed the screen width."
                          (cond ((or in-r out-r)
                                 (concat (or in-r "=")
                                         (if (equal in-r out-r) "="
-                                            (or out-r "="))))
+                                            (or out-r "D"))))
                                (calculator-deg "D=")
                                (t "=="))))
          (expr
@@ -852,39 +857,13 @@ The result should not exceed the screen width."
   "Convert the given STR to a number, according to the value of
 `calculator-input-radix'."
   (if calculator-input-radix
-    (let ((radix
-           (cdr (assq calculator-input-radix
-                      '((bin . 2) (oct . 8) (hex . 16)))))
-          (i -1) (value 0) (new-value 0))
-      ;; assume mostly valid input (e.g., characters in range)
-      (while (< (setq i (1+ i)) (length str))
-        (setq new-value
-              (let* ((ch (upcase (aref str i)))
-                     (n (cond ((< ch ?0)  nil)
-                              ((<= ch ?9) (- ch ?0))
-                              ((< ch ?A)  nil)
-                              ((<= ch ?Z) (- ch (- ?A 10)))
-                              (t          nil))))
-                (if (and n (<= 0 n) (< n radix))
-                  (+ n (* radix value))
-                  (progn
-                    (calculator-message
-                     "Warning: Ignoring bad input character `%c'." ch)
-                    (sit-for 1)
-                    value))))
-        (when (if (< new-value 0) (> value 0) (< value 0))
-          (calculator-message "Warning: Overflow in input."))
-        (setq value new-value))
-      value)
-    (car (read-from-string
-          (cond ((equal "." str) "0.0")
-                ((string-match-p "[eE][+-]?$" str) (concat str "0"))
-                ((string-match-p "\\.[0-9]\\|[eE]" str) str)
-                ((string-match-p "\\." str)
-                 ;; do this because Emacs reads "23." as an integer
-                 (concat str "0"))
-                ((stringp str) (concat str ".0"))
-                (t "0.0"))))))
+    (string-to-number str (cadr (assq calculator-input-radix
+                                      '((bin 2) (oct 8) (hex 16)))))
+    (let* ((str (replace-regexp-in-string
+                 "\\.\\([^0-9].*\\)?$" ".0\\1" str))
+           (str (replace-regexp-in-string
+                 "[eE][+-]?\\([^0-9].*\\)?$" "e0\\1" str)))
+      (string-to-number str))))
 
 (defun calculator-push-curnum ()
   "Push the numeric value of the displayed number to the stack."
@@ -911,9 +890,7 @@ If radix output mode is active, toggle digit grouping."
            (if (and new-disp (memq new-disp calculator-displayers))
              (let ((tmp nil))
                (while (not (eq (car calculator-displayers) new-disp))
-                 (setq tmp (cons (car calculator-displayers) tmp))
-                 (setq calculator-displayers
-                       (cdr calculator-displayers)))
+                 (push (pop calculator-displayers) tmp))
                (setq calculator-displayers
                      (nconc calculator-displayers (nreverse tmp))))
              (nconc (cdr calculator-displayers)
@@ -938,11 +915,11 @@ If radix output mode is active, increase the grouping 
size."
     (progn (setq calculator-radix-grouping-digits
                  (1+ calculator-radix-grouping-digits))
            (calculator-enter))
-    (and (car calculator-displayers)
-         (let ((disp (caar calculator-displayers)))
-           (cond ((symbolp disp) (funcall disp 'left))
-                 ((and (consp disp) (eq 'std (car disp)))
-                  (calculator-standard-displayer 'left)))))))
+    (when (car calculator-displayers)
+      (let ((disp (caar calculator-displayers)))
+        (cond ((symbolp disp) (funcall disp 'left))
+              ((and (consp disp) (eq 'std (car disp)))
+               (calculator-standard-displayer 'left)))))))
 
 (defun calculator-displayer-next ()
   "Send the current displayer function a `right' argument.
@@ -954,11 +931,11 @@ If radix output mode is active, decrease the grouping 
size."
     (progn (setq calculator-radix-grouping-digits
                  (max 2 (1- calculator-radix-grouping-digits)))
            (calculator-enter))
-    (and (car calculator-displayers)
-         (let ((disp (caar calculator-displayers)))
-           (cond ((symbolp disp) (funcall disp 'right))
-                 ((and (consp disp) (eq 'std (car disp)))
-                  (calculator-standard-displayer 'right)))))))
+    (when (car calculator-displayers)
+      (let ((disp (caar calculator-displayers)))
+        (cond ((symbolp disp) (funcall disp 'right))
+              ((and (consp disp) (eq 'std (car disp)))
+               (calculator-standard-displayer 'right)))))))
 
 (defun calculator-remove-zeros (numstr)
   "Get a number string NUMSTR and remove unnecessary zeros.
@@ -1003,10 +980,10 @@ The special `left' and `right' symbols will make it 
change the current
 number of digits displayed (`calculator-number-digits')."
   (if (symbolp num)
     (cond ((eq num 'left)
-           (and (> calculator-number-digits 0)
-                (setq calculator-number-digits
-                      (1- calculator-number-digits))
-                (calculator-enter)))
+           (when (> calculator-number-digits 0)
+             (setq calculator-number-digits
+                   (1- calculator-number-digits))
+             (calculator-enter)))
           ((eq num 'right)
            (setq calculator-number-digits
                  (1+ calculator-number-digits))
@@ -1054,7 +1031,7 @@ the `left' or `right' when one of the standard modes is 
used."
             (while (< i 0)
               (setq num (/ num 1000.0)) (setq exp (+ exp 3))
               (setq i (1+ i))))))
-      (or calculator-eng-tmp-show (setq calculator-eng-extra nil))
+      (unless calculator-eng-tmp-show (setq calculator-eng-extra nil))
       (let ((str (format (format "%%.%sf" calculator-number-digits)
                          num)))
         (concat (let ((calculator-remove-zeros
@@ -1206,7 +1183,7 @@ arguments."
           (DX (if (and X calculator-deg) (degrees-to-radians X) X))
           (L  calculator-saved-list)
           (fF `(calculator-funcall ',f x y))
-          (fD `(if calculator-deg (* radians-to-degrees x) x)))
+          (fD `(if calculator-deg (radians-to-degrees x) x)))
       (eval `(cl-flet ((F (&optional x y) ,fF) (D (x) ,fD))
                (let ((X ,X) (Y ,Y) (DX ,DX) (TX ,TX) (TY ,TY) (L ',L))
                  ,f))
@@ -1216,19 +1193,20 @@ arguments."
 ;;; Input interaction
 
 (defun calculator-last-input (&optional keys)
-  "Last char (or event or event sequence) that was read.
-Use KEYS if given, otherwise use `this-command-keys'."
-  (let ((inp (or keys (this-command-keys))))
-    (if (or (stringp inp) (not (arrayp inp)))
+  "Return the last key sequence that was used to invoke this command, or
+the input KEYS.  Uses the `function-key-map' translate keypad numbers to
+plain ones."
+  (let* ((inp (or keys (this-command-keys)))
+         (inp (or (and (arrayp inp) (not (stringp inp))
+                       (lookup-key function-key-map inp))
+                  inp)))
+    (if (or (not inp) (stringp inp) (not (arrayp inp))
+            (catch 'done ; any non-chars?
+              (dotimes (i (length inp))
+                (unless (characterp (aref inp i)) (throw 'done t)))
+              nil))
       inp
-      ;; Translates kp-x to x and [tries to] create a string to lookup
-      ;; operators; assume all symbols are translatable via
-      ;; `function-key-map'.  This is needed because we have key
-      ;; bindings for kp-* (which might be the wrong thing to do) so
-      ;; they don't get translated in `this-command-keys'.
-      (concat (mapcar (lambda (k)
-                        (if (numberp k) k (error "??bad key?? (%S)" k)))
-                      (or (lookup-key function-key-map inp) inp))))))
+      (concat inp))))
 
 (defun calculator-clear-fragile (&optional op)
   "Clear the fragile flag if it was set, then maybe reset all.
@@ -1270,7 +1248,7 @@ OP is the operator (if any) that caused this call."
     (calculator-update-display)))
 
 (defun calculator-exp ()
-  "Enter an `E' exponent character, or a digit in hex input mode."
+  "Enter an exponent, or an \"E\" digit in hex input mode."
   (interactive)
   (cond
     (calculator-input-radix (calculator-digit))
@@ -1312,18 +1290,13 @@ Optional string argument KEYS will force using it as 
the keys entered."
         (throw 'op-error nil))
       (push op calculator-stack)
       (calculator-reduce-stack (calculator-op-prec op))
-      (and (= (length calculator-stack) 1)
-           (numberp (car calculator-stack))
-           ;; the display is fragile if it contains only one number
-           (setq calculator-display-fragile t)
-           ;; add number to the saved-list
-           calculator-add-saved
-           (if (= 0 calculator-saved-ptr)
-             (setq calculator-saved-list
-                   (cons (car calculator-stack) calculator-saved-list))
-             (let ((p (nthcdr (1- calculator-saved-ptr)
-                              calculator-saved-list)))
-               (setcdr p (cons (car calculator-stack) (cdr p))))))
+      (when (and (= (length calculator-stack) 1)
+                 (numberp (car calculator-stack)))
+        ;; the display is fragile if it contains only one number
+        (setq calculator-display-fragile t)
+        (when calculator-add-saved ; add number to the saved-list
+          (push (car calculator-stack)
+                (nthcdr calculator-saved-ptr calculator-saved-list))))
       (calculator-update-display))))
 
 (defun calculator-op-or-exp ()
@@ -1332,7 +1305,8 @@ Used with +/- for entering them as digits in numbers like 
1e-3 (there is
 no need for negative numbers since these are handled by unary
 operators)."
   (interactive)
-  (if (and (not calculator-display-fragile)
+  (if (and (not calculator-input-radix)
+           (not calculator-display-fragile)
            calculator-curnum
            (string-match-p "[eE]$" calculator-curnum))
     (calculator-digit)
@@ -1346,8 +1320,8 @@ operators)."
   (interactive)
   (calculator-push-curnum)
   (if (or calculator-input-radix calculator-output-radix)
-    (progn (setq calculator-input-radix nil)
-           (setq calculator-output-radix nil))
+    (setq calculator-input-radix nil
+          calculator-output-radix nil)
     ;; already decimal -- toggle degrees mode
     (setq calculator-deg (not calculator-deg)))
   (calculator-update-display t))
@@ -1393,8 +1367,8 @@ Optional string argument KEYS will force using it as the 
keys entered."
 (defun calculator-clear-saved ()
   "Clear the list of saved values in `calculator-saved-list'."
   (interactive)
-  (setq calculator-saved-list nil)
-  (setq calculator-saved-ptr 0)
+  (setq calculator-saved-list nil
+        calculator-saved-ptr 0)
   (calculator-update-display t))
 
 (defun calculator-saved-move (n)
@@ -1492,21 +1466,6 @@ Optional string argument KEYS will force using it as the 
keys entered."
         (kill-new (replace-regexp-in-string
                    "^\\([^ ]+\\) *\\(\\[[0-9/]+\\]\\)? *$" "\\1" s))))))
 
-(defun calculator-set-register (reg)
-  "Set a register value for REG."
-  ;; FIXME: this should use `register-read-with-preview', but it uses
-  ;; calculator-registers rather than `register-alist'.  (Maybe
-  ;; dynamically rebinding it will get blessed?)  Also in to
-  ;; `calculator-get-register'.
-  (interactive "cRegister to store into: ")
-  (let* ((as  (assq reg calculator-registers))
-         (val (progn (calculator-enter) (car calculator-stack))))
-    (if as
-      (setcdr as val)
-      (setq calculator-registers
-            (cons (cons reg val) calculator-registers)))
-    (calculator-message "[%c] := %S" reg val)))
-
 (defun calculator-put-value (val)
   "Paste VAL as if entered.
 Used by `calculator-paste' and `get-register'."
@@ -1515,31 +1474,55 @@ Used by `calculator-paste' and `get-register'."
              (or calculator-display-fragile
                  (not (numberp (car calculator-stack)))))
     (calculator-clear-fragile)
-    (setq calculator-curnum (let ((calculator-displayer "%S"))
-                              (calculator-number-to-string val)))
+    (setq calculator-curnum
+          (let ((calculator-displayer "%S")
+                (calculator-radix-grouping-mode nil)
+                (calculator-output-radix calculator-input-radix))
+            (calculator-number-to-string val)))
     (calculator-update-display)))
 
-(defun calculator-paste ()
-  "Paste a value from the `kill-ring'."
-  (interactive)
-  (calculator-put-value
-   (let ((str (replace-regexp-in-string
-               "^ *\\(.+[^ ]\\) *$" "\\1" (current-kill 0))))
-     (and (not calculator-input-radix)
-          calculator-paste-decimals
-          (string-match "\\([0-9]+\\)\\(\\.[0-9]+\\)?\\(e[0-9]+\\)?"
-                        str)
-          (or (match-string 1 str)
-              (match-string 2 str)
-              (match-string 3 str))
-          (setq str (concat (or (match-string 1 str) "0")
-                            (or (match-string 2 str) ".0")
-                            (or (match-string 3 str) ""))))
-     (ignore-errors (calculator-string-to-number str)))))
+(defun calculator-paste (arg)
+  "Paste a value from the `kill-ring'.
+
+With a prefix argument, paste the raw string as a sequence of key
+presses, which can be used to paste expressions.  Note that this
+is literal; examples: spaces will store values, pasting \"1+2\"
+will not produce 3 if it's done you're entering a number or after
+a multiplication."
+  (interactive "P")
+  (let ((str (current-kill 0)))
+    (if arg
+      (setq unread-command-events
+            `(,@(listify-key-sequence str) ,@unread-command-events))
+      (calculator-put-value (calculator-string-to-number str)))))
+
+(defun calculator-register-read-with-preview (prompt)
+  "Similar to `register-read-with-preview' but for calculator
+registers."
+  (let ((register-alist calculator-registers)
+        (register-preview-delay 1)
+        (register-preview-function
+         (lambda (r)
+           (format "%s: %s\n"
+                   (single-key-description (car r))
+                   (calculator-number-to-string (cdr r))))))
+    (register-read-with-preview prompt)))
+
+(defun calculator-set-register (reg)
+  "Set a register value for REG."
+  (interactive (list (calculator-register-read-with-preview
+                      "Register to store value into: ")))
+  (let* ((as  (assq reg calculator-registers))
+         (val (progn (calculator-enter) (car calculator-stack))))
+    (if as
+      (setcdr as val)
+      (push (cons reg val) calculator-registers))
+    (calculator-message "[%c] := %S" reg val)))
 
 (defun calculator-get-register (reg)
   "Get a value from a register REG."
-  (interactive "cRegister to get value from: ")
+  (interactive (list (calculator-register-read-with-preview
+                      "Register to get value from: ")))
   (calculator-put-value (cdr (assq reg calculator-registers))))
 
 (declare-function electric-describe-mode "ehelp" ())
@@ -1551,10 +1534,11 @@ Used by `calculator-paste' and `get-register'."
   + - * / \\(div) %(rem) _(-X,postfix) ;(1/X,postfix) ^(exp) L(og)
   Q(sqrt) !(fact) S(in) C(os) T(an) |(or) #(xor) &(and) ~(not)
 * >/< repeats last binary operation with its 2nd (1st) arg as postfix op
-* I inverses next trig function        * \\='/\"/{} - display/display args
+* I inverse the next trig function     \
+* \\='/\"/{/}  - display/display args
 * D         - switch to all-decimal, or toggle deg/rad mode
-* B/O/H/X   - binary/octal/hex mode for i/o (X is a shortcut for H)
-* i/o       - prefix for d/b/o/x - set only input/output modes
+* B/O/H/X   - binary/octal/hex mode for i/o (both H and X are for hex)
+* i/o       - prefix for D/B/O/X - set only input/output modes
 * enter/=   - evaluate current expr.   * s/g      - set/get a register
 * space     - evaluate & save on list  * l/v      - list total/average
 * up/down/C-p/C-n - browse saved       * C-delete - clear all saved
@@ -1566,15 +1550,11 @@ Used by `calculator-paste' and `get-register'."
   (if (eq last-command 'calculator-help)
     (let ((mode-name "Calculator")
           (major-mode 'calculator-mode)
-          (g-map (current-global-map))
           (win (selected-window)))
       (require 'ehelp)
-      (when calculator-electric-mode
-        (use-global-map calculator-saved-global-map))
-      (if calculator-electric-mode
-        (electric-describe-mode)
-        (describe-mode))
-      (when calculator-electric-mode (use-global-map g-map))
+      (if (not calculator-electric-mode)
+        (describe-mode)
+        (electric-describe-mode))
       (select-window win)
       (message nil))
     (let ((one (one-window-p t))
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index aa26ac3..22f12ba 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -1164,7 +1164,7 @@ Show the buffer in another window, but don't select it."
     (unless (eq symbol basevar)
       (message "`%s' is an alias for `%s'" symbol basevar))))
 
-(defvar customize-changed-options-previous-release "24.1"
+(defvar customize-changed-options-previous-release "24.5"
   "Version for `customize-changed-options' to refer back to by default.")
 
 ;; Packages will update this variable, so make it available.
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index dcaaab6..c54cd22 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -756,9 +756,7 @@ Argument FN is the function calling this verifier."
          ;; The slot-missing method is a cool way of allowing an object author
          ;; to intercept missing slot definitions.  Since it is also the LAST
          ;; thing called in this fn, its return value would be retrieved.
-         (slot-missing obj slot 'oref)
-         ;;(signal 'invalid-slot-name (list (eieio-object-name obj) slot))
-         )
+         (slot-missing obj slot 'oref))
       (cl-check-type obj eieio-object)
       (eieio-barf-if-slot-unbound (aref obj c) obj slot 'oref))))
 
@@ -780,9 +778,7 @@ Fills in OBJ's SLOT with its default value."
            ;; Oref that slot.
            (aref (eieio--class-class-allocation-values cl)
                  c)
-         (slot-missing obj slot 'oref-default)
-         ;;(signal 'invalid-slot-name (list (class-name cl) slot))
-         )
+         (slot-missing obj slot 'oref-default))
       (eieio-barf-if-slot-unbound
        (let ((val (cl--slot-descriptor-initform
                    (aref (eieio--class-slots cl)
@@ -822,9 +818,7 @@ Fills in OBJ's SLOT with VALUE."
              (aset (eieio--class-class-allocation-values class)
                    c value))
          ;; See oref for comment on `slot-missing'
-         (slot-missing obj slot 'oset value)
-         ;;(signal 'invalid-slot-name (list (eieio-object-name obj) slot))
-         )
+         (slot-missing obj slot 'oset value))
       (eieio--validate-slot-value class c value slot)
       (aset obj c value))))
 
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index 790e8bc..0ec07fe 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -678,7 +678,8 @@ This class is not stored in the `parent' slot of a class 
vector."
 
 (setq eieio-default-superclass (cl--find-class 'eieio-default-superclass))
 
-(defalias 'standard-class 'eieio-default-superclass)
+(define-obsolete-function-alias 'standard-class
+  'eieio-default-superclass "25.2")
 
 (cl-defgeneric make-instance (class &rest initargs)
   "Make a new instance of CLASS based on INITARGS.
@@ -765,11 +766,7 @@ dynamically set from SLOTS."
   ;; Shared initialize will parse our slots for us.
   (shared-initialize this slots))
 
-(cl-defgeneric slot-missing (object slot-name operation &optional new-value)
-  "Method invoked when an attempt to access a slot in OBJECT fails.")
-
-(cl-defmethod slot-missing ((object eieio-default-superclass) slot-name
-                        _operation &optional _new-value)
+(cl-defgeneric slot-missing (object slot-name _operation &optional _new-value)
   "Method invoked when an attempt to access a slot in OBJECT fails.
 SLOT-NAME is the name of the failed slot, OPERATION is the type of access
 that was requested, and optional NEW-VALUE is the value that was desired
@@ -777,8 +774,9 @@ to be set.
 
 This method is called from `oref', `oset', and other functions which
 directly reference slots in EIEIO objects."
-  (signal 'invalid-slot-name (list (eieio-object-name object)
-                                  slot-name)))
+  (signal 'invalid-slot-name
+          (list (if (eieio-object-p object) (eieio-object-name object) object)
+                slot-name)))
 
 (cl-defgeneric slot-unbound (object class slot-name fn)
   "Slot unbound is invoked during an attempt to reference an unbound slot.")
@@ -815,22 +813,19 @@ first and modify the returned object.")
     (if params (shared-initialize nobj params))
     nobj))
 
-(cl-defgeneric destructor (this &rest params)
-  "Destructor for cleaning up any dynamic links to our object.")
-
-(cl-defmethod destructor ((_this eieio-default-superclass) &rest _params)
-  "Destructor for cleaning up any dynamic links to our object.
-Argument THIS is the object being destroyed.  PARAMS are additional
-ignored parameters."
+(cl-defgeneric destructor (_this &rest _params)
+  "Destructor for cleaning up any dynamic links to our object."
+  (declare (obsolete nil "25.2"))
   ;; No cleanup... yet.
-  )
+  nil)
 
-(cl-defgeneric object-print (this &rest strings)
-  "Pretty printer for object THIS.  Call function `object-name' with STRINGS.
+(cl-defgeneric object-print (this &rest _strings)
+  "Pretty printer for object THIS.
 
 It is sometimes useful to put a summary of the object into the
 default #<notation> string when using EIEIO browsing tools.
-Implement this method to customize the summary.")
+Implement this method to customize the summary."
+  (format "%S" this))
 
 (cl-defmethod object-print ((this eieio-default-superclass) &rest strings)
   "Pretty printer for object THIS.  Call function `object-name' with STRINGS.
@@ -938,11 +933,12 @@ this object."
 
 ;;; Unimplemented functions from CLOS
 ;;
-(defun change-class (_obj _class)
+(defun eieio-change-class (_obj _class)
   "Change the class of OBJ to type CLASS.
 This may create or delete slots, but does not affect the return value
 of `eq'."
   (error "EIEIO: `change-class' is unimplemented"))
+(define-obsolete-function-alias 'change-class 'eieio-change-class "25.2")
 
 ;; Hook ourselves into help system for describing classes and methods.
 ;; FIXME: This is not actually needed any more since we can click on the
diff --git a/lisp/emacs-lisp/let-alist.el b/lisp/emacs-lisp/let-alist.el
index ca7a904..0b5dede 100644
--- a/lisp/emacs-lisp/let-alist.el
+++ b/lisp/emacs-lisp/let-alist.el
@@ -2,13 +2,16 @@
 
 ;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
 
-;; Author: Artur Malabarba <address@hidden>
-;; Maintainer: Artur Malabarba <address@hidden>
+;; Author: Artur Malabarba <address@hidden>
+;; Package-Requires: ((emacs "24.1"))
 ;; Version: 1.0.4
 ;; Keywords: extensions lisp
 ;; Prefix: let-alist
 ;; Separator: -
 
+;; This is an Elpa :core package. Don't use functionality that is not
+;; compatible with Emacs 24.1.
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software: you can redistribute it and/or modify
@@ -134,7 +137,7 @@ displayed in the example above."
   (let ((var (make-symbol "alist")))
     `(let ((,var ,alist))
        (let ,(mapcar (lambda (x) `(,(car x) ,(let-alist--access-sexp (car x) 
var)))
-               (delete-dups (let-alist--deep-dot-search body)))
+                     (delete-dups (let-alist--deep-dot-search body)))
          ,@body))))
 
 (provide 'let-alist)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 2962da5..fdad84a 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -167,6 +167,7 @@
 
 (require 'tabulated-list)
 (require 'macroexp)
+(require 'url-handlers)
 
 (defgroup package nil
   "Manager for Emacs Lisp packages."
@@ -1124,7 +1125,8 @@ FILE is the name of a file relative to that base location.
 This macro retrieves FILE from LOCATION into a temporary buffer,
 and evaluates BODY while that buffer is current.  This work
 buffer is killed afterwards.  Return the last value in BODY."
-  (declare (indent 2) (debug t))
+  (declare (indent 2) (debug t)
+           (obsolete package--with-response-buffer "25.1"))
   `(with-temp-buffer
      (if (string-match-p "\\`https?:" ,location)
          (url-insert-file-contents (concat ,location ,file))
@@ -1134,47 +1136,52 @@ buffer is killed afterwards.  Return the last value in 
BODY."
        (insert-file-contents (expand-file-name ,file ,location)))
      ,@body))
 
-(defmacro package--with-work-buffer-async (location file async &rest body)
-  "Run BODY in a buffer containing the contents of FILE at LOCATION.
-If ASYNC is non-nil, and if it is possible, run BODY
-asynchronously.  If an error is encountered and ASYNC is a
-function, call it with no arguments (instead of executing BODY).
-If it returns non-nil, or if it wasn't a function, propagate the
-error.
-
-For a description of the other arguments see
-`package--with-work-buffer'."
-  (declare (indent 3) (debug t))
-  (macroexp-let2* macroexp-copyable-p
-      ((async-1 async)
-       (file-1 file)
-       (location-1 location))
-    `(if (or (not ,async-1)
-             (not (string-match-p "\\`https?:" ,location-1)))
-         (package--with-work-buffer ,location-1 ,file-1 ,@body)
-       ;; This `condition-case' is to catch connection errors.
-       (condition-case error-signal
-           (url-retrieve (concat ,location-1 ,file-1)
-                         ;; This is to catch execution errors.
-                         (lambda (status)
-                           (condition-case error-signal
-                               (progn
-                                 (when-let ((er (plist-get status :error)))
-                                   (error "Error retrieving: %s %S" (concat 
,location-1 ,file-1) er))
-                                 (goto-char (point-min))
-                                 (unless (search-forward "\n\n" nil 'noerror)
-                                   (error "Invalid url response in buffer %s"
-                                          (current-buffer)))
-                                 (delete-region (point-min) (point))
-                                 ,@body
-                                 (kill-buffer (current-buffer)))
-                             (error (when (if (functionp ,async-1) (funcall 
,async-1) t)
-                                      (signal (car error-signal) (cdr 
error-signal))))))
-                         nil
-                         'silent)
-         (error (when (if (functionp ,async-1) (funcall ,async-1) t)
-                  (message "Error contacting: %s" (concat ,location-1 ,file-1))
-                  (signal (car error-signal) (cdr error-signal))))))))
+(cl-defmacro package--with-response-buffer (url &rest body &key async file 
error-form noerror &allow-other-keys)
+  "Access URL and run BODY in a buffer containing the response.
+Point is after the headers when BODY runs.
+FILE, if provided, is added to URL.
+URL can be a local file name, which must be absolute.
+ASYNC, if non-nil, runs the request asynchronously.
+ERROR-FORM is run only if an error occurs.  If NOERROR is
+non-nil, don't propagate errors caused by the connection or by
+BODY (does not apply to errors signaled by ERROR-FORM).
+
+\(fn URL &key ASYNC FILE ERROR-FORM NOERROR &rest BODY)"
+  (declare (indent defun) (debug t))
+  (while (keywordp (car body))
+    (setq body (cdr (cdr body))))
+  (macroexp-let2* nil ((url-1 url))
+    `(cl-macrolet ((wrap-errors (&rest bodyforms)
+                                (let ((err (make-symbol "err")))
+                                  `(condition-case ,err
+                                       ,(macroexp-progn bodyforms)
+                                     ,(list 'error ',error-form
+                                            (list 'unless ',noerror
+                                                  `(signal (car ,err) (cdr 
,err))))))))
+       (if (string-match-p "\\`https?:" ,url-1)
+           (let* ((url (concat ,url-1 ,file))
+                  (callback (lambda (status)
+                              (let ((b (current-buffer)))
+                                (unwind-protect (wrap-errors
+                                                 (when-let ((er (plist-get 
status :error)))
+                                                   (error "Error retrieving: 
%s %S" url er))
+                                                 (unless 
(search-forward-regexp "^\r?\n\r?" nil 'noerror)
+                                                   (error "Error retrieving: 
%s %S" url "incomprehensible buffer"))
+                                                 (with-temp-buffer
+                                                   (url-insert-buffer-contents 
b url)
+                                                   (kill-buffer b)
+                                                   (goto-char (point-min))
+                                                   ,@body)))))))
+             (if ,async
+                 (wrap-errors (url-retrieve url callback nil 'silent))
+               (with-current-buffer (wrap-errors (url-retrieve-synchronously 
url 'silent))
+                 (funcall callback nil))))
+         (wrap-errors (with-temp-buffer
+                        (let ((url (expand-file-name ,file ,url-1)))
+                          (unless (file-name-absolute-p url)
+                            (error "Location %s is not a url nor an absolute 
file name" url))
+                          (insert-file-contents url))
+                        ,@body))))))
 
 (defun package--check-signature-content (content string &optional sig-file)
   "Check signature CONTENT against STRING.
@@ -1220,15 +1227,12 @@ list can be empty).  If the signatures file is not 
found,
 CALLBACK is called with no arguments."
   (let ((sig-file (concat file ".sig"))
         (string (or string (buffer-string))))
-    (condition-case nil
-        (package--with-work-buffer-async
-            location sig-file (when async (or callback t))
-          (let ((sig (package--check-signature-content
-                      (buffer-string) string sig-file)))
-            (when callback (funcall callback sig))
-            sig))
-      (file-error (funcall callback)))))
-
+    (package--with-response-buffer location :file sig-file
+      :async async :noerror t
+      :error-form (when callback (funcall callback nil))
+      (let ((sig (package--check-signature-content (buffer-substring (point) 
(point-max)) string sig-file)))
+        (when callback (funcall callback sig))
+        sig))))
 
 ;;; Packages on Archives
 ;; The following variables store information about packages available
@@ -1470,7 +1474,9 @@ Once it's empty, run 
`package--post-download-archives-hook'."
 ARCHIVE should be a cons cell of the form (NAME . LOCATION),
 similar to an entry in `package-alist'.  Save the cached copy to
 \"archives/NAME/FILE\" in `package-user-dir'."
-  (package--with-work-buffer-async (cdr archive) file async
+  (package--with-response-buffer (cdr archive) :file file
+    :async async
+    :error-form (package--update-downloads-in-progress archive)
     (let* ((location (cdr archive))
            (name (car archive))
            (content (buffer-string))
@@ -1494,17 +1500,14 @@ similar to an entry in `package-alist'.  Save the 
cached copy to
                ;; remove it from the in-progress list.
                (package--update-downloads-in-progress archive)
                (error "Unsigned archive `%s'" name))
+             ;; Either everything worked or we don't mind not signing.
              ;; Write out the archives file.
              (write-region content nil local-file nil 'silent)
              ;; Write out good signatures into archive-contents.signed file.
              (when good-sigs
                (write-region (mapconcat #'epg-signature-to-string good-sigs 
"\n")
                              nil (concat local-file ".signed") nil 'silent))
-             (package--update-downloads-in-progress archive)
-             ;; If we got this far, either everything worked or we don't mind
-             ;; not signing, so tell `package--with-work-buffer-async' to not
-             ;; propagate errors.
-             nil)))))))
+             (package--update-downloads-in-progress archive))))))))
 
 (defun package--download-and-read-archives (&optional async)
   "Download descriptions of all `package-archives' and read them.
@@ -1517,12 +1520,7 @@ perform the downloads asynchronously."
                 :test #'equal))
   (dolist (archive package-archives)
     (condition-case-unless-debug nil
-        (package--download-one-archive
-         archive "archive-contents"
-         ;; Called if the async download fails
-         (when async
-           ;; The t at the end means to propagate connection errors.
-           (lambda () (package--update-downloads-in-progress archive) t)))
+        (package--download-one-archive archive "archive-contents" async)
       (error (message "Failed to download `%s' archive."
                (car archive))))))
 
@@ -1777,7 +1775,7 @@ if all the in-between dependencies are also in 
PACKAGE-LIST."
   (let* ((location (package-archive-base pkg-desc))
          (file (concat (package-desc-full-name pkg-desc)
                        (package-desc-suffix pkg-desc))))
-    (package--with-work-buffer location file
+    (package--with-response-buffer location :file file
       (if (or (not package-check-signature)
               (member (package-desc-archive pkg-desc)
                       package-unsigned-archives))
@@ -2368,26 +2366,23 @@ Otherwise no newline is inserted."
               (replace-match ""))
             (while (re-search-forward "^\\(;+ ?\\)" nil t)
               (replace-match ""))))
-      (let ((readme (expand-file-name (format "%s-readme.txt" name)
-                                      package-user-dir))
-            readme-string)
+      (let* ((basename (format "%s-readme.txt" name))
+             (readme (expand-file-name basename package-user-dir))
+             readme-string)
         ;; For elpa packages, try downloading the commentary.  If that
         ;; fails, try an existing readme file in `package-user-dir'.
-        (cond ((condition-case nil
-                   (save-excursion
-                     (package--with-work-buffer
-                         (package-archive-base desc)
-                         (format "%s-readme.txt" name)
-                       (save-excursion
-                         (goto-char (point-max))
-                         (unless (bolp)
-                           (insert ?\n)))
-                       (write-region nil nil
-                                     (expand-file-name readme package-user-dir)
-                                     nil 'silent)
-                       (setq readme-string (buffer-string))
-                       t))
-                 (error nil))
+        (cond ((and (package-desc-archive desc)
+                    (package--with-response-buffer (package-archive-base desc)
+                      :file basename :noerror t
+                      (save-excursion
+                        (goto-char (point-max))
+                        (unless (bolp)
+                          (insert ?\n)))
+                      (write-region nil nil
+                                    (expand-file-name readme package-user-dir)
+                                    nil 'silent)
+                      (setq readme-string (buffer-string))
+                      t))
                (insert readme-string))
               ((file-readable-p readme)
                (insert-file-contents readme)
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index ea8b524..d389f6e 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -666,6 +666,22 @@ If command is repeated at same position, delete the 
rectangle."
             (setq rect (cons row rect))))))
     (nreverse rect)))
 
+(defun cua--extract-rectangle-bounds ()
+  (let (rect)
+    (if (not (cua--rectangle-virtual-edges))
+        (cua--rectangle-operation nil nil nil nil nil ; do not tabify
+          (lambda (s e _l _r)
+             (setq rect (cons (cons s e) rect))))
+      (cua--rectangle-operation nil 1 nil nil nil ; do not tabify
+        (lambda (s e l r _v)
+           (goto-char s)
+           (move-to-column l)
+           (setq s (point))
+           (move-to-column r)
+           (setq e (point))
+           (setq rect (cons (cons s e) rect)))))
+    (nreverse rect)))
+
 (defun cua--insert-rectangle (rect &optional below paste-column line-count)
   ;; Insert rectangle as insert-rectangle, but don't set mark and exit with
   ;; point at either next to top right or below bottom left corner
@@ -1394,6 +1410,8 @@ With prefix arg, indent to that column."
 
 (add-function :around region-extract-function
               #'cua--rectangle-region-extract)
+(add-function :around region-insert-function
+              #'cua--insert-rectangle)
 (add-function :around redisplay-highlight-region-function
               #'cua--rectangle-highlight-for-redisplay)
 
@@ -1405,8 +1423,12 @@ With prefix arg, indent to that column."
 
 (defun cua--rectangle-region-extract (orig &optional delete)
   (cond
-   ((not cua--rectangle) (funcall orig delete))
-   ((eq delete 'delete-only) (cua--delete-rectangle))
+   ((not cua--rectangle)
+    (funcall orig delete))
+   ((eq delete 'bounds)
+    (cua--extract-rectangle-bounds))
+   ((eq delete 'delete-only)
+    (cua--delete-rectangle))
    (t
     (let* ((strs (cua--extract-rectangle))
            (str (mapconcat #'identity strs "\n")))
diff --git a/lisp/epa.el b/lisp/epa.el
index 9f112c4..e51d5d8 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -34,6 +34,17 @@
   :link '(custom-manual "(epa) Top")
   :group 'epg)
 
+(defcustom epa-replace-original-text 'ask
+  "Whether the original text shall be replaced by the decrypted.
+
+If t, replace the original text without any confirmation.
+If nil, don't replace the original text and show the result in a new buffer.
+If neither t nor nil, ask user for confirmation."
+  :type '(choice (const :tag "Never" nil)
+                (const :tag "Ask the user" ask)
+                (const :tag "Always" t))
+  :group 'epa)
+
 (defcustom epa-popup-info-window t
   "If non-nil, display status information from epa commands in another window."
   :type 'boolean
@@ -872,7 +883,9 @@ For example:
          (with-current-buffer (funcall make-buffer-function)
            (let ((inhibit-read-only t))
              (insert plain)))
-       (if (y-or-n-p "Replace the original text? ")
+       (if (or (eq epa-replace-original-text t)
+                (and epa-replace-original-text
+                     (y-or-n-p "Replace the original text? ")))
            (let ((inhibit-read-only t))
              (delete-region start end)
              (goto-char start)
@@ -968,7 +981,9 @@ For example:
                 (or coding-system-for-read
                     (get-text-property start 'epa-coding-system-used)
                     'undecided)))
-    (if (y-or-n-p "Replace the original text? ")
+    (if (or (eq epa-replace-original-text t)
+            (and epa-replace-original-text
+                 (y-or-n-p "Replace the original text? ")))
        (let ((inhibit-read-only t)
              buffer-read-only)
          (delete-region start end)
diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index 4c5d43f..b6c1f68 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -22,15 +22,16 @@
 ;;; Commentary
 
 ;; This package is an abstraction layer from the different low-level
-;; file notification packages `gfilenotify', `inotify' and
+;; file notification packages `inotify', `kqueue', `gfilenotify' and
 ;; `w32notify'.
 
 ;;; Code:
 
 (defconst file-notify--library
   (cond
-   ((featurep 'gfilenotify) 'gfilenotify)
    ((featurep 'inotify) 'inotify)
+   ((featurep 'kqueue) 'kqueue)
+   ((featurep 'gfilenotify) 'gfilenotify)
    ((featurep 'w32notify) 'w32notify))
   "Non-nil when Emacs has been compiled with file notification support.
 The value is the name of the low-level file notification package
@@ -40,25 +41,24 @@ could use another implementation.")
 (defvar file-notify-descriptors (make-hash-table :test 'equal)
   "Hash table for registered file notification descriptors.
 A key in this hash table is the descriptor as returned from
-`gfilenotify', `inotify', `w32notify' or a file name handler.
-The value in the hash table is a list
+`inotify', `kqueue', `gfilenotify', `w32notify' or a file name
+handler.  The value in the hash table is a list
 
   (DIR (FILE . CALLBACK) (FILE . CALLBACK) ...)
 
 Several values for a given DIR happen only for `inotify', when
 different files from the same directory are watched.")
 
-(defun file-notify--rm-descriptor (descriptor &optional what)
+(defun file-notify--rm-descriptor (descriptor)
   "Remove DESCRIPTOR from `file-notify-descriptors'.
 DESCRIPTOR should be an object returned by `file-notify-add-watch'.
-If it is registered in `file-notify-descriptors', a stopped event is sent.
-WHAT is a file or directory name to be removed, needed just for `inotify'."
+If it is registered in `file-notify-descriptors', a stopped event is sent."
   (let* ((desc (if (consp descriptor) (car descriptor) descriptor))
         (file (if (consp descriptor) (cdr descriptor)))
          (registered (gethash desc file-notify-descriptors))
         (dir (car registered)))
 
-    (when (and (consp registered) (or (null what) (string-equal dir what)))
+    (when (consp registered)
       ;; Send `stopped' event.
       (dolist (entry (cdr registered))
        (funcall (cdr entry)
@@ -76,7 +76,8 @@ WHAT is a file or directory name to be removed, needed just 
for `inotify'."
            (remhash desc file-notify-descriptors)
          (puthash desc registered file-notify-descriptors))))))
 
-;; This function is used by `gfilenotify', `inotify' and `w32notify' events.
+;; This function is used by `inotify', `kqueue', `gfilenotify' and
+;; `w32notify' events.
 ;;;###autoload
 (defun file-notify-handle-event (event)
   "Handle file system monitoring event.
@@ -159,7 +160,7 @@ EVENT is the cadr of the event in `file-notify-handle-event'
        (setq actions nil))
 
       ;; Loop over actions.  In fact, more than one action happens only
-      ;; for `inotify'.
+      ;; for `inotify' and `kqueue'.
       (dolist (action actions)
 
        ;; Send pending event, if it doesn't match.
@@ -184,19 +185,17 @@ EVENT is the cadr of the event in 
`file-notify-handle-event'
        ;; Map action.  We ignore all events which cannot be mapped.
        (setq action
              (cond
-              ;; gfilenotify.
-              ((memq action '(attribute-changed changed created deleted))
+              ((memq action
+                      '(attribute-changed changed created deleted renamed))
                action)
-              ((eq action 'moved)
+              ((memq action '(moved rename))
                (setq file1 (file-notify--event-file1-name event))
                'renamed)
-
-              ;; inotify, w32notify.
               ((eq action 'ignored)
                 (setq stopped t actions nil))
-              ((eq action 'attrib) 'attribute-changed)
+              ((memq action '(attrib link)) 'attribute-changed)
               ((memq action '(create added)) 'created)
-              ((memq action '(modify modified)) 'changed)
+              ((memq action '(modify modified write)) 'changed)
               ((memq action '(delete delete-self move-self removed)) 'deleted)
               ;; Make the event pending.
               ((memq action '(moved-from renamed-from))
@@ -236,7 +235,6 @@ EVENT is the cadr of the event in `file-notify-handle-event'
           (setq pending-event nil))
 
         ;; Check for stopped.
-       ;;(message "file-notify-callback %S %S" file registered)
         (setq
          stopped
          (or
@@ -244,10 +242,13 @@ EVENT is the cadr of the event in 
`file-notify-handle-event'
           (and
            (memq action '(deleted renamed))
            (= (length (cdr registered)) 1)
-           (string-equal
-            (file-name-nondirectory file)
-           (or (file-name-nondirectory (car registered))
-               (car (cadr registered)))))))
+           (or
+            (string-equal
+             (file-name-nondirectory file)
+            (file-name-nondirectory (car registered)))
+            (string-equal
+             (file-name-nondirectory file)
+             (car (cadr registered)))))))
 
        ;; Apply callback.
        (when (and action
@@ -258,10 +259,17 @@ EVENT is the cadr of the event in 
`file-notify-handle-event'
                    ;; File matches.
                    (string-equal
                     (nth 0 entry) (file-name-nondirectory file))
+                   ;; Directory matches.
+                   (string-equal
+                    (file-name-nondirectory file)
+                    (file-name-nondirectory (car registered)))
                    ;; File1 matches.
                    (and (stringp file1)
                         (string-equal
                          (nth 0 entry) (file-name-nondirectory file1)))))
+          ;;(message
+           ;;"file-notify-callback %S %S %S %S %S"
+           ;;(file-notify--descriptor desc file) action file file1 registered)
          (if file1
              (funcall
               callback
@@ -272,11 +280,10 @@ EVENT is the cadr of the event in 
`file-notify-handle-event'
 
       ;; Modify `file-notify-descriptors'.
       (when stopped
-        (file-notify--rm-descriptor
-         (file-notify--descriptor desc file) file)))))
+        (file-notify-rm-watch (file-notify--descriptor desc file))))))
 
-;; `gfilenotify' and `w32notify' return a unique descriptor for every
-;; `file-notify-add-watch', while `inotify' returns a unique
+;; `kqueue', `gfilenotify' and `w32notify' return a unique descriptor
+;; for every `file-notify-add-watch', while `inotify' returns a unique
 ;; descriptor per inode only.
 (defun file-notify-add-watch (file flags callback)
   "Add a watch for filesystem events pertaining to FILE.
@@ -329,7 +336,7 @@ FILE is the name of the file whose event is being reported."
               (if (file-directory-p file)
                   file
                 (file-name-directory file))))
-       desc func l-flags registered)
+       desc func l-flags registered entry)
 
     (unless (file-directory-p dir)
       (signal 'file-notify-error `("Directory does not exist" ,dir)))
@@ -338,7 +345,12 @@ FILE is the name of the file whose event is being 
reported."
        ;; A file name handler could exist even if there is no local
        ;; file notification support.
        (setq desc (funcall
-                   handler 'file-notify-add-watch dir flags callback))
+                   handler 'file-notify-add-watch
+                    ;; kqueue does not report file changes in
+                    ;; directory monitor.  So we must watch the file
+                    ;; itself.
+                    (if (eq file-notify--library 'kqueue) file dir)
+                    flags callback))
 
       ;; Check, whether Emacs has been compiled with file notification
       ;; support.
@@ -349,8 +361,9 @@ FILE is the name of the file whose event is being reported."
       ;; Determine low-level function to be called.
       (setq func
            (cond
-            ((eq file-notify--library 'gfilenotify) 'gfile-add-watch)
             ((eq file-notify--library 'inotify) 'inotify-add-watch)
+            ((eq file-notify--library 'kqueue) 'kqueue-add-watch)
+            ((eq file-notify--library 'gfilenotify) 'gfile-add-watch)
             ((eq file-notify--library 'w32notify) 'w32notify-add-watch)))
 
       ;; Determine respective flags.
@@ -362,30 +375,32 @@ FILE is the name of the file whose event is being 
reported."
           (cond
            ((eq file-notify--library 'inotify)
             '(create delete delete-self modify move-self move))
+           ((eq file-notify--library 'kqueue)
+            '(create delete write extend rename))
            ((eq file-notify--library 'w32notify)
             '(file-name directory-name size last-write-time)))))
        (when (memq 'attribute-change flags)
          (push (cond
                  ((eq file-notify--library 'inotify) 'attrib)
+                 ((eq file-notify--library 'kqueue) 'attrib)
                  ((eq file-notify--library 'w32notify) 'attributes))
                 l-flags)))
 
       ;; Call low-level function.
-      (setq desc (funcall func dir l-flags 'file-notify-callback)))
+      (setq desc (funcall
+                  func (if (eq file-notify--library 'kqueue) file dir)
+                  l-flags 'file-notify-callback)))
 
     ;; Modify `file-notify-descriptors'.
-    (setq registered (gethash desc file-notify-descriptors))
-    (puthash
-     desc
-     `(,dir
-       (,(unless (file-directory-p file) (file-name-nondirectory file))
-       . ,callback)
-       . ,(cdr registered))
-     file-notify-descriptors)
+    (setq file (unless (file-directory-p file) (file-name-nondirectory file))
+         desc (if (consp desc) (car desc) desc)
+         registered (gethash desc file-notify-descriptors)
+         entry `(,file . ,callback))
+    (unless (member entry (cdr registered))
+      (puthash desc `(,dir ,entry . ,(cdr registered)) 
file-notify-descriptors))
 
     ;; Return descriptor.
-    (file-notify--descriptor
-     desc (unless (file-directory-p file) (file-name-nondirectory file)))))
+    (file-notify--descriptor desc file)))
 
 (defun file-notify-rm-watch (descriptor)
   "Remove an existing watch specified by its DESCRIPTOR.
@@ -410,8 +425,9 @@ DESCRIPTOR should be an object returned by 
`file-notify-add-watch'."
 
               (funcall
                (cond
-                ((eq file-notify--library 'gfilenotify) 'gfile-rm-watch)
                 ((eq file-notify--library 'inotify) 'inotify-rm-watch)
+                ((eq file-notify--library 'kqueue) 'kqueue-rm-watch)
+                ((eq file-notify--library 'gfilenotify) 'gfile-rm-watch)
                 ((eq file-notify--library 'w32notify) 'w32notify-rm-watch))
                desc))
           (file-notify-error nil)))
@@ -441,8 +457,9 @@ DESCRIPTOR should be an object returned by 
`file-notify-add-watch'."
                (funcall handler 'file-notify-valid-p descriptor)
              (funcall
               (cond
-               ((eq file-notify--library 'gfilenotify) 'gfile-valid-p)
                ((eq file-notify--library 'inotify) 'inotify-valid-p)
+               ((eq file-notify--library 'kqueue) 'kqueue-valid-p)
+               ((eq file-notify--library 'gfilenotify) 'gfile-valid-p)
                ((eq file-notify--library 'w32notify) 'w32notify-valid-p))
               desc))
            t))))
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index e6d6a3e..8ef9c27 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -658,7 +658,12 @@ was inserted."
                           (not (and (boundp 'archive-superior-buffer)
                                     archive-superior-buffer))
                           (not (and (boundp 'tar-superior-buffer)
-                                    tar-superior-buffer)))))
+                                    tar-superior-buffer))
+                           ;; This means the buffer holds the
+                           ;; decrypted content (bug#21870).
+                           (not (and (boundp 'epa-file-encrypt-to)
+                                     (local-variable-p
+                                      'epa-file-encrypt-to))))))
         (file-or-data (if data-p
                           (string-make-unibyte
                            (buffer-substring-no-properties (point-min) 
(point-max)))
diff --git a/lisp/ldefs-boot.el b/lisp/ldefs-boot.el
index d8f627a..4691056 100644
--- a/lisp/ldefs-boot.el
+++ b/lisp/ldefs-boot.el
@@ -1153,8 +1153,8 @@ Returns list of symbols and documentation found.
 
 ;;;***
 
-;;;### (autoloads nil "arc-mode" "arc-mode.el" (22027 46774 644310
-;;;;;;  591000))
+;;;### (autoloads nil "arc-mode" "arc-mode.el" (22085 50883 177731
+;;;;;;  271000))
 ;;; Generated autoloads from arc-mode.el
 
 (autoload 'archive-mode "arc-mode" "\
@@ -2123,14 +2123,15 @@ a reflection.
 
 ;;;***
 
-;;;### (autoloads nil "bookmark" "bookmark.el" (22011 58553 109858
-;;;;;;  469000))
+;;;### (autoloads nil "bookmark" "bookmark.el" (22081 53819 631137
+;;;;;;  351000))
 ;;; Generated autoloads from bookmark.el
  (define-key ctl-x-r-map "b" 'bookmark-jump)
  (define-key ctl-x-r-map "m" 'bookmark-set)
+ (define-key ctl-x-r-map "M" 'bookmark-set-no-overwrite)
  (define-key ctl-x-r-map "l" 'bookmark-bmenu-list)
 
-(defvar bookmark-map (let ((map (make-sparse-keymap))) (define-key map "x" 
'bookmark-set) (define-key map "m" 'bookmark-set) (define-key map "j" 
'bookmark-jump) (define-key map "g" 'bookmark-jump) (define-key map "o" 
'bookmark-jump-other-window) (define-key map "i" 'bookmark-insert) (define-key 
map "e" 'edit-bookmarks) (define-key map "f" 'bookmark-insert-location) 
(define-key map "r" 'bookmark-rename) (define-key map "d" 'bookmark-delete) 
(define-key map "l" 'bookmark-load) (define-key  [...]
+(defvar bookmark-map (let ((map (make-sparse-keymap))) (define-key map "x" 
'bookmark-set) (define-key map "m" 'bookmark-set) (define-key map "M" 
'bookmark-set-no-overwrite) (define-key map "j" 'bookmark-jump) (define-key map 
"g" 'bookmark-jump) (define-key map "o" 'bookmark-jump-other-window) 
(define-key map "i" 'bookmark-insert) (define-key map "e" 'edit-bookmarks) 
(define-key map "f" 'bookmark-insert-location) (define-key map "r" 
'bookmark-rename) (define-key map "d" 'bookmark-delete)  [...]
 Keymap containing bindings to bookmark functions.
 It is not bound to any key by default: to bind it
 so that you have a bookmark prefix, just use `global-set-key' and bind a
@@ -2140,7 +2141,7 @@ functions have a binding in this keymap.")
 
 (autoload 'bookmark-set "bookmark" "\
 Set a bookmark named NAME at the current location.
-If name is nil, then prompt the user.
+If NAME is nil, then prompt the user.
 
 With a prefix arg (non-nil NO-OVERWRITE), do not overwrite any
 existing bookmark that has the same name as NAME, but instead push the
@@ -2165,6 +2166,36 @@ the list of bookmarks.)
 
 \(fn &optional NAME NO-OVERWRITE)" t nil)
 
+(autoload 'bookmark-set-no-overwrite "bookmark" "\
+Set a bookmark named NAME at the current location.
+If NAME is nil, then prompt the user.
+
+If a bookmark named NAME already exists and prefix argument
+PUSH-BOOKMARK is non-nil, then push the new bookmark onto the
+bookmark alist.  Pushing it means that among bookmarks named
+NAME, this one becomes the one in effect, but the others are
+still there, in order, and become effective again if the user
+ever deletes the most recent one.
+
+Otherwise, if a bookmark named NAME already exists but PUSH-BOOKMARK
+is nil, raise an error.
+
+To yank words from the text of the buffer and use them as part of the
+bookmark name, type C-w while setting a bookmark.  Successive C-w's
+yank successive words.
+
+Typing C-u inserts (at the bookmark name prompt) the name of the last
+bookmark used in the document where the new bookmark is being set;
+this helps you use a single bookmark name to track progress through a
+large document.  If there is no prior bookmark for this document, then
+C-u inserts an appropriate name based on the buffer or file.
+
+Use \\[bookmark-delete] to remove bookmarks (you give it a name and
+it removes only the first instance of a bookmark with that name from
+the list of bookmarks.)
+
+\(fn &optional NAME PUSH-BOOKMARK)" t nil)
+
 (autoload 'bookmark-jump "bookmark" "\
 Jump to bookmark BOOKMARK (a point in some file).
 You may have a problem using this function if the value of variable
@@ -2898,7 +2929,7 @@ from the cursor position.
 
 ;;;***
 
-;;;### (autoloads nil "calc" "calc/calc.el" (22039 37934 737599 199000))
+;;;### (autoloads nil "calc" "calc/calc.el" (22073 59712 746803 451000))
 ;;; Generated autoloads from calc/calc.el
  (define-key ctl-x-map "*" 'calc-dispatch)
 
@@ -2984,8 +3015,8 @@ See Info node `(calc)Defining Functions'.
 
 ;;;***
 
-;;;### (autoloads nil "calc-undo" "calc/calc-undo.el" (21670 32330
-;;;;;;  885624 725000))
+;;;### (autoloads nil "calc-undo" "calc/calc-undo.el" (22073 59712
+;;;;;;  730803 451000))
 ;;; Generated autoloads from calc/calc-undo.el
 
 (autoload 'calc-undo "calc-undo" "\
@@ -2995,8 +3026,8 @@ See Info node `(calc)Defining Functions'.
 
 ;;;***
 
-;;;### (autoloads nil "calculator" "calculator.el" (21993 28595 966597
-;;;;;;  473000))
+;;;### (autoloads nil "calculator" "calculator.el" (22109 33223 416655
+;;;;;;  811000))
 ;;; Generated autoloads from calculator.el
 
 (autoload 'calculator "calculator" "\
@@ -3069,8 +3100,8 @@ it fails.
 
 ;;;***
 
-;;;### (autoloads nil "cc-engine" "progmodes/cc-engine.el" (22011
-;;;;;;  58553 881858 469000))
+;;;### (autoloads nil "cc-engine" "progmodes/cc-engine.el" (22084
+;;;;;;  30014 95762 3000))
 ;;; Generated autoloads from progmodes/cc-engine.el
 
 (autoload 'c-guess-basic-syntax "cc-engine" "\
@@ -3179,8 +3210,8 @@ the absolute file name of the file if STYLE-NAME is nil.
 
 ;;;***
 
-;;;### (autoloads nil "cc-mode" "progmodes/cc-mode.el" (22040 58794
-;;;;;;  688259 771000))
+;;;### (autoloads nil "cc-mode" "progmodes/cc-mode.el" (22084 30014
+;;;;;;  99762 3000))
 ;;; Generated autoloads from progmodes/cc-mode.el
 
 (autoload 'c-initialize-cc-mode "cc-mode" "\
@@ -5117,8 +5148,8 @@ Enable CUA selection mode without the C-z/C-x/C-c/C-v 
bindings.
 
 ;;;***
 
-;;;### (autoloads nil "cua-rect" "emulation/cua-rect.el" (21670 32330
-;;;;;;  885624 725000))
+;;;### (autoloads nil "cua-rect" "emulation/cua-rect.el" (22087 6213
+;;;;;;  764351 952000))
 ;;; Generated autoloads from emulation/cua-rect.el
 
 (autoload 'cua-rectangle-mark-mode "cua-rect" "\
@@ -5150,8 +5181,8 @@ entering the area covered by the text-property property 
or leaving it.
 
 ;;;***
 
-;;;### (autoloads nil "cus-edit" "cus-edit.el" (21993 28596 22597
-;;;;;;  473000))
+;;;### (autoloads nil "cus-edit" "cus-edit.el" (22087 6213 748351
+;;;;;;  952000))
 ;;; Generated autoloads from cus-edit.el
 
 (defvar custom-browse-sort-alphabetically nil "\
@@ -6367,8 +6398,8 @@ This requires the external program `diff' to be in your 
`exec-path'.
 
 ;;;***
 
-;;;### (autoloads nil "diff-mode" "vc/diff-mode.el" (22011 58554
-;;;;;;  89858 469000))
+;;;### (autoloads nil "diff-mode" "vc/diff-mode.el" (22087 6213 816351
+;;;;;;  952000))
 ;;; Generated autoloads from vc/diff-mode.el
 
 (autoload 'diff-mode "diff-mode" "\
@@ -6411,7 +6442,7 @@ Optional arguments are passed to `dig-invoke'.
 
 ;;;***
 
-;;;### (autoloads nil "dired" "dired.el" (22067 17342 118157 143000))
+;;;### (autoloads nil "dired" "dired.el" (22085 50883 181731 271000))
 ;;; Generated autoloads from dired.el
 
 (defvar dired-listing-switches (purecopy "-al") "\
@@ -8118,15 +8149,15 @@ BUFFER is put back into its original major mode.
 
 ;;;***
 
-;;;### (autoloads nil "eieio" "emacs-lisp/eieio.el" (21998 46624
-;;;;;;  898024 649000))
+;;;### (autoloads nil "eieio" "emacs-lisp/eieio.el" (22102 59970
+;;;;;;  680776 103000))
 ;;; Generated autoloads from emacs-lisp/eieio.el
 (push (purecopy '(eieio 1 4)) package--builtin-versions)
 
 ;;;***
 
-;;;### (autoloads nil "eieio-core" "emacs-lisp/eieio-core.el" (22067
-;;;;;;  17342 150157 143000))
+;;;### (autoloads nil "eieio-core" "emacs-lisp/eieio-core.el" (22102
+;;;;;;  59970 668776 103000))
 ;;; Generated autoloads from emacs-lisp/eieio-core.el
 (push (purecopy '(eieio-core 1 4)) package--builtin-versions)
 
@@ -8410,7 +8441,7 @@ Commands:
 
 ;;;***
 
-;;;### (autoloads nil "epa" "epa.el" (21980 16567 517544 893000))
+;;;### (autoloads nil "epa" "epa.el" (22093 44991 758016 539000))
 ;;; Generated autoloads from epa.el
 
 (autoload 'epa-list-keys "epa" "\
@@ -8723,7 +8754,7 @@ if ARG is omitted or nil.
 
 ;;;***
 
-;;;### (autoloads nil "epg" "epg.el" (22011 58553 461858 469000))
+;;;### (autoloads nil "epg" "epg.el" (22076 35900 86633 595000))
 ;;; Generated autoloads from epg.el
 (push (purecopy '(epg 1 0 0)) package--builtin-versions)
 
@@ -9132,8 +9163,8 @@ with args, toggle notify status of people.
 
 ;;;***
 
-;;;### (autoloads nil "erc-pcomplete" "erc/erc-pcomplete.el" (21855
-;;;;;;  576 787951 155000))
+;;;### (autoloads nil "erc-pcomplete" "erc/erc-pcomplete.el" (22079
+;;;;;;  12092 327174 267000))
 ;;; Generated autoloads from erc/erc-pcomplete.el
  (autoload 'erc-completion-mode "erc-pcomplete" nil t)
 
@@ -9392,8 +9423,8 @@ corresponding to a successful execution.
 
 ;;;***
 
-;;;### (autoloads nil "etags" "progmodes/etags.el" (21998 46517 206024
-;;;;;;  649000))
+;;;### (autoloads nil "etags" "progmodes/etags.el" (22087 6213 768351
+;;;;;;  952000))
 ;;; Generated autoloads from progmodes/etags.el
 
 (defvar tags-file-name nil "\
@@ -9703,11 +9734,6 @@ for \\[find-tag] (which see).
 
 \(fn)" t nil)
 
-(autoload 'etags-xref-find "etags" "\
-
-
-\(fn ACTION ID)" nil nil)
-
 ;;;***
 
 ;;;### (autoloads nil "ethio-util" "language/ethio-util.el" (21862
@@ -10156,8 +10182,8 @@ This is used only in conjunction with 
`expand-add-abbrevs'.
 
 ;;;***
 
-;;;### (autoloads nil "f90" "progmodes/f90.el" (22026 25907 635502
-;;;;;;  692000))
+;;;### (autoloads nil "f90" "progmodes/f90.el" (22071 17982 246921
+;;;;;;  531000))
 ;;; Generated autoloads from progmodes/f90.el
 
 (autoload 'f90-mode "f90" "\
@@ -10560,8 +10586,8 @@ the name is considered already unique; only the second 
substitution
 
 ;;;***
 
-;;;### (autoloads nil "filenotify" "filenotify.el" (22069 62806 562804
-;;;;;;  836000))
+;;;### (autoloads nil "filenotify" "filenotify.el" (22102 59970 680776
+;;;;;;  103000))
 ;;; Generated autoloads from filenotify.el
 
 (autoload 'file-notify-handle-event "filenotify" "\
@@ -10576,7 +10602,7 @@ Otherwise, signal a `file-notify-error'.
 
 ;;;***
 
-;;;### (autoloads nil "files-x" "files-x.el" (21998 46517 38024 649000))
+;;;### (autoloads nil "files-x" "files-x.el" (22083 9150 136915 960000))
 ;;; Generated autoloads from files-x.el
 
 (autoload 'add-file-local-variable "files-x" "\
@@ -12618,8 +12644,8 @@ Declare back end NAME with ABILITIES as a Gnus back end.
 
 ;;;***
 
-;;;### (autoloads nil "gnus-sum" "gnus/gnus-sum.el" (21993 28596
-;;;;;;  110597 473000))
+;;;### (autoloads nil "gnus-sum" "gnus/gnus-sum.el" (22080 32958
+;;;;;;  2580 652000))
 ;;; Generated autoloads from gnus/gnus-sum.el
 
 (autoload 'gnus-summary-bookmark-jump "gnus-sum" "\
@@ -13357,8 +13383,8 @@ different regions.  With numeric argument ARG, behaves 
like
 
 ;;;***
 
-;;;### (autoloads nil "help-fns" "help-fns.el" (22067 17342 162157
-;;;;;;  143000))
+;;;### (autoloads nil "help-fns" "help-fns.el" (22083 9150 144915
+;;;;;;  960000))
 ;;; Generated autoloads from help-fns.el
 
 (autoload 'describe-function "help-fns" "\
@@ -13575,7 +13601,7 @@ Provide help for current mode.
 
 ;;;***
 
-;;;### (autoloads nil "hexl" "hexl.el" (22056 47028 723798 795000))
+;;;### (autoloads nil "hexl" "hexl.el" (22079 12092 331174 267000))
 ;;; Generated autoloads from hexl.el
 
 (autoload 'hexl-mode "hexl" "\
@@ -13601,7 +13627,7 @@ in hexl format.
 
 A sample format:
 
-  HEX ADDR: 0001 0203 0405 0607 0809 0a0b 0c0d 0e0f     ASCII-TEXT
+  HEX ADDR: 0011 2233 4455 6677 8899 aabb ccdd eeff     ASCII-TEXT
   --------  ---- ---- ---- ---- ---- ---- ---- ----  ----------------
   00000000: 5468 6973 2069 7320 6865 786c 2d6d 6f64  This is hexl-mod
   00000010: 652e 2020 4561 6368 206c 696e 6520 7265  e.  Each line re
@@ -15437,8 +15463,8 @@ An image file is one whose name has an extension in
 
 ;;;***
 
-;;;### (autoloads nil "image-mode" "image-mode.el" (21716 41663 456033
-;;;;;;  27000))
+;;;### (autoloads nil "image-mode" "image-mode.el" (22091 3267 895306
+;;;;;;  892000))
 ;;; Generated autoloads from image-mode.el
 
 (autoload 'image-mode "image-mode" "\
@@ -16590,7 +16616,7 @@ locally, like so:
 
 ;;;***
 
-;;;### (autoloads nil "json" "json.el" (22064 41137 993468 395000))
+;;;### (autoloads nil "json" "json.el" (22085 50883 185731 271000))
 ;;; Generated autoloads from json.el
 (push (purecopy '(json 1 4)) package--builtin-versions)
 
@@ -17000,7 +17026,7 @@ generations (this defaults to 1).
 
 ;;;***
 
-;;;### (autoloads nil "linum" "linum.el" (21855 577 57945 485000))
+;;;### (autoloads nil "linum" "linum.el" (22092 24132 128832 464000))
 ;;; Generated autoloads from linum.el
 (push (purecopy '(linum 0 9 24)) package--builtin-versions)
 
@@ -17823,8 +17849,8 @@ Default bookmark handler for Man buffers.
 
 ;;;***
 
-;;;### (autoloads nil "map" "emacs-lisp/map.el" (22063 20273 739891
-;;;;;;  395000))
+;;;### (autoloads nil "map" "emacs-lisp/map.el" (22084 30014 55762
+;;;;;;  3000))
 ;;; Generated autoloads from emacs-lisp/map.el
 (push (purecopy '(map 1 0)) package--builtin-versions)
 
@@ -18547,8 +18573,8 @@ If NO-DISPLAY is nil, display it. Otherwise, do nothing 
after replacing.
 
 ;;;***
 
-;;;### (autoloads nil "mm-url" "gnus/mm-url.el" (21670 32331 385639
-;;;;;;  720000))
+;;;### (autoloads nil "mm-url" "gnus/mm-url.el" (22084 30014 55762
+;;;;;;  3000))
 ;;; Generated autoloads from gnus/mm-url.el
 
 (autoload 'mm-url-insert-file-contents "mm-url" "\
@@ -18782,7 +18808,7 @@ To test this function, evaluate:
 
 ;;;***
 
-;;;### (autoloads nil "mpc" "mpc.el" (22050 8240 94934 108000))
+;;;### (autoloads nil "mpc" "mpc.el" (22093 44991 770016 539000))
 ;;; Generated autoloads from mpc.el
 
 (autoload 'mpc "mpc" "\
@@ -20349,8 +20375,8 @@ See the command `outline-mode' for more information on 
this mode.
 
 ;;;***
 
-;;;### (autoloads nil "package" "emacs-lisp/package.el" (22059 23214
-;;;;;;  33660 839000))
+;;;### (autoloads nil "package" "emacs-lisp/package.el" (22104 15298
+;;;;;;  466671 488000))
 ;;; Generated autoloads from emacs-lisp/package.el
 (push (purecopy '(package 1 0 1)) package--builtin-versions)
 
@@ -20577,12 +20603,12 @@ Check if KEY is in the cache.
 
 ;;;***
 
-;;;### (autoloads nil "pcase" "emacs-lisp/pcase.el" (22026 25907
-;;;;;;  583502 692000))
+;;;### (autoloads nil "pcase" "emacs-lisp/pcase.el" (22073 59712
+;;;;;;  774803 451000))
 ;;; Generated autoloads from emacs-lisp/pcase.el
 
 (autoload 'pcase "pcase" "\
-Perform ML-style pattern matching on EXP.
+Eval EXP and perform ML-style pattern matching on that value.
 CASES is a list of elements of the form (PATTERN CODE...).
 
 Patterns can take the following forms:
@@ -20590,7 +20616,7 @@ Patterns can take the following forms:
   SYMBOL       matches anything and binds it to SYMBOL.
   (or PAT...)  matches if any of the patterns matches.
   (and PAT...) matches if all the patterns match.
-  \\='VAL              matches if the object is `equal' to VAL
+  \\='VAL              matches if the object is `equal' to VAL.
   ATOM         is a shorthand for \\='ATOM.
                   ATOM can be a keyword, an integer, or a string.
   (pred FUN)   matches if FUN applied to the object returns non-nil.
@@ -20606,11 +20632,11 @@ FUN can take the form
                         which is the value being matched.
 So a FUN of the form SYMBOL is equivalent to one of the form (FUN).
 FUN can refer to variables bound earlier in the pattern.
-FUN is assumed to be pure, i.e. it can be dropped if its result is not used,
-and two identical calls can be merged into one.
 E.g. you can match pairs where the cdr is larger than the car with a pattern
 like \\=`(,a . ,(pred (< a))) or, with more checks:
 \\=`(,(and a (pred numberp)) . ,(and (pred numberp) (pred (< a))))
+FUN is assumed to be pure, i.e. it can be dropped if its result is not used,
+and two identical calls can be merged into one.
 
 Additional patterns can be defined via `pcase-defmacro'.
 Currently, the following patterns are provided this way:
@@ -21116,8 +21142,8 @@ they are not by default assigned to keys.
 
 ;;;***
 
-;;;### (autoloads nil "pinentry" "net/pinentry.el" (21972 22452 338264
-;;;;;;  357000))
+;;;### (autoloads nil "pinentry" "net/pinentry.el" (22076 35900 90633
+;;;;;;  595000))
 ;;; Generated autoloads from net/pinentry.el
 (push (purecopy '(pinentry 0 1)) package--builtin-versions)
 
@@ -21127,7 +21153,10 @@ Start a Pinentry service.
 Once the environment is properly set, subsequent invocations of
 the gpg command will interact with Emacs for passphrase input.
 
-\(fn)" t nil)
+If the optional QUIET argument is non-nil, messages at startup
+will not be shown.
+
+\(fn &optional QUIET)" t nil)
 
 ;;;***
 
@@ -21826,7 +21855,7 @@ are both set to t.
 
 ;;;***
 
-;;;### (autoloads nil "proced" "proced.el" (21998 46517 190024 649000))
+;;;### (autoloads nil "proced" "proced.el" (22085 50883 209731 271000))
 ;;; Generated autoloads from proced.el
 
 (autoload 'proced "proced" "\
@@ -21873,14 +21902,30 @@ Open profile FILENAME.
 
 ;;;***
 
-;;;### (autoloads nil "project" "progmodes/project.el" (21960 31281
-;;;;;;  344212 153000))
+;;;### (autoloads nil "project" "progmodes/project.el" (22083 9150
+;;;;;;  180915 960000))
 ;;; Generated autoloads from progmodes/project.el
 
 (autoload 'project-current "project" "\
 Return the project instance in DIR or `default-directory'.
+When no project found in DIR, and MAYBE-PROMPT is non-nil, ask
+the user for a different directory to look in.
 
-\(fn &optional DIR)" nil nil)
+\(fn &optional MAYBE-PROMPT DIR)" nil nil)
+
+(autoload 'project-find-regexp "project" "\
+Find all matches for REGEXP in the current project.
+With \\[universal-argument] prefix, you can specify the directory
+to search in, and the file name pattern to search for.
+
+\(fn REGEXP)" t nil)
+
+(autoload 'project-or-libraries-find-regexp "project" "\
+Find all matches for REGEXP in the current project or libraries.
+With \\[universal-argument] prefix, you can specify the file name
+pattern to search for.
+
+\(fn REGEXP)" t nil)
 
 ;;;***
 
@@ -22666,7 +22711,7 @@ were operated on recently.
 
 ;;;***
 
-;;;### (autoloads nil "rect" "rect.el" (21803 38823 44085 519000))
+;;;### (autoloads nil "rect" "rect.el" (22087 6213 796351 952000))
 ;;; Generated autoloads from rect.el
 
 (autoload 'delete-rectangle "rect" "\
@@ -24487,10 +24532,10 @@ Like `mail' command, but display mail buffer in 
another frame.
 
 ;;;***
 
-;;;### (autoloads nil "seq" "emacs-lisp/seq.el" (22065 61995 842407
-;;;;;;  852000))
+;;;### (autoloads nil "seq" "emacs-lisp/seq.el" (22084 30014 55762
+;;;;;;  3000))
 ;;; Generated autoloads from emacs-lisp/seq.el
-(push (purecopy '(seq 2 2)) package--builtin-versions)
+(push (purecopy '(seq 2 3)) package--builtin-versions)
 
 ;;;***
 
@@ -24872,7 +24917,7 @@ Otherwise, one argument `-i' is passed to the shell.
 
 ;;;***
 
-;;;### (autoloads nil "shr" "net/shr.el" (22047 32042 328736 723000))
+;;;### (autoloads nil "shr" "net/shr.el" (22085 50883 205731 271000))
 ;;; Generated autoloads from net/shr.el
 
 (autoload 'shr-render-region "shr" "\
@@ -25216,17 +25261,10 @@ then `snmpv2-mode-hook'.
 
 ;;;***
 
-;;;### (autoloads nil "soap-client" "net/soap-client.el" (22061 64938
-;;;;;;  516287 963000))
+;;;### (autoloads nil "soap-client" "net/soap-client.el" (22084 30014
+;;;;;;  59762 3000))
 ;;; Generated autoloads from net/soap-client.el
-(push (purecopy '(soap-client 3 0 1)) package--builtin-versions)
-
-;;;***
-
-;;;### (autoloads nil "soap-inspect" "net/soap-inspect.el" (22061
-;;;;;;  64938 516287 963000))
-;;; Generated autoloads from net/soap-inspect.el
-(push (purecopy '(soap-client 3 0 1)) package--builtin-versions)
+(push (purecopy '(soap-client 3 0 2)) package--builtin-versions)
 
 ;;;***
 
@@ -27190,8 +27228,8 @@ tetris-mode keybindings:
 
 ;;;***
 
-;;;### (autoloads nil "tex-mode" "textmodes/tex-mode.el" (22064 41138
-;;;;;;  13468 395000))
+;;;### (autoloads nil "tex-mode" "textmodes/tex-mode.el" (22076 35900
+;;;;;;  118633 595000))
 ;;; Generated autoloads from textmodes/tex-mode.el
 
 (defvar tex-shell-file-name nil "\
@@ -28473,7 +28511,7 @@ the output buffer or changing the window configuration.
 
 ;;;***
 
-;;;### (autoloads nil "tramp" "net/tramp.el" (22064 41138 9468 395000))
+;;;### (autoloads nil "tramp" "net/tramp.el" (22083 9150 180915 960000))
 ;;; Generated autoloads from net/tramp.el
 
 (defvar tramp-mode t "\
@@ -29140,8 +29178,8 @@ overriding the value of `url-gateway-method'.
 
 ;;;***
 
-;;;### (autoloads nil "url-handlers" "url/url-handlers.el" (22065
-;;;;;;  61995 878407 852000))
+;;;### (autoloads nil "url-handlers" "url/url-handlers.el" (22089
+;;;;;;  47939 367694 315000))
 ;;; Generated autoloads from url/url-handlers.el
 
 (defvar url-handler-mode nil "\
@@ -29694,7 +29732,7 @@ If FILE-NAME is non-nil, save the result to FILE-NAME.
 
 ;;;***
 
-;;;### (autoloads nil "vc" "vc/vc.el" (22014 34736 871840 613000))
+;;;### (autoloads nil "vc" "vc/vc.el" (22083 9150 184915 960000))
 ;;; Generated autoloads from vc/vc.el
 
 (defvar vc-checkout-hook nil "\
@@ -29846,6 +29884,11 @@ changes from the current branch.
 
 \(fn)" t nil)
 
+(autoload 'vc-message-unresolved-conflicts "vc" "\
+Display a message indicating unresolved conflicts in FILENAME.
+
+\(fn FILENAME)" nil nil)
+
 (defalias 'vc-resolve-conflicts 'smerge-ediff)
 
 (autoload 'vc-create-tag "vc" "\
@@ -30041,8 +30084,8 @@ should be applied to the background or to the 
foreground.
 
 ;;;***
 
-;;;### (autoloads nil "vc-bzr" "vc/vc-bzr.el" (22064 41138 13468
-;;;;;;  395000))
+;;;### (autoloads nil "vc-bzr" "vc/vc-bzr.el" (22081 53819 655137
+;;;;;;  351000))
 ;;; Generated autoloads from vc/vc-bzr.el
 
 (defconst vc-bzr-admin-dirname ".bzr" "\
@@ -30070,8 +30113,8 @@ Name of the format file in a .bzr directory.")
 
 ;;;***
 
-;;;### (autoloads nil "vc-dir" "vc/vc-dir.el" (22055 26158 818447
-;;;;;;  352000))
+;;;### (autoloads nil "vc-dir" "vc/vc-dir.el" (22085 50883 245731
+;;;;;;  271000))
 ;;; Generated autoloads from vc/vc-dir.el
 
 (autoload 'vc-dir "vc-dir" "\
@@ -30119,8 +30162,8 @@ case, and the process object in the asynchronous case.
 
 ;;;***
 
-;;;### (autoloads nil "vc-git" "vc/vc-git.el" (22064 41138 17468
-;;;;;;  395000))
+;;;### (autoloads nil "vc-git" "vc/vc-git.el" (22081 53819 659137
+;;;;;;  351000))
 ;;; Generated autoloads from vc/vc-git.el
  (defun vc-git-registered (file)
   "Return non-nil if FILE is registered with git."
@@ -30131,7 +30174,7 @@ case, and the process object in the asynchronous case.
 
 ;;;***
 
-;;;### (autoloads nil "vc-hg" "vc/vc-hg.el" (22064 41138 21468 395000))
+;;;### (autoloads nil "vc-hg" "vc/vc-hg.el" (22081 53819 659137 351000))
 ;;; Generated autoloads from vc/vc-hg.el
  (defun vc-hg-registered (file)
   "Return non-nil if FILE is registered with hg."
@@ -30206,8 +30249,8 @@ For a description of possible values, see 
`vc-check-master-templates'.")
 
 ;;;***
 
-;;;### (autoloads nil "vc-svn" "vc/vc-svn.el" (22064 41138 21468
-;;;;;;  395000))
+;;;### (autoloads nil "vc-svn" "vc/vc-svn.el" (22081 53819 663137
+;;;;;;  351000))
 ;;; Generated autoloads from vc/vc-svn.el
  (defun vc-svn-registered (f)
   (let ((admin-dir (cond ((and (eq system-type 'windows-nt)
@@ -30280,7 +30323,7 @@ Key bindings:
 ;;;***
 
 ;;;### (autoloads nil "verilog-mode" "progmodes/verilog-mode.el"
-;;;;;;  (22015 55603 833705 321000))
+;;;;;;  (22097 42046 455599 456000))
 ;;; Generated autoloads from progmodes/verilog-mode.el
 
 (autoload 'verilog-mode "verilog-mode" "\
@@ -31419,8 +31462,8 @@ Please submit bug reports and other feedback to the 
author, Neil W. Van Dyke
 
 ;;;***
 
-;;;### (autoloads nil "which-func" "progmodes/which-func.el" (21986
-;;;;;;  55346 292512 613000))
+;;;### (autoloads nil "which-func" "progmodes/which-func.el" (22109
+;;;;;;  33223 420655 811000))
 ;;; Generated autoloads from progmodes/which-func.el
  (put 'which-func-format 'risky-local-variable t)
  (put 'which-func-current 'risky-local-variable t)
@@ -32091,8 +32134,8 @@ If LIMIT is non-nil, then do not consider characters 
beyond LIMIT.
 
 ;;;***
 
-;;;### (autoloads nil "xref" "progmodes/xref.el" (21993 28596 366597
-;;;;;;  473000))
+;;;### (autoloads nil "xref" "progmodes/xref.el" (22087 6213 784351
+;;;;;;  952000))
 ;;; Generated autoloads from progmodes/xref.el
 
 (autoload 'xref-pop-marker-stack "xref" "\
@@ -32135,13 +32178,6 @@ With prefix argument, prompt for the identifier.
 
 \(fn IDENTIFIER)" t nil)
 
-(autoload 'xref-find-regexp "xref" "\
-Find all matches for REGEXP.
-With \\[universal-argument] prefix, you can specify the directory
-to search in, and the file name pattern to search for.
-
-\(fn REGEXP)" t nil)
-
 (autoload 'xref-find-apropos "xref" "\
 Find all meaningful symbols that match PATTERN.
 The argument has the same meaning as in `apropos'.
@@ -32217,37 +32253,37 @@ Zone out, completely.
 ;;;;;;  "calc/calc-fin.el" "calc/calc-forms.el" "calc/calc-frac.el"
 ;;;;;;  "calc/calc-funcs.el" "calc/calc-graph.el" "calc/calc-help.el"
 ;;;;;;  "calc/calc-incom.el" "calc/calc-keypd.el" "calc/calc-lang.el"
-;;;;;;  "calc/calc-macs.el" "calc/calc-map.el" "calc/calc-math.el"
-;;;;;;  "calc/calc-menu.el" "calc/calc-misc.el" "calc/calc-mode.el"
-;;;;;;  "calc/calc-mtx.el" "calc/calc-nlfit.el" "calc/calc-poly.el"
-;;;;;;  "calc/calc-prog.el" "calc/calc-rewr.el" "calc/calc-rules.el"
-;;;;;;  "calc/calc-sel.el" "calc/calc-stat.el" "calc/calc-store.el"
-;;;;;;  "calc/calc-stuff.el" "calc/calc-trail.el" "calc/calc-units.el"
-;;;;;;  "calc/calc-vec.el" "calc/calc-yank.el" "calc/calcalg2.el"
-;;;;;;  "calc/calcalg3.el" "calc/calccomp.el" "calc/calcsel2.el"
-;;;;;;  "calendar/cal-bahai.el" "calendar/cal-coptic.el" 
"calendar/cal-french.el"
-;;;;;;  "calendar/cal-html.el" "calendar/cal-islam.el" "calendar/cal-iso.el"
-;;;;;;  "calendar/cal-julian.el" "calendar/cal-loaddefs.el" 
"calendar/cal-mayan.el"
-;;;;;;  "calendar/cal-menu.el" "calendar/cal-move.el" "calendar/cal-persia.el"
-;;;;;;  "calendar/cal-tex.el" "calendar/cal-x.el" "calendar/diary-loaddefs.el"
-;;;;;;  "calendar/hol-loaddefs.el" "cdl.el" "cedet/cedet-cscope.el"
-;;;;;;  "cedet/cedet-files.el" "cedet/cedet-global.el" "cedet/cedet-idutils.el"
-;;;;;;  "cedet/ede/auto.el" "cedet/ede/autoconf-edit.el" "cedet/ede/base.el"
-;;;;;;  "cedet/ede/config.el" "cedet/ede/cpp-root.el" "cedet/ede/custom.el"
-;;;;;;  "cedet/ede/detect.el" "cedet/ede/dired.el" "cedet/ede/emacs.el"
-;;;;;;  "cedet/ede/files.el" "cedet/ede/generic.el" "cedet/ede/linux.el"
-;;;;;;  "cedet/ede/locate.el" "cedet/ede/make.el" "cedet/ede/makefile-edit.el"
-;;;;;;  "cedet/ede/pconf.el" "cedet/ede/pmake.el" "cedet/ede/proj-archive.el"
-;;;;;;  "cedet/ede/proj-aux.el" "cedet/ede/proj-comp.el" 
"cedet/ede/proj-elisp.el"
-;;;;;;  "cedet/ede/proj-info.el" "cedet/ede/proj-misc.el" 
"cedet/ede/proj-obj.el"
-;;;;;;  "cedet/ede/proj-prog.el" "cedet/ede/proj-scheme.el" 
"cedet/ede/proj-shared.el"
-;;;;;;  "cedet/ede/proj.el" "cedet/ede/project-am.el" "cedet/ede/shell.el"
-;;;;;;  "cedet/ede/simple.el" "cedet/ede/source.el" "cedet/ede/speedbar.el"
-;;;;;;  "cedet/ede/srecode.el" "cedet/ede/system.el" "cedet/ede/util.el"
-;;;;;;  "cedet/semantic/analyze.el" "cedet/semantic/analyze/complete.el"
-;;;;;;  "cedet/semantic/analyze/debug.el" "cedet/semantic/analyze/fcn.el"
-;;;;;;  "cedet/semantic/analyze/refs.el" "cedet/semantic/bovine.el"
-;;;;;;  "cedet/semantic/bovine/c.el" "cedet/semantic/bovine/debug.el"
+;;;;;;  "calc/calc-loaddefs.el" "calc/calc-macs.el" "calc/calc-map.el"
+;;;;;;  "calc/calc-math.el" "calc/calc-menu.el" "calc/calc-misc.el"
+;;;;;;  "calc/calc-mode.el" "calc/calc-mtx.el" "calc/calc-nlfit.el"
+;;;;;;  "calc/calc-poly.el" "calc/calc-prog.el" "calc/calc-rewr.el"
+;;;;;;  "calc/calc-rules.el" "calc/calc-sel.el" "calc/calc-stat.el"
+;;;;;;  "calc/calc-store.el" "calc/calc-stuff.el" "calc/calc-trail.el"
+;;;;;;  "calc/calc-units.el" "calc/calc-vec.el" "calc/calc-yank.el"
+;;;;;;  "calc/calcalg2.el" "calc/calcalg3.el" "calc/calccomp.el"
+;;;;;;  "calc/calcsel2.el" "calendar/cal-bahai.el" "calendar/cal-coptic.el"
+;;;;;;  "calendar/cal-french.el" "calendar/cal-html.el" "calendar/cal-islam.el"
+;;;;;;  "calendar/cal-iso.el" "calendar/cal-julian.el" 
"calendar/cal-loaddefs.el"
+;;;;;;  "calendar/cal-mayan.el" "calendar/cal-menu.el" "calendar/cal-move.el"
+;;;;;;  "calendar/cal-persia.el" "calendar/cal-tex.el" "calendar/cal-x.el"
+;;;;;;  "calendar/diary-loaddefs.el" "calendar/hol-loaddefs.el" "cdl.el"
+;;;;;;  "cedet/cedet-cscope.el" "cedet/cedet-files.el" "cedet/cedet-global.el"
+;;;;;;  "cedet/cedet-idutils.el" "cedet/ede/auto.el" 
"cedet/ede/autoconf-edit.el"
+;;;;;;  "cedet/ede/base.el" "cedet/ede/config.el" "cedet/ede/cpp-root.el"
+;;;;;;  "cedet/ede/custom.el" "cedet/ede/detect.el" "cedet/ede/dired.el"
+;;;;;;  "cedet/ede/emacs.el" "cedet/ede/files.el" "cedet/ede/generic.el"
+;;;;;;  "cedet/ede/linux.el" "cedet/ede/loaddefs.el" "cedet/ede/locate.el"
+;;;;;;  "cedet/ede/make.el" "cedet/ede/makefile-edit.el" "cedet/ede/pconf.el"
+;;;;;;  "cedet/ede/pmake.el" "cedet/ede/proj-archive.el" 
"cedet/ede/proj-aux.el"
+;;;;;;  "cedet/ede/proj-comp.el" "cedet/ede/proj-elisp.el" 
"cedet/ede/proj-info.el"
+;;;;;;  "cedet/ede/proj-misc.el" "cedet/ede/proj-obj.el" 
"cedet/ede/proj-prog.el"
+;;;;;;  "cedet/ede/proj-scheme.el" "cedet/ede/proj-shared.el" 
"cedet/ede/proj.el"
+;;;;;;  "cedet/ede/project-am.el" "cedet/ede/shell.el" "cedet/ede/simple.el"
+;;;;;;  "cedet/ede/source.el" "cedet/ede/speedbar.el" "cedet/ede/srecode.el"
+;;;;;;  "cedet/ede/system.el" "cedet/ede/util.el" "cedet/semantic/analyze.el"
+;;;;;;  "cedet/semantic/analyze/complete.el" "cedet/semantic/analyze/debug.el"
+;;;;;;  "cedet/semantic/analyze/fcn.el" "cedet/semantic/analyze/refs.el"
+;;;;;;  "cedet/semantic/bovine.el" "cedet/semantic/bovine/c.el" 
"cedet/semantic/bovine/debug.el"
 ;;;;;;  "cedet/semantic/bovine/el.el" "cedet/semantic/bovine/gcc.el"
 ;;;;;;  "cedet/semantic/bovine/make.el" "cedet/semantic/bovine/scm.el"
 ;;;;;;  "cedet/semantic/chart.el" "cedet/semantic/complete.el" 
"cedet/semantic/ctxt.el"
@@ -32262,13 +32298,13 @@ Zone out, completely.
 ;;;;;;  "cedet/semantic/fw.el" "cedet/semantic/grammar-wy.el" 
"cedet/semantic/grammar.el"
 ;;;;;;  "cedet/semantic/html.el" "cedet/semantic/ia-sb.el" 
"cedet/semantic/ia.el"
 ;;;;;;  "cedet/semantic/idle.el" "cedet/semantic/imenu.el" 
"cedet/semantic/java.el"
-;;;;;;  "cedet/semantic/lex-spp.el" "cedet/semantic/lex.el" 
"cedet/semantic/mru-bookmark.el"
-;;;;;;  "cedet/semantic/sb.el" "cedet/semantic/scope.el" 
"cedet/semantic/senator.el"
-;;;;;;  "cedet/semantic/sort.el" "cedet/semantic/symref.el" 
"cedet/semantic/symref/cscope.el"
-;;;;;;  "cedet/semantic/symref/filter.el" "cedet/semantic/symref/global.el"
-;;;;;;  "cedet/semantic/symref/grep.el" "cedet/semantic/symref/idutils.el"
-;;;;;;  "cedet/semantic/symref/list.el" "cedet/semantic/tag-file.el"
-;;;;;;  "cedet/semantic/tag-ls.el" "cedet/semantic/tag-write.el"
+;;;;;;  "cedet/semantic/lex-spp.el" "cedet/semantic/lex.el" 
"cedet/semantic/loaddefs.el"
+;;;;;;  "cedet/semantic/mru-bookmark.el" "cedet/semantic/sb.el" 
"cedet/semantic/scope.el"
+;;;;;;  "cedet/semantic/senator.el" "cedet/semantic/sort.el" 
"cedet/semantic/symref.el"
+;;;;;;  "cedet/semantic/symref/cscope.el" "cedet/semantic/symref/filter.el"
+;;;;;;  "cedet/semantic/symref/global.el" "cedet/semantic/symref/grep.el"
+;;;;;;  "cedet/semantic/symref/idutils.el" "cedet/semantic/symref/list.el"
+;;;;;;  "cedet/semantic/tag-file.el" "cedet/semantic/tag-ls.el" 
"cedet/semantic/tag-write.el"
 ;;;;;;  "cedet/semantic/tag.el" "cedet/semantic/texi.el" 
"cedet/semantic/util-modes.el"
 ;;;;;;  "cedet/semantic/util.el" "cedet/semantic/wisent.el" 
"cedet/semantic/wisent/comp.el"
 ;;;;;;  "cedet/semantic/wisent/java-tags.el" 
"cedet/semantic/wisent/javascript.el"
@@ -32278,55 +32314,56 @@ Zone out, completely.
 ;;;;;;  "cedet/srecode/el.el" "cedet/srecode/expandproto.el" 
"cedet/srecode/extract.el"
 ;;;;;;  "cedet/srecode/fields.el" "cedet/srecode/filters.el" 
"cedet/srecode/find.el"
 ;;;;;;  "cedet/srecode/getset.el" "cedet/srecode/insert.el" 
"cedet/srecode/java.el"
-;;;;;;  "cedet/srecode/map.el" "cedet/srecode/mode.el" 
"cedet/srecode/semantic.el"
-;;;;;;  "cedet/srecode/srt.el" "cedet/srecode/table.el" 
"cedet/srecode/template.el"
-;;;;;;  "cedet/srecode/texi.el" "cus-dep.el" "dframe.el" "dired-aux.el"
-;;;;;;  "dired-x.el" "dom.el" "dos-fns.el" "dos-vars.el" "dos-w32.el"
-;;;;;;  "dynamic-setting.el" "emacs-lisp/avl-tree.el" "emacs-lisp/bindat.el"
-;;;;;;  "emacs-lisp/byte-opt.el" "emacs-lisp/cl-extra.el" 
"emacs-lisp/cl-macs.el"
-;;;;;;  "emacs-lisp/cl-seq.el" "emacs-lisp/cl.el" "emacs-lisp/eieio-base.el"
-;;;;;;  "emacs-lisp/eieio-compat.el" "emacs-lisp/eieio-custom.el"
-;;;;;;  "emacs-lisp/eieio-datadebug.el" "emacs-lisp/eieio-opt.el"
-;;;;;;  "emacs-lisp/eieio-speedbar.el" "emacs-lisp/generator.el"
-;;;;;;  "emacs-lisp/lisp-mnt.el" "emacs-lisp/package-x.el" "emacs-lisp/smie.el"
-;;;;;;  "emacs-lisp/subr-x.el" "emacs-lisp/tcover-ses.el" 
"emacs-lisp/tcover-unsafep.el"
-;;;;;;  "emulation/cua-gmrk.el" "emulation/edt-lk201.el" 
"emulation/edt-mapper.el"
-;;;;;;  "emulation/edt-pc.el" "emulation/edt-vt100.el" "emulation/viper-cmd.el"
-;;;;;;  "emulation/viper-ex.el" "emulation/viper-init.el" 
"emulation/viper-keym.el"
-;;;;;;  "emulation/viper-macs.el" "emulation/viper-mous.el" 
"emulation/viper-util.el"
-;;;;;;  "erc/erc-backend.el" "erc/erc-goodies.el" "erc/erc-ibuffer.el"
-;;;;;;  "erc/erc-lang.el" "eshell/em-alias.el" "eshell/em-banner.el"
-;;;;;;  "eshell/em-basic.el" "eshell/em-cmpl.el" "eshell/em-dirs.el"
-;;;;;;  "eshell/em-glob.el" "eshell/em-hist.el" "eshell/em-ls.el"
-;;;;;;  "eshell/em-pred.el" "eshell/em-prompt.el" "eshell/em-rebind.el"
-;;;;;;  "eshell/em-script.el" "eshell/em-smart.el" "eshell/em-term.el"
-;;;;;;  "eshell/em-tramp.el" "eshell/em-unix.el" "eshell/em-xtra.el"
-;;;;;;  "eshell/esh-arg.el" "eshell/esh-cmd.el" "eshell/esh-ext.el"
-;;;;;;  "eshell/esh-io.el" "eshell/esh-module.el" "eshell/esh-opt.el"
-;;;;;;  "eshell/esh-proc.el" "eshell/esh-util.el" "eshell/esh-var.el"
-;;;;;;  "ezimage.el" "format-spec.el" "fringe.el" "generic-x.el"
-;;;;;;  "gnus/compface.el" "gnus/gnus-async.el" "gnus/gnus-bcklg.el"
-;;;;;;  "gnus/gnus-cite.el" "gnus/gnus-cloud.el" "gnus/gnus-cus.el"
-;;;;;;  "gnus/gnus-demon.el" "gnus/gnus-dup.el" "gnus/gnus-eform.el"
-;;;;;;  "gnus/gnus-ems.el" "gnus/gnus-icalendar.el" "gnus/gnus-int.el"
-;;;;;;  "gnus/gnus-logic.el" "gnus/gnus-mh.el" "gnus/gnus-salt.el"
-;;;;;;  "gnus/gnus-score.el" "gnus/gnus-srvr.el" "gnus/gnus-topic.el"
-;;;;;;  "gnus/gnus-undo.el" "gnus/gnus-util.el" "gnus/gnus-uu.el"
-;;;;;;  "gnus/gnus-vm.el" "gnus/gssapi.el" "gnus/ietf-drums.el" 
"gnus/legacy-gnus-agent.el"
-;;;;;;  "gnus/mail-parse.el" "gnus/mail-prsvr.el" "gnus/mail-source.el"
-;;;;;;  "gnus/mailcap.el" "gnus/messcompat.el" "gnus/mm-archive.el"
-;;;;;;  "gnus/mm-bodies.el" "gnus/mm-decode.el" "gnus/mm-util.el"
-;;;;;;  "gnus/mm-view.el" "gnus/mml-sec.el" "gnus/mml-smime.el" 
"gnus/nnagent.el"
-;;;;;;  "gnus/nnbabyl.el" "gnus/nndir.el" "gnus/nndraft.el" "gnus/nneething.el"
-;;;;;;  "gnus/nngateway.el" "gnus/nnheader.el" "gnus/nnimap.el" "gnus/nnir.el"
-;;;;;;  "gnus/nnmail.el" "gnus/nnmaildir.el" "gnus/nnmairix.el" 
"gnus/nnmbox.el"
-;;;;;;  "gnus/nnmh.el" "gnus/nnnil.el" "gnus/nnoo.el" "gnus/nnregistry.el"
-;;;;;;  "gnus/nnrss.el" "gnus/nnspool.el" "gnus/nntp.el" "gnus/nnvirtual.el"
-;;;;;;  "gnus/nnweb.el" "gnus/registry.el" "gnus/rfc1843.el" "gnus/rfc2045.el"
-;;;;;;  "gnus/rfc2047.el" "gnus/rfc2231.el" "gnus/rtree.el" 
"gnus/sieve-manage.el"
-;;;;;;  "gnus/smime.el" "gnus/spam-stat.el" "gnus/spam-wash.el" "hex-util.el"
-;;;;;;  "hfy-cmap.el" "ibuf-ext.el" "international/charscript.el"
-;;;;;;  "international/fontset.el" "international/iso-ascii.el" 
"international/ja-dic-cnv.el"
+;;;;;;  "cedet/srecode/loaddefs.el" "cedet/srecode/map.el" 
"cedet/srecode/mode.el"
+;;;;;;  "cedet/srecode/semantic.el" "cedet/srecode/srt.el" 
"cedet/srecode/table.el"
+;;;;;;  "cedet/srecode/template.el" "cedet/srecode/texi.el" "cus-dep.el"
+;;;;;;  "dframe.el" "dired-aux.el" "dired-x.el" "dom.el" "dos-fns.el"
+;;;;;;  "dos-vars.el" "dos-w32.el" "dynamic-setting.el" 
"emacs-lisp/avl-tree.el"
+;;;;;;  "emacs-lisp/bindat.el" "emacs-lisp/byte-opt.el" 
"emacs-lisp/cl-extra.el"
+;;;;;;  "emacs-lisp/cl-loaddefs.el" "emacs-lisp/cl-macs.el" 
"emacs-lisp/cl-seq.el"
+;;;;;;  "emacs-lisp/cl.el" "emacs-lisp/eieio-base.el" 
"emacs-lisp/eieio-compat.el"
+;;;;;;  "emacs-lisp/eieio-custom.el" "emacs-lisp/eieio-datadebug.el"
+;;;;;;  "emacs-lisp/eieio-opt.el" "emacs-lisp/eieio-speedbar.el"
+;;;;;;  "emacs-lisp/generator.el" "emacs-lisp/lisp-mnt.el" 
"emacs-lisp/package-x.el"
+;;;;;;  "emacs-lisp/smie.el" "emacs-lisp/subr-x.el" "emacs-lisp/tcover-ses.el"
+;;;;;;  "emacs-lisp/tcover-unsafep.el" "emulation/cua-gmrk.el" 
"emulation/edt-lk201.el"
+;;;;;;  "emulation/edt-mapper.el" "emulation/edt-pc.el" 
"emulation/edt-vt100.el"
+;;;;;;  "emulation/viper-cmd.el" "emulation/viper-ex.el" 
"emulation/viper-init.el"
+;;;;;;  "emulation/viper-keym.el" "emulation/viper-macs.el" 
"emulation/viper-mous.el"
+;;;;;;  "emulation/viper-util.el" "erc/erc-backend.el" "erc/erc-goodies.el"
+;;;;;;  "erc/erc-ibuffer.el" "erc/erc-lang.el" "eshell/em-alias.el"
+;;;;;;  "eshell/em-banner.el" "eshell/em-basic.el" "eshell/em-cmpl.el"
+;;;;;;  "eshell/em-dirs.el" "eshell/em-glob.el" "eshell/em-hist.el"
+;;;;;;  "eshell/em-ls.el" "eshell/em-pred.el" "eshell/em-prompt.el"
+;;;;;;  "eshell/em-rebind.el" "eshell/em-script.el" "eshell/em-smart.el"
+;;;;;;  "eshell/em-term.el" "eshell/em-tramp.el" "eshell/em-unix.el"
+;;;;;;  "eshell/em-xtra.el" "eshell/esh-arg.el" "eshell/esh-cmd.el"
+;;;;;;  "eshell/esh-ext.el" "eshell/esh-groups.el" "eshell/esh-io.el"
+;;;;;;  "eshell/esh-module.el" "eshell/esh-opt.el" "eshell/esh-proc.el"
+;;;;;;  "eshell/esh-util.el" "eshell/esh-var.el" "ezimage.el" "format-spec.el"
+;;;;;;  "fringe.el" "generic-x.el" "gnus/compface.el" "gnus/gnus-async.el"
+;;;;;;  "gnus/gnus-bcklg.el" "gnus/gnus-cite.el" "gnus/gnus-cloud.el"
+;;;;;;  "gnus/gnus-cus.el" "gnus/gnus-demon.el" "gnus/gnus-dup.el"
+;;;;;;  "gnus/gnus-eform.el" "gnus/gnus-ems.el" "gnus/gnus-icalendar.el"
+;;;;;;  "gnus/gnus-int.el" "gnus/gnus-logic.el" "gnus/gnus-mh.el"
+;;;;;;  "gnus/gnus-salt.el" "gnus/gnus-score.el" "gnus/gnus-srvr.el"
+;;;;;;  "gnus/gnus-topic.el" "gnus/gnus-undo.el" "gnus/gnus-util.el"
+;;;;;;  "gnus/gnus-uu.el" "gnus/gnus-vm.el" "gnus/gssapi.el" 
"gnus/ietf-drums.el"
+;;;;;;  "gnus/legacy-gnus-agent.el" "gnus/mail-parse.el" "gnus/mail-prsvr.el"
+;;;;;;  "gnus/mail-source.el" "gnus/mailcap.el" "gnus/messcompat.el"
+;;;;;;  "gnus/mm-archive.el" "gnus/mm-bodies.el" "gnus/mm-decode.el"
+;;;;;;  "gnus/mm-util.el" "gnus/mm-view.el" "gnus/mml-sec.el" 
"gnus/mml-smime.el"
+;;;;;;  "gnus/nnagent.el" "gnus/nnbabyl.el" "gnus/nndir.el" "gnus/nndraft.el"
+;;;;;;  "gnus/nneething.el" "gnus/nngateway.el" "gnus/nnheader.el"
+;;;;;;  "gnus/nnimap.el" "gnus/nnir.el" "gnus/nnmail.el" "gnus/nnmaildir.el"
+;;;;;;  "gnus/nnmairix.el" "gnus/nnmbox.el" "gnus/nnmh.el" "gnus/nnnil.el"
+;;;;;;  "gnus/nnoo.el" "gnus/nnregistry.el" "gnus/nnrss.el" "gnus/nnspool.el"
+;;;;;;  "gnus/nntp.el" "gnus/nnvirtual.el" "gnus/nnweb.el" "gnus/registry.el"
+;;;;;;  "gnus/rfc1843.el" "gnus/rfc2045.el" "gnus/rfc2047.el" "gnus/rfc2231.el"
+;;;;;;  "gnus/rtree.el" "gnus/sieve-manage.el" "gnus/smime.el" 
"gnus/spam-stat.el"
+;;;;;;  "gnus/spam-wash.el" "hex-util.el" "hfy-cmap.el" "ibuf-ext.el"
+;;;;;;  "international/charscript.el" "international/fontset.el"
+;;;;;;  "international/iso-ascii.el" "international/ja-dic-cnv.el"
 ;;;;;;  "international/ja-dic-utl.el" "international/ogonek.el" 
"international/uni-bidi.el"
 ;;;;;;  "international/uni-brackets.el" "international/uni-category.el"
 ;;;;;;  "international/uni-combining.el" "international/uni-comment.el"
@@ -32365,11 +32402,11 @@ Zone out, completely.
 ;;;;;;  "net/imap.el" "net/ldap.el" "net/mairix.el" "net/newsticker.el"
 ;;;;;;  "net/nsm.el" "net/rfc2104.el" "net/sasl-cram.el" "net/sasl-digest.el"
 ;;;;;;  "net/sasl-scram-rfc.el" "net/sasl.el" "net/shr-color.el"
-;;;;;;  "net/socks.el" "net/tls.el" "net/tramp-adb.el" "net/tramp-cache.el"
-;;;;;;  "net/tramp-cmds.el" "net/tramp-compat.el" "net/tramp-gvfs.el"
-;;;;;;  "net/tramp-gw.el" "net/tramp-loaddefs.el" "net/tramp-sh.el"
-;;;;;;  "net/tramp-smb.el" "net/tramp-uu.el" "net/trampver.el" 
"net/zeroconf.el"
-;;;;;;  "notifications.el" "nxml/nxml-enc.el" "nxml/nxml-maint.el"
+;;;;;;  "net/soap-inspect.el" "net/socks.el" "net/tls.el" "net/tramp-adb.el"
+;;;;;;  "net/tramp-cache.el" "net/tramp-cmds.el" "net/tramp-compat.el"
+;;;;;;  "net/tramp-gvfs.el" "net/tramp-gw.el" "net/tramp-loaddefs.el"
+;;;;;;  "net/tramp-sh.el" "net/tramp-smb.el" "net/tramp-uu.el" 
"net/trampver.el"
+;;;;;;  "net/zeroconf.el" "notifications.el" "nxml/nxml-enc.el" 
"nxml/nxml-maint.el"
 ;;;;;;  "nxml/nxml-ns.el" "nxml/nxml-outln.el" "nxml/nxml-parse.el"
 ;;;;;;  "nxml/nxml-rap.el" "nxml/nxml-util.el" "nxml/rng-dt.el" 
"nxml/rng-loc.el"
 ;;;;;;  "nxml/rng-maint.el" "nxml/rng-match.el" "nxml/rng-parse.el"
@@ -32394,14 +32431,14 @@ Zone out, completely.
 ;;;;;;  "org/org-faces.el" "org/org-feed.el" "org/org-footnote.el"
 ;;;;;;  "org/org-gnus.el" "org/org-habit.el" "org/org-id.el" 
"org/org-indent.el"
 ;;;;;;  "org/org-info.el" "org/org-inlinetask.el" "org/org-install.el"
-;;;;;;  "org/org-irc.el" "org/org-list.el" "org/org-macro.el" "org/org-mhe.el"
-;;;;;;  "org/org-mobile.el" "org/org-mouse.el" "org/org-pcomplete.el"
-;;;;;;  "org/org-plot.el" "org/org-protocol.el" "org/org-rmail.el"
-;;;;;;  "org/org-src.el" "org/org-table.el" "org/org-timer.el" "org/org-w3m.el"
-;;;;;;  "org/ox-ascii.el" "org/ox-beamer.el" "org/ox-html.el" 
"org/ox-icalendar.el"
-;;;;;;  "org/ox-latex.el" "org/ox-man.el" "org/ox-md.el" "org/ox-odt.el"
-;;;;;;  "org/ox-org.el" "org/ox-publish.el" "org/ox-texinfo.el" "org/ox.el"
-;;;;;;  "play/gametree.el" "progmodes/ada-prj.el" "progmodes/cc-align.el"
+;;;;;;  "org/org-irc.el" "org/org-list.el" "org/org-loaddefs.el"
+;;;;;;  "org/org-macro.el" "org/org-mhe.el" "org/org-mobile.el" 
"org/org-mouse.el"
+;;;;;;  "org/org-pcomplete.el" "org/org-plot.el" "org/org-protocol.el"
+;;;;;;  "org/org-rmail.el" "org/org-src.el" "org/org-table.el" 
"org/org-timer.el"
+;;;;;;  "org/org-w3m.el" "org/ox-ascii.el" "org/ox-beamer.el" "org/ox-html.el"
+;;;;;;  "org/ox-icalendar.el" "org/ox-latex.el" "org/ox-man.el" "org/ox-md.el"
+;;;;;;  "org/ox-odt.el" "org/ox-org.el" "org/ox-publish.el" "org/ox-texinfo.el"
+;;;;;;  "org/ox.el" "play/gametree.el" "progmodes/ada-prj.el" 
"progmodes/cc-align.el"
 ;;;;;;  "progmodes/cc-awk.el" "progmodes/cc-bytecomp.el" "progmodes/cc-cmds.el"
 ;;;;;;  "progmodes/cc-defs.el" "progmodes/cc-fonts.el" "progmodes/cc-langs.el"
 ;;;;;;  "progmodes/cc-menus.el" "progmodes/ebnf-abn.el" "progmodes/ebnf-bnf.el"
@@ -32424,7 +32461,7 @@ Zone out, completely.
 ;;;;;;  "vc/ediff-vers.el" "vc/ediff-wind.el" "vc/pcvs-info.el" 
"vc/pcvs-parse.el"
 ;;;;;;  "vc/pcvs-util.el" "vc/vc-dav.el" "vc/vc-filewise.el" "vcursor.el"
 ;;;;;;  "vt-control.el" "vt100-led.el" "w32-fns.el" "w32-vars.el"
-;;;;;;  "x-dnd.el") (22069 63623 894804 836000))
+;;;;;;  "x-dnd.el") (22106 57434 227149 199000))
 
 ;;;***
 
diff --git a/lisp/linum.el b/lisp/linum.el
index 7b6a3ea..4e0bc56 100644
--- a/lisp/linum.el
+++ b/lisp/linum.el
@@ -120,7 +120,15 @@ Linum mode is a buffer-local minor mode."
   (mapc #'delete-overlay linum-overlays)
   (setq linum-overlays nil)
   (dolist (w (get-buffer-window-list (current-buffer) nil t))
-    (set-window-margins w 0 (cdr (window-margins w)))))
+    ;; restore margins if needed FIXME: This still fails if the
+    ;; "other" mode has incidently set margins to exactly what linum
+    ;; had: see bug#20674 for a similar workaround in nlinum.el
+    (let ((set-margins (window-parameter w 'linum--set-margins))
+          (current-margins (window-margins w)))
+      (when (and set-margins
+                 (equal set-margins current-margins))
+        (set-window-margins w 0 (cdr current-margins))
+        (set-window-parameter w 'linum--set-margins nil)))))
 
 (defun linum-update-current ()
   "Update line numbers for the current buffer."
@@ -143,10 +151,10 @@ Linum mode is a buffer-local minor mode."
 
 (defun linum--face-width (face)
   (let ((info (font-info (face-font face)))
-       width)
+        width)
     (setq width (aref info 11))
     (if (<= width 0)
-       (setq width (aref info 10)))
+        (setq width (aref info 10)))
     width))
 
 (defun linum-update-window (win)
@@ -170,7 +178,7 @@ Linum mode is a buffer-local minor mode."
              (visited (catch 'visited
                         (dolist (o (overlays-in (point) (point)))
                           (when (equal-including-properties
-                                (overlay-get o 'linum-str) str)
+                                 (overlay-get o 'linum-str) str)
                             (unless (memq o linum-overlays)
                               (push o linum-overlays))
                             (setq linum-available (delq o linum-available))
@@ -193,7 +201,12 @@ Linum mode is a buffer-local minor mode."
       (setq width (ceiling
                    (/ (* width 1.0 (linum--face-width 'linum))
                       (frame-char-width)))))
-    (set-window-margins win width (cdr (window-margins win)))))
+    ;; open up space in the left margin, if needed, and record that
+    ;; fact as the window-parameter `linum--set-margins'
+    (let ((existing-margins (window-margins win)))
+      (when (> width (or (car existing-margins) 0))
+        (set-window-margins win width (cdr existing-margins))
+        (set-window-parameter win 'linum--set-margins (window-margins win))))))
 
 (defun linum-after-change (beg end _len)
   ;; update overlays on deletions, and after newlines are inserted
diff --git a/lisp/loadup.el b/lisp/loadup.el
index f0caa8b..782622c 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -60,6 +60,10 @@
     (let ((dir (car load-path)))
       ;; We'll probably overflow the pure space.
       (setq purify-flag nil)
+      ;; Value of max-lisp-eval-depth when compiling initially.
+      ;; During bootstrapping the byte-compiler is run interpreted when
+      ;; compiling itself, which uses a lot more stack than usual.
+      (setq max-lisp-eval-depth 2200)
       (setq load-path (list (expand-file-name "." dir)
                            (expand-file-name "emacs-lisp" dir)
                            (expand-file-name "language" dir)
@@ -149,6 +153,7 @@
 (load "emacs-lisp/nadvice")
 (load "emacs-lisp/cl-preloaded")
 (load "minibuffer")            ;After loaddefs, for define-minor-mode.
+(load "obarray")        ;abbrev.el is implemented in terms of obarrays.
 (load "abbrev")         ;lisp-mode.el and simple.el use define-abbrev-table.
 (load "simple")
 
diff --git a/lisp/mpc.el b/lisp/mpc.el
index af1aac9..3ddcf13 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -826,6 +826,9 @@ The songs are returned as alists."
   (mpc-proc-cmd "play")
   (mpc-status-refresh))
 
+(defun mpc-cmd-seekcur (time)
+  (mpc-proc-cmd (list "seekcur" time) #'mpc-status-refresh))
+
 (defun mpc-cmd-add (files &optional playlist)
   "Add the songs FILES to PLAYLIST.
 If PLAYLIST is t or nil or missing, use the main playlist."
@@ -1026,12 +1029,11 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
                                                (substring time (match-end 0))
                                              time)))))
                     (`Cover
-                     (let ((dir (file-name-directory
-                                 (mpc-file-local-copy (cdr (assq 'file 
info))))))
+                     (let ((dir (file-name-directory (cdr (assq 'file info)))))
                        ;; (debug)
                        (push `(equal ',dir (file-name-directory (cdr (assq 
'file info)))) pred)
                        (if-let ((covers '(".folder.png" "cover.jpg" 
"folder.jpg"))
-                                (cover (cl-loop for file in (directory-files 
dir)
+                                (cover (cl-loop for file in (directory-files 
(mpc-file-local-copy dir))
                                                 if (member (downcase file) 
covers)
                                                 return (concat dir file)))
                                 (file (with-demoted-errors "MPC: %s"
@@ -1128,7 +1130,7 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
     (define-key map "s" 'mpc-toggle-play)
     (define-key map ">" 'mpc-next)
     (define-key map "<" 'mpc-prev)
-    (define-key map "g" nil)
+    (define-key map "g" 'mpc-seek-current)
     map))
 
 (easy-menu-define mpc-mode-menu mpc-mode-map
@@ -1137,6 +1139,7 @@ If PLAYLIST is t or nil or missing, use the main 
playlist."
     ["Play/Pause" mpc-toggle-play]      ;FIXME: Add one of ⏯/▶/⏸ in there?
     ["Next Track" mpc-next]             ;FIXME: Add ⇥ there?
     ["Previous Track" mpc-prev]         ;FIXME: Add ⇤ there?
+    ["Seek Within Track" mpc-seek-current]
     "--"
     ["Repeat Playlist" mpc-toggle-repeat :style toggle
      :selected (member '(repeat . "1") mpc-status)]
@@ -2403,6 +2406,12 @@ This is used so that they can be compared with `eq', 
which is needed for
   (interactive)
   (mpc-cmd-pause "0"))
 
+(defun mpc-seek-current (pos)
+  "Seek within current track."
+  (interactive
+   (list (read-string "Position to go ([+-]seconds): ")))
+  (mpc-cmd-seekcur pos))
+
 (defun mpc-toggle-play ()
   "Toggle between play and pause.
 If stopped, start playback."
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 6bd5815..1b6108e 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -221,7 +221,7 @@ This variant works around bugs in `eval-when-compile' in 
various
 (eval-and-compile
   (defmacro c--macroexpand-all (form &optional environment)
     ;; Macro to smooth out the renaming of `cl-macroexpand-all' in Emacs 24.3.
-    (if (eq c--mapcan-status 'cl-mapcan)
+    (if (fboundp 'macroexpand-all)
        `(macroexpand-all ,form ,environment)
       `(cl-macroexpand-all ,form ,environment)))
 
@@ -508,19 +508,21 @@ must not be within a `c-save-buffer-state', since the 
user then
 wouldn't be able to undo them.
 
 The return value is the value of the last form in BODY."
-  `(let* ((modified (buffer-modified-p)) (buffer-undo-list t)
-         (inhibit-read-only t) (inhibit-point-motion-hooks t)
-         before-change-functions after-change-functions
-         deactivate-mark
-         buffer-file-name buffer-file-truename ; Prevent primitives checking
-                                               ; for file modification
-         ,@varlist)
-     (unwind-protect
-        (progn ,@body)
-       (and (not modified)
-           (buffer-modified-p)
-           (set-buffer-modified-p nil)))))
-(put 'c-save-buffer-state 'lisp-indent-function 1)
+  (declare (debug t) (indent 1))
+  (if (fboundp 'with-silent-modifications)
+      `(with-silent-modifications (let* ,varlist ,@body))
+    `(let* ((modified (buffer-modified-p)) (buffer-undo-list t)
+           (inhibit-read-only t) (inhibit-point-motion-hooks t)
+           before-change-functions after-change-functions
+           deactivate-mark
+           buffer-file-name buffer-file-truename ; Prevent primitives checking
+                                                 ; for file modification
+           ,@varlist)
+       (unwind-protect
+          (progn ,@body)
+        (and (not modified)
+             (buffer-modified-p)
+             (set-buffer-modified-p nil))))))
 
 (defmacro c-tentative-buffer-changes (&rest body)
   "Eval BODY and optionally restore the buffer contents to the state it
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index af2ea56..2c22483 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -228,8 +228,7 @@ Blank lines separate paragraphs.  Semicolons start comments.
 
 \\{emacs-lisp-mode-map}"
   :group 'lisp
-  (defvar xref-find-function)
-  (defvar xref-identifier-completion-table-function)
+  (defvar xref-backend-functions)
   (defvar project-library-roots-function)
   (lisp-mode-variables nil nil 'elisp)
   (add-hook 'after-load-functions #'elisp--font-lock-flush-elisp-buffers)
@@ -239,9 +238,7 @@ Blank lines separate paragraphs.  Semicolons start comments.
   (setq imenu-case-fold-search nil)
   (add-function :before-until (local 'eldoc-documentation-function)
                 #'elisp-eldoc-documentation-function)
-  (setq-local xref-find-function #'elisp-xref-find)
-  (setq-local xref-identifier-completion-table-function
-              #'elisp--xref-identifier-completion-table)
+  (add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
   (setq-local project-library-roots-function #'elisp-library-roots)
   (add-hook 'completion-at-point-functions
             #'elisp-completion-at-point nil 'local))
@@ -588,21 +585,7 @@ It can be quoted, or be inside a quoted form."
 (declare-function xref-make "xref" (summary location))
 (declare-function xref-collect-references "xref" (symbol dir))
 
-(defun elisp-xref-find (action id)
-  (require 'find-func)
-  ;; FIXME: use information in source near point to filter results:
-  ;; (dvc-log-edit ...) - exclude 'feature
-  ;; (require 'dvc-log-edit) - only 'feature
-  ;; Semantic may provide additional information
-  (pcase action
-    (`definitions
-      (let ((sym (intern-soft id)))
-        (when sym
-          (elisp--xref-find-definitions sym))))
-    (`references
-     (elisp--xref-find-references id))
-    (`apropos
-     (elisp--xref-find-apropos id))))
+(defun elisp--xref-backend () 'elisp)
 
 ;; WORKAROUND: This is nominally a constant, but the text properties
 ;; are not preserved thru dump if use defconst.  See bug#21237.
@@ -638,7 +621,17 @@ Each function should return a list of xrefs, or nil; the 
first
 non-nil result supercedes the xrefs produced by
 `elisp--xref-find-definitions'.")
 
-;; FIXME: name should be singular; match xref-find-definition
+(cl-defmethod xref-backend-definitions ((_backend (eql elisp)) identifier)
+  (require 'find-func)
+  ;; FIXME: use information in source near point to filter results:
+  ;; (dvc-log-edit ...) - exclude 'feature
+  ;; (require 'dvc-log-edit) - only 'feature
+  ;; Semantic may provide additional information
+  ;;
+  (let ((sym (intern-soft identifier)))
+    (when sym
+      (elisp--xref-find-definitions sym))))
+
 (defun elisp--xref-find-definitions (symbol)
   ;; The file name is not known when `symbol' is defined via interactive eval.
   (let (xrefs)
@@ -805,7 +798,7 @@ non-nil result supercedes the xrefs produced by
 (declare-function project-roots "project")
 (declare-function project-current "project")
 
-(defun elisp--xref-find-references (symbol)
+(cl-defmethod xref-backend-references ((_backend (eql elisp)) symbol)
   "Find all references to SYMBOL (a string) in the current project."
   (cl-mapcan
    (lambda (dir)
@@ -815,7 +808,7 @@ non-nil result supercedes the xrefs produced by
       (project-roots pr)
       (project-library-roots pr)))))
 
-(defun elisp--xref-find-apropos (regexp)
+(cl-defmethod xref-backend-apropos ((_backend (eql elisp)) regexp)
   (apply #'nconc
          (let (lst)
            (dolist (sym (apropos-internal regexp))
@@ -832,7 +825,7 @@ non-nil result supercedes the xrefs produced by
                          (facep sym)))
                    'strict))
 
-(defun elisp--xref-identifier-completion-table ()
+(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql elisp)))
   elisp--xref-identifier-completion-table)
 
 (cl-defstruct (xref-elisp-location
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 38c5cc2..ae1aa11 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -2084,17 +2084,12 @@ for \\[find-tag] (which see)."
 
 (defvar etags-xref-find-definitions-tag-order '(tag-exact-match-p
                                                 tag-implicit-name-match-p)
-  "Tag order used in `etags-xref-find' to look for definitions.")
+  "Tag order used in `xref-backend-definitions' to look for definitions.")
 
-;;;###autoload
-(defun etags-xref-find (action id)
-  (pcase action
-    (`definitions (etags--xref-find-definitions id))
-    (`references  (etags--xref-find-references id))
-    (`apropos (etags--xref-find-definitions id t))))
-
-(defun etags--xref-find-references (symbol)
-  ;; TODO: Merge together with the Elisp impl.
+(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql etags)))
+  (tags-lazy-completion-table))
+
+(cl-defmethod xref-backend-references ((_backend (eql etags)) symbol)
   (cl-mapcan
    (lambda (dir)
      (xref-collect-references symbol dir))
@@ -2103,6 +2098,12 @@ for \\[find-tag] (which see)."
       (project-roots pr)
       (project-library-roots pr)))))
 
+(cl-defmethod xref-backend-definitions ((_backend (eql etags)) symbol)
+  (etags--xref-find-definitions symbol))
+
+(cl-defmethod xref-backend-apropos ((_backend (eql etags)) symbol)
+  (etags--xref-find-definitions symbol t))
+
 (defun etags--xref-find-definitions (pattern &optional regexp?)
   ;; This emulates the behaviour of `find-tag-in-order' but instead of
   ;; returning one match at a time all matches are returned as list.
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index 489094b..4095d47 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -123,7 +123,7 @@
 ;;
 
 ;; This variable will always hold the version number of the mode
-(defconst verilog-mode-version "2015-09-18-314cf1d-vpo-GNU"
+(defconst verilog-mode-version "2015-11-21-8112ca0-vpo-GNU"
   "Version of this Verilog mode.")
 (defconst verilog-mode-release-emacs t
   "If non-nil, this version of Verilog mode was released with Emacs itself.")
@@ -230,10 +230,9 @@ STRING should be given if the last search was by 
`string-match' on STRING."
         `(customize ,var))
       )
 
-    (unless (boundp 'inhibit-point-motion-hooks)
-      (defvar inhibit-point-motion-hooks nil))
-    (unless (boundp 'deactivate-mark)
-      (defvar deactivate-mark nil))
+    (defvar inhibit-modification-hooks)
+    (defvar inhibit-point-motion-hooks)
+    (defvar deactivate-mark)
     )
   ;;
   ;; OK, do this stuff if we are NOT XEmacs:
@@ -327,6 +326,14 @@ wherever possible, since it is slow."
         (not (null pos)))))))
 
 (eval-and-compile
+  (cond
+   ((fboundp 'restore-buffer-modified-p)
+    ;; Faster, as does not update mode line when nothing changes
+    (defalias 'verilog-restore-buffer-modified-p 'restore-buffer-modified-p))
+   (t
+    (defalias 'verilog-restore-buffer-modified-p 'set-buffer-modified-p))))
+
+(eval-and-compile
   ;; Both xemacs and emacs
   (condition-case nil
       (require 'diff)  ; diff-command and diff-switches
@@ -827,6 +834,10 @@ Function takes three arguments, the original buffer, the
 difference buffer, and the point in original buffer with the
 first difference.")
 
+(defvar verilog-diff-ignore-regexp nil
+  "Non-nil specifies regexp which `verilog-diff-auto' will ignore.
+This is typically nil.")
+
 ;;; Compile support:
 ;;
 
@@ -2937,8 +2948,6 @@ find the errors."
     (modify-syntax-entry ?> "." table)
     (modify-syntax-entry ?& "." table)
     (modify-syntax-entry ?| "." table)
-    ;; FIXME: This goes against Emacs conventions.  Use "_" syntax instead and
-    ;; then use regexps with things like "\\_<...\\_>".
     (modify-syntax-entry ?` "w" table)  ; ` is part of definition symbols in 
Verilog
     (modify-syntax-entry ?_ "w" table)
     (modify-syntax-entry ?\' "." table)
@@ -3225,56 +3234,63 @@ A change is considered significant if it affects the 
buffer text
 in any way that isn't completely restored again.  Any
 user-visible changes to the buffer must not be within a
 `verilog-save-buffer-state'."
-  ;; From c-save-buffer-state
-  `(let* ((modified (buffer-modified-p))
-         (buffer-undo-list t)
-         (inhibit-read-only t)
-         (inhibit-point-motion-hooks t)
-         (verilog-no-change-functions t)
-         before-change-functions
-         after-change-functions
-         deactivate-mark
-         buffer-file-name ; Prevent primitives checking
-         buffer-file-truename) ; for file modification
-     (unwind-protect
-        (progn ,@body)
-       (and (not modified)
-           (buffer-modified-p)
-           (set-buffer-modified-p nil)))))
+  `(let ((inhibit-point-motion-hooks t)
+         (verilog-no-change-functions t))
+     ,(if (fboundp 'with-silent-modifications)
+          `(with-silent-modifications ,@body)
+        ;; Backward compatible version of with-silent-modifications
+        `(let* ((modified (buffer-modified-p))
+                (buffer-undo-list t)
+                (inhibit-read-only t)
+                (inhibit-modification-hooks t)
+                ;; XEmacs ignores inhibit-modification-hooks.
+                before-change-functions after-change-functions
+                deactivate-mark
+                buffer-file-name        ; Prevent primitives checking
+                buffer-file-truename)  ; for file modification
+           (unwind-protect
+               (progn ,@body)
+             (and (not modified)
+                  (buffer-modified-p)
+                  (verilog-restore-buffer-modified-p nil)))))))
 
-(defmacro verilog-save-no-change-functions (&rest body)
-  "Execute BODY forms, disabling all change hooks in BODY.
-For insignificant changes, see instead `verilog-save-buffer-state'."
-  `(let* ((inhibit-point-motion-hooks t)
-         (verilog-no-change-functions t)
-         before-change-functions
-         after-change-functions)
-     (progn ,@body)))
 
 (defvar verilog-save-font-mod-hooked nil
-  "Local variable when inside a `verilog-save-font-mods' block.")
+  "Local variable when inside a `verilog-save-font-no-change-functions' 
block.")
 (make-variable-buffer-local 'verilog-save-font-mod-hooked)
 
-(defmacro verilog-save-font-mods (&rest body)
-  "Execute BODY forms, disabling text modifications to allow performing BODY.
+(defmacro verilog-save-font-no-change-functions (&rest body)
+ "Execute BODY forms, disabling all change hooks in BODY.
 Includes temporary disabling of `font-lock' to restore the buffer
 to full text form for parsing.  Additional actions may be specified with
-`verilog-before-save-font-hook' and `verilog-after-save-font-hook'."
-  ;; Before version 20, match-string with font-lock returns a
-  ;; vector that is not equal to the string.  IE if on "input"
-  ;; nil==(equal "input" (progn (looking-at "input") (match-string 0)))
-  `(let* ((hooked (unless verilog-save-font-mod-hooked
-                   (verilog-run-hooks 'verilog-before-save-font-hook)
-                   t))
-         (verilog-save-font-mod-hooked t)
-         (fontlocked (when (and (boundp 'font-lock-mode) font-lock-mode)
-                       (font-lock-mode 0)
-                       t)))
-     (unwind-protect
-         (progn ,@body)
-       ;; Unwind forms
-       (when fontlocked (font-lock-mode t))
-       (when hooked (verilog-run-hooks 'verilog-after-save-font-hook)))))
+`verilog-before-save-font-hook' and `verilog-after-save-font-hook'.
+For insignificant changes, see instead `verilog-save-buffer-state'."
+ `(if verilog-save-font-mod-hooked ; Short-circuit a recursive call
+      (progn ,@body)
+    ;; Before version 20, match-string with font-lock returns a
+    ;; vector that is not equal to the string.  IE if on "input"
+    ;; nil==(equal "input" (progn (looking-at "input") (match-string 0)))
+    ;; Therefore we must remove and restore font-lock mode
+    (verilog-run-hooks 'verilog-before-save-font-hook)
+    (let* ((verilog-save-font-mod-hooked (- (point-max) (point-min)))
+           ;; Significant speed savings with no font-lock properties
+           (fontlocked (when (and (boundp 'font-lock-mode) font-lock-mode)
+                         (font-lock-mode 0)
+                         t)))
+      (run-hook-with-args 'before-change-functions (point-min) (point-max))
+      (unwind-protect
+          ;; Must inhibit and restore hooks before restoring font-lock
+          (let* ((inhibit-point-motion-hooks t)
+                 (inhibit-modification-hooks t)
+                 (verilog-no-change-functions t)
+                 ;; XEmacs and pre-Emacs 21 ignore inhibit-modification-hooks.
+                 before-change-functions after-change-functions)
+            (progn ,@body))
+        ;; Unwind forms
+        (run-hook-with-args 'after-change-functions (point-min) (point-max)
+                            verilog-save-font-mod-hooked) ; old length
+        (when fontlocked (font-lock-mode t))
+        (verilog-run-hooks 'verilog-after-save-font-hook)))))
 
 ;;
 ;; Comment detection and caching
@@ -8074,7 +8090,7 @@ Duplicate signals are also removed.  For example A[2] and 
A[1] become A[2:1]."
             (when (and sv-busstring
                        (not (equal sv-busstring (verilog-sig-bits sig))))
                (when nil  ; Debugging
-                (message (concat "Warning, can't merge into single bus %s%s"
+                (message (concat "Warning, can't merge into single bus `%s%s'"
                                  ", the AUTOs may be wrong")
                          sv-name bus))
               (setq buswarn ", Couldn't Merge"))
@@ -8377,18 +8393,18 @@ Return an array of [outputs inouts inputs wire reg 
assign const]."
                 (setcar (cdr (cdr (cdr newsig)))
                         (if (verilog-sig-memory newsig)
                             (concat (verilog-sig-memory newsig) (match-string 
1))
-                          (match-string 1))))
+                          (match-string-no-properties 1))))
                 (vec  ; Multidimensional
                 (setq multidim (cons vec multidim))
                 (setq vec (verilog-string-replace-matches
-                           "\\s-+" "" nil nil (match-string 1))))
+                           "\\s-+" "" nil nil (match-string-no-properties 1))))
                 (t  ; Bit width
                 (setq vec (verilog-string-replace-matches
-                           "\\s-+" "" nil nil (match-string 1))))))
+                           "\\s-+" "" nil nil (match-string-no-properties 
1))))))
         ;; Normal or escaped identifier -- note we remember the \ if escaped
         ((looking-at "\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)")
          (goto-char (match-end 0))
-         (setq keywd (match-string 1))
+         (setq keywd (match-string-no-properties 1))
          (when (string-match "^\\\\" (match-string 1))
             (setq keywd (concat keywd " ")))  ; Escaped ID needs space at end
          ;; Add any :: package names to same identifier
@@ -8573,11 +8589,12 @@ Return an array of [outputs inouts inputs wire reg 
assign const]."
   (defvar sigs-out-unk)
   (defvar sigs-temp)
   ;; These are known to be from other packages and may not be defined
-  (defvar diff-command nil)
+  (defvar diff-command)
   ;; There are known to be from newer versions of Emacs
-  (defvar create-lockfiles))
+  (defvar create-lockfiles)
+  (defvar which-func-modes))
 
-(defun verilog-read-sub-decls-sig (submoddecls comment port sig vec multidim)
+(defun verilog-read-sub-decls-sig (submoddecls comment port sig vec multidim 
mem)
   "For `verilog-read-sub-decls-line', add a signal."
   ;; sig eq t to indicate .name syntax
   ;;(message "vrsds: %s(%S)" port sig)
@@ -8588,6 +8605,7 @@ Return an array of [outputs inouts inputs wire reg assign 
const]."
       (setq sig  (if dotname port (verilog-symbol-detick-denumber sig)))
       (if vec (setq vec  (verilog-symbol-detick-denumber vec)))
       (if multidim (setq multidim  (mapcar `verilog-symbol-detick-denumber 
multidim)))
+      (if mem (setq mem (verilog-symbol-detick-denumber mem)))
       (unless (or (not sig)
                   (equal sig ""))  ; Ignore .foo(1'b1) assignments
        (cond ((or (setq portdata (assoc port (verilog-decls-get-inouts 
submoddecls)))
@@ -8597,7 +8615,7 @@ Return an array of [outputs inouts inputs wire reg assign 
const]."
                            sig
                            (if dotname (verilog-sig-bits portdata) vec)
                            (concat "To/From " comment)
-                           (verilog-sig-memory portdata)
+                            mem
                            nil
                            (verilog-sig-signed portdata)
                            (unless (member (verilog-sig-type portdata) 
'("wire" "reg"))
@@ -8611,7 +8629,7 @@ Return an array of [outputs inouts inputs wire reg assign 
const]."
                            sig
                            (if dotname (verilog-sig-bits portdata) vec)
                            (concat "From " comment)
-                           (verilog-sig-memory portdata)
+                           mem
                            nil
                            (verilog-sig-signed portdata)
                            ;; Though ok in SV, in V2K code, propagating the
@@ -8630,7 +8648,7 @@ Return an array of [outputs inouts inputs wire reg assign 
const]."
                            sig
                            (if dotname (verilog-sig-bits portdata) vec)
                            (concat "To " comment)
-                           (verilog-sig-memory portdata)
+                           mem
                            nil
                            (verilog-sig-signed portdata)
                            (unless (member (verilog-sig-type portdata) 
'("wire" "reg"))
@@ -8643,7 +8661,7 @@ Return an array of [outputs inouts inputs wire reg assign 
const]."
                            sig
                            (if dotname (verilog-sig-bits portdata) vec)
                            (concat "To/From " comment)
-                           (verilog-sig-memory portdata)
+                           mem
                            nil
                            (verilog-sig-signed portdata)
                            (verilog-sig-type portdata)
@@ -8656,7 +8674,7 @@ Return an array of [outputs inouts inputs wire reg assign 
const]."
                            sig
                            (if dotname (verilog-sig-bits portdata) vec)
                            (concat "To/From " comment)
-                           (verilog-sig-memory portdata)
+                           mem
                            nil
                            (verilog-sig-signed portdata)
                            (verilog-sig-type portdata)
@@ -8669,7 +8687,7 @@ Return an array of [outputs inouts inputs wire reg assign 
const]."
   "For `verilog-read-sub-decls-line', parse a subexpression and add signals."
   ;;(message "vrsde: `%s'" expr)
   ;; Replace special /*[....]*/ comments inserted by verilog-auto-inst-port
-  (setq expr (verilog-string-replace-matches "/\\*\\(\\[[^*]+\\]\\)\\*/" "\\1" 
nil nil expr))
+  (setq expr (verilog-string-replace-matches "/\\*\\(\\.?\\[[^*]+\\]\\)\\*/" 
"\\1" nil nil expr))
   ;; Remove front operators
   (setq expr (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil 
nil expr))
   ;;
@@ -8683,7 +8701,7 @@ Return an array of [outputs inouts inputs wire reg assign 
const]."
        (while (setq mstr (pop mlst))
          (verilog-read-sub-decls-expr submoddecls comment port mstr)))))
    (t
-    (let (sig vec multidim)
+    (let (sig vec multidim mem)
       ;; Remove leading reduction operators, etc
       (setq expr (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" 
nil nil expr))
       ;;(message "vrsde-ptop: `%s'" expr)
@@ -8703,10 +8721,15 @@ Return an array of [outputs inouts inputs wire reg 
assign const]."
        (when vec (setq multidim (cons vec multidim)))
        (setq vec (match-string 1 expr)
              expr (substring expr (match-end 0))))
+      ;; Find .[unpacked_memory] or .[unpacked][unpacked]...
+      (while (string-match "^\\s-*\\.\\(\\[[^]]+\\]\\)" expr)
+       ;;(message "vrsde-m: `%s'" (match-string 1 expr))
+       (setq mem (match-string 1 expr)
+             expr (substring expr (match-end 0))))
       ;; If found signal, and nothing unrecognized, add the signal
       ;;(message "vrsde-rem: `%s'" expr)
       (when (and sig (string-match "^\\s-*$" expr))
-       (verilog-read-sub-decls-sig submoddecls comment port sig vec 
multidim))))))
+       (verilog-read-sub-decls-sig submoddecls comment port sig vec multidim 
mem))))))
 
 (defun verilog-read-sub-decls-line (submoddecls comment)
   "For `verilog-read-sub-decls', read lines of port defs until none match.
@@ -8717,23 +8740,23 @@ Inserts the list of signals found, using submodi to 
look up each port."
       (while (not done)
        ;; Get port name
        (cond ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*(\\s-*")
-              (setq port (match-string 1))
+              (setq port (match-string-no-properties 1))
               (goto-char (match-end 0)))
              ;; .\escaped (
              ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*")
-               (setq port (concat (match-string 1) " "))  ; escaped id's need 
trailing space
+               (setq port (concat (match-string-no-properties 1) " "))  ; 
escaped id's need trailing space
               (goto-char (match-end 0)))
              ;; .name
              ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*[,)/]")
               (verilog-read-sub-decls-sig
-               submoddecls comment (match-string 1) t ; sig==t for .name
-               nil nil) ; vec multidim
+               submoddecls comment (match-string-no-properties 1) t ; sig==t 
for .name
+               nil nil nil) ; vec multidim mem
               (setq port nil))
              ;; .\escaped_name
              ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*[,)/]")
               (verilog-read-sub-decls-sig
-               submoddecls comment (concat (match-string 1) " ") t ; sig==t 
for .name
-               nil nil) ; vec multidim
+               submoddecls comment (concat (match-string-no-properties 1) " ") 
t ; sig==t for .name
+               nil nil nil) ; vec multidim mem
               (setq port nil))
              ;; random
              ((looking-at "\\s-*\\.[^(]*(")
@@ -8748,20 +8771,20 @@ Inserts the list of signals found, using submodi to 
look up each port."
          (cond ((looking-at "\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\s-*)")
                 (verilog-read-sub-decls-sig
                  submoddecls comment port
-                 (verilog-string-remove-spaces (match-string 1)) ; sig
-                 nil nil)) ; vec multidim
+                 (verilog-string-remove-spaces (match-string-no-properties 1)) 
; sig
+                 nil nil nil)) ; vec multidim mem
                ;;
                ((looking-at 
"\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)")
                 (verilog-read-sub-decls-sig
                  submoddecls comment port
-                 (verilog-string-remove-spaces (match-string 1)) ; sig
-                 (match-string 2) nil)) ; vec multidim
+                 (verilog-string-remove-spaces (match-string-no-properties 1)) 
; sig
+                 (match-string-no-properties 2) nil nil)) ; vec multidim mem
                ;; Fastpath was above looking-at's.
                ;; For something more complicated invoke a parser
                ((looking-at "[^)]+")
                 (verilog-read-sub-decls-expr
                  submoddecls comment port
-                 (buffer-substring
+                 (buffer-substring-no-properties
                   (point) (1- (progn (search-backward "(") ; start at (
                                      (verilog-forward-sexp-ign-cmt 1)
                                      (point)))))))) ; expr
@@ -9894,7 +9917,7 @@ Return modi if successful, else print message unless 
IGNORE-ERROR is true."
               (or mif ignore-error
                   (error
                    (concat
-                    "%s: Can't locate %s module definition%s"
+                    "%s: Can't locate `%s' module definition%s"
                     "\n    Check the verilog-library-directories variable."
                     "\n    I looked in (if not listed, doesn't exist):\n\t%s")
                    (verilog-point-text) module
@@ -9959,9 +9982,9 @@ Cache the output of function so next call may have faster 
access."
            (t
             ;; Read from file
             ;; Clear then restore any highlighting to make emacs19 happy
-            (let (func-returns)
-              (verilog-save-font-mods
-               (setq func-returns (funcall function)))
+             (let ((func-returns
+                    (verilog-save-font-no-change-functions
+                     (funcall function))))
               ;; Cache for next time
               (setq verilog-modi-cache-list
                     (cons (list (list modi function)
@@ -10003,7 +10026,7 @@ Report errors unless optional IGNORE-ERROR."
   (let* ((realname (verilog-symbol-detick name t))
         (modport (assoc name (verilog-decls-get-modports 
(verilog-modi-get-decls modi)))))
     (or modport ignore-error
-       (error "%s: Can't locate %s modport definition%s"
+       (error "%s: Can't locate `%s' modport definition%s"
                (verilog-point-text) name
                (if (not (equal name realname))
                    (concat " (Expanded macro to " realname ")")
@@ -10193,7 +10216,7 @@ When MODI is non-null, also add to modi-cache, for 
tracking."
          ((equal direction "parameter")
           (verilog-modi-cache-add-gparams modi sigs))
          (t
-          (error "Unsupported verilog-insert-definition direction: %s" 
direction))))
+          (error "Unsupported verilog-insert-definition direction: `%s'" 
direction))))
   (or dont-sort
       (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare)))
   (while sigs
@@ -10224,7 +10247,7 @@ When MODI is non-null, also add to modi-cache, for 
tracking."
 
 (eval-when-compile
   (if (not (boundp 'indent-pt))
-      (defvar indent-pt nil "Local used by insert-indent")))
+      (defvar indent-pt nil "Local used by `verilog-insert-indent'.")))
 
 (defun verilog-insert-indent (&rest stuff)
   "Indent to position stored in local `indent-pt' variable, then insert STUFF.
@@ -10510,6 +10533,41 @@ removed."
          (re-search-backward ",")
          (delete-char 1))))))
 
+(defun verilog-delete-auto-buffer ()
+  "Perform `verilog-delete-auto' on the current buffer.
+Intended for internal use inside a `verilog-save-font-no-change-functions' 
block."
+  ;; Allow user to customize
+  (verilog-run-hooks 'verilog-before-delete-auto-hook)
+
+  ;; Remove those that have multi-line insertions, possibly with parameters
+  ;; We allow anything beginning with AUTO, so that users can add their own
+  ;; patterns
+  (verilog-auto-re-search-do
+   (concat "/\\*AUTO[A-Za-z0-9_]+"
+           ;; Optional parens or quoted parameter or .* for (((...)))
+           "\\(\\|([^)]*)\\|(\"[^\"]*\")\\).*?"
+           "\\*/")
+   'verilog-delete-autos-lined)
+  ;; Remove those that are in parenthesis
+  (verilog-auto-re-search-do
+   (concat "/\\*"
+           (eval-when-compile
+             (verilog-regexp-words
+              `("AS" "AUTOARG" "AUTOCONCATWIDTH" "AUTOINST" "AUTOINSTPARAM"
+                "AUTOSENSE")))
+           "\\*/")
+   'verilog-delete-to-paren)
+  ;; Do .* instantiations, but avoid removing any user pins by looking for our 
magic comments
+  (verilog-auto-re-search-do "\\.\\*"
+                             'verilog-delete-auto-star-all)
+  ;; Remove template comments ... anywhere in case was pasted after AUTOINST 
removed
+  (goto-char (point-min))
+  (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)\\([ 
\tLT0-9]*\\| LHS: .*\\)?$" nil t)
+    (replace-match ""))
+
+  ;; Final customize
+  (verilog-run-hooks 'verilog-delete-auto-hook))
+
 (defun verilog-delete-auto ()
   "Delete the automatic outputs, regs, and wires created by \\[verilog-auto].
 Use \\[verilog-auto] to re-insert the updated AUTOs.
@@ -10520,39 +10578,10 @@ called before and after this function, respectively."
   (save-excursion
     (if (buffer-file-name)
         (find-file-noselect (buffer-file-name)))  ; To check we have latest 
version
-    (verilog-save-no-change-functions
+    (verilog-save-font-no-change-functions
      (verilog-save-scan-cache
-      ;; Allow user to customize
-      (verilog-run-hooks 'verilog-before-delete-auto-hook)
-
-      ;; Remove those that have multi-line insertions, possibly with parameters
-      ;; We allow anything beginning with AUTO, so that users can add their own
-      ;; patterns
-      (verilog-auto-re-search-do
-       (concat "/\\*AUTO[A-Za-z0-9_]+"
-              ;; Optional parens or quoted parameter or .* for (((...)))
-              "\\(\\|([^)]*)\\|(\"[^\"]*\")\\).*?"
-              "\\*/")
-       'verilog-delete-autos-lined)
-      ;; Remove those that are in parenthesis
-      (verilog-auto-re-search-do
-       (concat "/\\*"
-              (eval-when-compile
-                (verilog-regexp-words
-                 `("AS" "AUTOARG" "AUTOCONCATWIDTH" "AUTOINST" "AUTOINSTPARAM"
-                   "AUTOSENSE")))
-              "\\*/")
-       'verilog-delete-to-paren)
-      ;; Do .* instantiations, but avoid removing any user pins by looking for 
our magic comments
-      (verilog-auto-re-search-do "\\.\\*"
-                                'verilog-delete-auto-star-all)
-      ;; Remove template comments ... anywhere in case was pasted after 
AUTOINST removed
-      (goto-char (point-min))
-      (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)\\([ 
\tLT0-9]*\\| LHS: .*\\)?$" nil t)
-       (replace-match ""))
+      (verilog-delete-auto-buffer)))))
 
-      ;; Final customize
-      (verilog-run-hooks 'verilog-delete-auto-hook)))))
 
 ;;; Auto inject:
 ;;
@@ -10679,10 +10708,11 @@ Typing \\[verilog-inject-auto] will make this into:
 ;; Auto diff:
 ;;
 
-(defun verilog-diff-buffers-p (b1 b2 &optional whitespace)
+(defun verilog-diff-buffers-p (b1 b2 &optional whitespace regexp)
   "Return nil if buffers B1 and B2 have same contents.
 Else, return point in B1 that first mismatches.
-If optional WHITESPACE true, ignore whitespace."
+If optional WHITESPACE true, ignore whitespace.
+If optional REGEXP, ignore differences matching it."
   (save-excursion
     (let* ((case-fold-search nil)  ; compare-buffer-substrings cares
           (p1 (with-current-buffer b1 (goto-char (point-min))))
@@ -10703,6 +10733,15 @@ If optional WHITESPACE true, ignore whitespace."
            (goto-char p2)
            (skip-chars-forward " \t\n\r\f\v")
            (setq p2 (point))))
+       (when regexp
+         (with-current-buffer b1
+           (goto-char p1)
+           (when (looking-at regexp)
+              (setq p1 (match-end 0))))
+         (with-current-buffer b2
+           (goto-char p2)
+           (when (looking-at regexp)
+              (setq p2 (match-end 0)))))
        (setq size (min (- maxp1 p1) (- maxp2 p2)))
        (setq progress (compare-buffer-substrings b2 p2 (+ size p2)
                                                  b1 p1 (+ size p1)))
@@ -10723,7 +10762,7 @@ Ignores WHITESPACE if t, and writes output to stdout if 
SHOW."
   ;; call `diff' as `diff' has different calling semantics on different
   ;; versions of Emacs.
   (if (not (file-exists-p f1))
-      (message "Buffer %s has no associated file on disc" (buffer-name b2))
+      (message "Buffer `%s' has no associated file on disk" (buffer-name b2))
     (with-temp-buffer "*Verilog-Diff*"
                       (let ((outbuf (current-buffer))
                             (f2 (make-temp-file "vm-diff-auto-")))
@@ -10791,7 +10830,7 @@ or `diff' in batch mode."
            ;; Restore name if unwind
            (with-current-buffer b1 (setq buffer-file-name name1)))))
       ;;
-      (setq diffpt (verilog-diff-buffers-p b1 b2 t))
+      (setq diffpt (verilog-diff-buffers-p b1 b2 t verilog-diff-ignore-regexp))
       (cond ((not diffpt)
             (unless noninteractive (message "AUTO expansion identical"))
              (kill-buffer newname))  ; Nice to cleanup after oneself
@@ -11054,6 +11093,7 @@ If PAR-VALUES replace final strings with these 
parameter values."
         (vl-name (verilog-sig-name port-st))
         (vl-width (verilog-sig-width port-st))
         (vl-modport (verilog-sig-modport port-st))
+        (vl-memory (verilog-sig-memory port-st))
         (vl-mbits (if (verilog-sig-multidim port-st)
                        (verilog-sig-multidim-string port-st) ""))
         (vl-bits (if (or verilog-auto-inst-vector
@@ -11078,15 +11118,25 @@ If PAR-VALUES replace final strings with these 
parameter values."
                        (concat "\\<" (nth 0 (car check-values)) "\\>")
                        (concat "(" (nth 1 (car check-values)) ")")
                        t t vl-mbits)
+             vl-memory (when vl-memory
+                          (verilog-string-replace-matches
+                           (concat "\\<" (nth 0 (car check-values)) "\\>")
+                           (concat "(" (nth 1 (car check-values)) ")")
+                           t t vl-memory))
              check-values (cdr check-values)))
       (setq vl-bits (verilog-simplify-range-expression vl-bits)
            vl-mbits (verilog-simplify-range-expression vl-mbits)
+           vl-memory (when vl-memory (verilog-simplify-range-expression 
vl-memory))
            vl-width (verilog-make-width-expression vl-bits))) ; Not in the 
loop for speed
     ;; Default net value if not found
-    (setq dflt-bits (if (and (verilog-sig-bits port-st)
-                            (or (verilog-sig-multidim port-st)
-                                (verilog-sig-memory port-st)))
-                       (concat "/*" vl-mbits vl-bits "*/")
+    (setq dflt-bits (if (or (and (verilog-sig-bits port-st)
+                                 (verilog-sig-multidim port-st))
+                            (verilog-sig-memory port-st))
+                       (concat "/*" vl-mbits vl-bits
+                                ;; .[ used to separate packed from unpacked
+                                (if vl-memory "." "")
+                                (if vl-memory vl-memory "")
+                                "*/")
                      (concat vl-bits))
          tpl-net (concat port
                          (if (and vl-modport
@@ -11157,7 +11207,7 @@ If PAR-VALUES replace final strings with these 
parameter values."
          (for-star
           (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16)
                         verilog-auto-inst-column))
-          (verilog-insert " // Implicit .\*\n")) ;For some reason the . or * 
must be escaped...
+          (verilog-insert " // Implicit .*\n"))
          (t
           (insert "\n")))))
 ;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" 
"address@hidden"(% (+ @ 1) 4)\"a")) "3")
@@ -13316,13 +13366,16 @@ Typing \\[verilog-auto] will make this into:
           (sig-list-all  (verilog-decls-get-iovars moddecls))
           ;;
           (undecode-sig (or (assoc undecode-name sig-list-all)
-                            (error "%s: Signal %s not found in design" 
(verilog-point-text) undecode-name)))
+                            (error "%s: Signal `%s' not found in design"
+                                    (verilog-point-text) undecode-name)))
           (undecode-enum (or (verilog-sig-enum undecode-sig)
-                             (error "%s: Signal %s does not have an enum tag" 
(verilog-point-text) undecode-name)))
+                             (error "%s: Signal `%s' does not have an enum tag"
+                                     (verilog-point-text) undecode-name)))
           ;;
           (enum-sigs (verilog-signals-not-in
                       (or (verilog-signals-matching-enum sig-list-consts 
undecode-enum)
-                          (error "%s: No state definitions for %s" 
(verilog-point-text) undecode-enum))
+                          (error "%s: No state definitions for `%s'"
+                                  (verilog-point-text) undecode-enum))
                       nil))
           ;;
           (one-hot (or
@@ -13518,120 +13571,115 @@ Wilson Snyder (address@hidden)."
   (unless noninteractive (message "Updating AUTOs..."))
   (if (fboundp 'dinotrace-unannotate-all)
       (dinotrace-unannotate-all))
-  (verilog-save-font-mods
+  ;; Disable change hooks for speed
+  ;; This let can't be part of above let; must restore
+  ;; after-change-functions before font-lock resumes
+  (verilog-save-font-no-change-functions
    (let ((oldbuf (if (not (buffer-modified-p))
-                    (buffer-string)))
-        (case-fold-search verilog-case-fold)
-        ;; Cache directories; we don't write new files, so can't change
-        (verilog-dir-cache-preserving t)
-        ;; Cache current module
-        (verilog-modi-cache-current-enable t)
-        (verilog-modi-cache-current-max (point-min)) ; IE it's invalid
-        verilog-modi-cache-current)
-     (unwind-protect
-        ;; Disable change hooks for speed
-        ;; This let can't be part of above let; must restore
-        ;; after-change-functions before font-lock resumes
-        (verilog-save-no-change-functions
-         (verilog-save-scan-cache
-          (save-excursion
-            ;; Wipe cache; otherwise if we AUTOed a block above this one,
-            ;; we'll misremember we have generated IOs, confusing AUTOOUTPUT
-            (setq verilog-modi-cache-list nil)
-            ;; Local state
-            (verilog-read-auto-template-init)
-            ;; If we're not in verilog-mode, change syntax table so parsing 
works right
-            (unless (eq major-mode `verilog-mode) (verilog-mode))
-            ;; Allow user to customize
-            (verilog-run-hooks 'verilog-before-auto-hook)
-            ;; Try to save the user from needing to revert-file to reread file 
local-variables
-            (verilog-auto-reeval-locals)
-            (verilog-read-auto-lisp-present)
-            (verilog-read-auto-lisp (point-min) (point-max))
-            (verilog-getopt-flags)
-            ;; From here on out, we can cache anything we read from disk
-            (verilog-preserve-dir-cache
-             ;; These two may seem obvious to do always, but on large includes 
it can be way too slow
-             (when verilog-auto-read-includes
-               (verilog-read-includes)
-               (verilog-read-defines nil nil t))
-             ;; Setup variables due to SystemVerilog expansion
-             (verilog-auto-re-search-do "/\\*AUTOLOGIC\\*/" 
'verilog-auto-logic-setup)
-             ;; This particular ordering is important
-             ;; INST: Lower modules correct, no internal dependencies, FIRST
-             (verilog-preserve-modi-cache
-              ;; Clear existing autos else we'll be screwed by existing ones
-              (verilog-delete-auto)
-              ;; Injection if appropriate
-              (when inject
-                (verilog-inject-inst)
-                (verilog-inject-sense)
-                (verilog-inject-arg))
-              ;;
-              ;; Do user inserts first, so their code can insert AUTOs
-              (verilog-auto-re-search-do "/\\*AUTOINSERTLISP(.*?)\\*/"
-                                         'verilog-auto-insert-lisp)
-              ;; Expand instances before need the signals the instances 
input/output
-              (verilog-auto-re-search-do "/\\*AUTOINSTPARAM\\*/" 
'verilog-auto-inst-param)
-              (verilog-auto-re-search-do "/\\*AUTOINST\\*/" 'verilog-auto-inst)
-              (verilog-auto-re-search-do "\\.\\*" 'verilog-auto-star)
-              ;; Doesn't matter when done, but combine it with a common changer
-              (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 
'verilog-auto-sense)
-              (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 
'verilog-auto-reset)
-              ;; Must be done before autoin/out as creates a reg
-              (verilog-auto-re-search-do "/\\*AUTOASCIIENUM(.*?)\\*/" 
'verilog-auto-ascii-enum)
-              ;;
-              ;; first in/outs from other files
-              (verilog-auto-re-search-do "/\\*AUTOINOUTMODPORT(.*?)\\*/" 
'verilog-auto-inout-modport)
-              (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE(.*?)\\*/" 
'verilog-auto-inout-module)
-              (verilog-auto-re-search-do "/\\*AUTOINOUTCOMP(.*?)\\*/" 
'verilog-auto-inout-comp)
-              (verilog-auto-re-search-do "/\\*AUTOINOUTIN(.*?)\\*/" 
'verilog-auto-inout-in)
-              (verilog-auto-re-search-do "/\\*AUTOINOUTPARAM(.*?)\\*/" 
'verilog-auto-inout-param)
-              ;; next in/outs which need previous sucked inputs first
-              (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\((.*?)\\)?\\*/" 
'verilog-auto-output)
-              (verilog-auto-re-search-do "/\\*AUTOINPUT\\((.*?)\\)?\\*/" 
'verilog-auto-input)
-              (verilog-auto-re-search-do "/\\*AUTOINOUT\\((.*?)\\)?\\*/" 
'verilog-auto-inout)
-              ;; Then tie off those in/outs
-              (verilog-auto-re-search-do "/\\*AUTOTIEOFF\\*/" 
'verilog-auto-tieoff)
-              ;; These can be anywhere after AUTOINSERTLISP
-              (verilog-auto-re-search-do "/\\*AUTOUNDEF\\((.*?)\\)?\\*/" 
'verilog-auto-undef)
-              ;; Wires/regs must be after inputs/outputs
-              (verilog-auto-re-search-do "/\\*AUTOASSIGNMODPORT(.*?)\\*/" 
'verilog-auto-assign-modport)
-              (verilog-auto-re-search-do "/\\*AUTOLOGIC\\*/" 
'verilog-auto-logic)
-              (verilog-auto-re-search-do "/\\*AUTOWIRE\\*/" 'verilog-auto-wire)
-              (verilog-auto-re-search-do "/\\*AUTOREG\\*/" 'verilog-auto-reg)
-              (verilog-auto-re-search-do "/\\*AUTOREGINPUT\\*/" 
'verilog-auto-reg-input)
-              ;; outputevery needs AUTOOUTPUTs done first
-              (verilog-auto-re-search-do "/\\*AUTOOUTPUTEVERY\\((.*?)\\)?\\*/" 
'verilog-auto-output-every)
-              ;; After we've created all new variables
-              (verilog-auto-re-search-do "/\\*AUTOUNUSED\\*/" 
'verilog-auto-unused)
-              ;; Must be after all inputs outputs are generated
-              (verilog-auto-re-search-do "/\\*AUTOARG\\*/" 'verilog-auto-arg)
-              ;; User inserts
-              (verilog-auto-re-search-do "/\\*AUTOINSERTLAST(.*?)\\*/" 
'verilog-auto-insert-last)
-              ;; Fix line numbers (comments only)
-              (when verilog-auto-inst-template-numbers
-                (verilog-auto-templated-rel))
-              (when verilog-auto-template-warn-unused
-                (verilog-auto-template-lint))))
-            ;;
-            (verilog-run-hooks 'verilog-auto-hook)
-            ;;
-            (when verilog-auto-delete-trailing-whitespace
-              (verilog-delete-trailing-whitespace))
-            ;;
-            (set (make-local-variable 'verilog-auto-update-tick) 
(buffer-chars-modified-tick))
-            ;;
-            ;; If end result is same as when started, clear modified flag
-            (cond ((and oldbuf (equal oldbuf (buffer-string)))
-                   (set-buffer-modified-p nil)
-                   (unless noninteractive (message "Updating AUTOs...done (no 
changes)")))
-                  (t (unless noninteractive (message "Updating 
AUTOs...done"))))
-            ;; End of after-change protection
-            )))
-       ;; Unwind forms
-       ;; Currently handled in verilog-save-font-mods
-       ))))
+                     (buffer-string)))
+         (case-fold-search verilog-case-fold)
+         ;; Cache directories; we don't write new files, so can't change
+         (verilog-dir-cache-preserving t)
+         ;; Cache current module
+         (verilog-modi-cache-current-enable t)
+         (verilog-modi-cache-current-max (point-min)) ; IE it's invalid
+         verilog-modi-cache-current)
+     (verilog-save-scan-cache
+      (save-excursion
+        ;; Wipe cache; otherwise if we AUTOed a block above this one,
+        ;; we'll misremember we have generated IOs, confusing AUTOOUTPUT
+        (setq verilog-modi-cache-list nil)
+        ;; Local state
+        (verilog-read-auto-template-init)
+        ;; If we're not in verilog-mode, change syntax table so parsing works 
right
+        (unless (eq major-mode `verilog-mode) (verilog-mode))
+        ;; Allow user to customize
+        (verilog-run-hooks 'verilog-before-auto-hook)
+        ;; Try to save the user from needing to revert-file to reread file 
local-variables
+        (verilog-auto-reeval-locals)
+        (verilog-read-auto-lisp-present)
+        (verilog-read-auto-lisp (point-min) (point-max))
+        (verilog-getopt-flags)
+        ;; From here on out, we can cache anything we read from disk
+        (verilog-preserve-dir-cache
+         ;; These two may seem obvious to do always, but on large includes it 
can be way too slow
+         (when verilog-auto-read-includes
+           (verilog-read-includes)
+           (verilog-read-defines nil nil t))
+         ;; Setup variables due to SystemVerilog expansion
+         (verilog-auto-re-search-do "/\\*AUTOLOGIC\\*/" 
'verilog-auto-logic-setup)
+         ;; This particular ordering is important
+         ;; INST: Lower modules correct, no internal dependencies, FIRST
+         (verilog-preserve-modi-cache
+          ;; Clear existing autos else we'll be screwed by existing ones
+          (verilog-delete-auto-buffer)
+          ;; Injection if appropriate
+          (when inject
+            (verilog-inject-inst)
+            (verilog-inject-sense)
+            (verilog-inject-arg))
+          ;;
+          ;; Do user inserts first, so their code can insert AUTOs
+          (verilog-auto-re-search-do "/\\*AUTOINSERTLISP(.*?)\\*/"
+                                     'verilog-auto-insert-lisp)
+          ;; Expand instances before need the signals the instances 
input/output
+          (verilog-auto-re-search-do "/\\*AUTOINSTPARAM\\*/" 
'verilog-auto-inst-param)
+          (verilog-auto-re-search-do "/\\*AUTOINST\\*/" 'verilog-auto-inst)
+          (verilog-auto-re-search-do "\\.\\*" 'verilog-auto-star)
+          ;; Doesn't matter when done, but combine it with a common changer
+          (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 
'verilog-auto-sense)
+          (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset)
+          ;; Must be done before autoin/out as creates a reg
+          (verilog-auto-re-search-do "/\\*AUTOASCIIENUM(.*?)\\*/" 
'verilog-auto-ascii-enum)
+          ;;
+          ;; first in/outs from other files
+          (verilog-auto-re-search-do "/\\*AUTOINOUTMODPORT(.*?)\\*/" 
'verilog-auto-inout-modport)
+          (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE(.*?)\\*/" 
'verilog-auto-inout-module)
+          (verilog-auto-re-search-do "/\\*AUTOINOUTCOMP(.*?)\\*/" 
'verilog-auto-inout-comp)
+          (verilog-auto-re-search-do "/\\*AUTOINOUTIN(.*?)\\*/" 
'verilog-auto-inout-in)
+          (verilog-auto-re-search-do "/\\*AUTOINOUTPARAM(.*?)\\*/" 
'verilog-auto-inout-param)
+          ;; next in/outs which need previous sucked inputs first
+          (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\((.*?)\\)?\\*/" 
'verilog-auto-output)
+          (verilog-auto-re-search-do "/\\*AUTOINPUT\\((.*?)\\)?\\*/" 
'verilog-auto-input)
+          (verilog-auto-re-search-do "/\\*AUTOINOUT\\((.*?)\\)?\\*/" 
'verilog-auto-inout)
+          ;; Then tie off those in/outs
+          (verilog-auto-re-search-do "/\\*AUTOTIEOFF\\*/" 'verilog-auto-tieoff)
+          ;; These can be anywhere after AUTOINSERTLISP
+          (verilog-auto-re-search-do "/\\*AUTOUNDEF\\((.*?)\\)?\\*/" 
'verilog-auto-undef)
+          ;; Wires/regs must be after inputs/outputs
+          (verilog-auto-re-search-do "/\\*AUTOASSIGNMODPORT(.*?)\\*/" 
'verilog-auto-assign-modport)
+          (verilog-auto-re-search-do "/\\*AUTOLOGIC\\*/" 'verilog-auto-logic)
+          (verilog-auto-re-search-do "/\\*AUTOWIRE\\*/" 'verilog-auto-wire)
+          (verilog-auto-re-search-do "/\\*AUTOREG\\*/" 'verilog-auto-reg)
+          (verilog-auto-re-search-do "/\\*AUTOREGINPUT\\*/" 
'verilog-auto-reg-input)
+          ;; outputevery needs AUTOOUTPUTs done first
+          (verilog-auto-re-search-do "/\\*AUTOOUTPUTEVERY\\((.*?)\\)?\\*/" 
'verilog-auto-output-every)
+          ;; After we've created all new variables
+          (verilog-auto-re-search-do "/\\*AUTOUNUSED\\*/" 'verilog-auto-unused)
+          ;; Must be after all inputs outputs are generated
+          (verilog-auto-re-search-do "/\\*AUTOARG\\*/" 'verilog-auto-arg)
+          ;; User inserts
+          (verilog-auto-re-search-do "/\\*AUTOINSERTLAST(.*?)\\*/" 
'verilog-auto-insert-last)
+          ;; Fix line numbers (comments only)
+          (when verilog-auto-inst-template-numbers
+            (verilog-auto-templated-rel))
+          (when verilog-auto-template-warn-unused
+            (verilog-auto-template-lint))))
+        ;;
+        (verilog-run-hooks 'verilog-auto-hook)
+        ;;
+        (when verilog-auto-delete-trailing-whitespace
+          (verilog-delete-trailing-whitespace))
+        ;;
+        (set (make-local-variable 'verilog-auto-update-tick) 
(buffer-chars-modified-tick))
+        ;;
+        ;; If end result is same as when started, clear modified flag
+        (cond ((and oldbuf (equal oldbuf (buffer-string)))
+               (verilog-restore-buffer-modified-p nil)
+               (unless noninteractive (message "Updating AUTOs...done (no 
changes)")))
+              (t (unless noninteractive (message "Updating AUTOs...done"))))
+        ;; End of save-cache
+        )))))
 
 ;;; Skeletons:
 ;;
diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
index a8c2813..7e289b3 100644
--- a/lisp/progmodes/which-func.el
+++ b/lisp/progmodes/which-func.el
@@ -1,4 +1,4 @@
-;;; which-func.el --- print current function in mode line
+;;; which-func.el --- print current function in mode line  -*- 
lexical-binding:t -*-
 
 ;; Copyright (C) 1994, 1997-1998, 2001-2015 Free Software Foundation,
 ;; Inc.
@@ -80,7 +80,6 @@
   "List of major modes for which Which Function mode should be used.
 For other modes it is disabled.  If this is equal to t,
 then Which Function mode is enabled in any major mode that supports it."
-  :group 'which-func
   :version "24.3"                       ; explicit list -> t
   :type '(choice (const :tag "All modes" t)
                 (repeat (symbol :tag "Major mode"))))
@@ -91,13 +90,11 @@ This means that Which Function mode won't really do anything
 until you use Imenu, in these modes.  Note that files
 larger than `which-func-maxout' behave in this way too;
 Which Function mode doesn't do anything until you use Imenu."
-  :group 'which-func
   :type '(repeat (symbol :tag "Major mode")))
 
 (defcustom which-func-maxout 500000
   "Don't automatically compute the Imenu menu if buffer is this big or bigger.
 Zero means compute the Imenu menu regardless of size."
-  :group 'which-func
   :type 'integer)
 
 (defvar which-func-keymap
@@ -137,8 +134,7 @@ Zero means compute the Imenu menu regardless of size."
      :foreground "Blue1")
     (t
      :foreground "LightSkyBlue"))
-  "Face used to highlight mode line function names."
-  :group 'which-func)
+  "Face used to highlight mode line function names.")
 
 (defcustom which-func-format
   `("["
@@ -152,7 +148,6 @@ mouse-3: go to end")
     "]")
   "Format for displaying the function in the mode line."
   :version "24.2"                  ; added mouse-face; 24point2 is correct
-  :group 'which-func
   :type 'sexp)
 ;;;###autoload (put 'which-func-format 'risky-local-variable t)
 
@@ -193,14 +188,16 @@ This makes a difference only if `which-function-mode' is 
non-nil.")
 
 (add-hook 'find-file-hook 'which-func-ff-hook t)
 
+(defun which-func-try-to-enable ()
+  (unless (or (not which-function-mode)
+              (local-variable-p 'which-func-mode))
+    (setq which-func-mode (or (eq which-func-modes t)
+                              (member major-mode which-func-modes)))))
+
 (defun which-func-ff-hook ()
   "File find hook for Which Function mode.
 It creates the Imenu index for the buffer, if necessary."
-  (unless (local-variable-p 'which-func-mode)
-    (setq which-func-mode
-          (and which-function-mode
-               (or (eq which-func-modes t)
-                   (member major-mode which-func-modes)))))
+  (which-func-try-to-enable)
 
   (condition-case err
       (if (and which-func-mode
@@ -239,6 +236,13 @@ It creates the Imenu index for the buffer, if necessary."
 
 (defvar which-func-update-timer nil)
 
+(unless (or (assq 'which-func-mode mode-line-misc-info)
+            (assq 'which-function-mode mode-line-misc-info))
+  (add-to-list 'mode-line-misc-info
+               '(which-function-mode    ;Only display if mode is enabled.
+                 (which-func-mode       ;Only display if buffer supports it.
+                  ("" which-func-format " ")))))
+
 ;; This is the name people would normally expect.
 ;;;###autoload
 (define-minor-mode which-function-mode
@@ -254,17 +258,12 @@ in certain major modes."
   (when (timerp which-func-update-timer)
     (cancel-timer which-func-update-timer))
   (setq which-func-update-timer nil)
-  (if which-function-mode
-      ;;Turn it on
-      (progn
-        (setq which-func-update-timer
-              (run-with-idle-timer idle-update-delay t #'which-func-update))
-        (dolist (buf (buffer-list))
-          (with-current-buffer buf
-            (unless (local-variable-p 'which-func-mode)
-              (setq which-func-mode
-                    (or (eq which-func-modes t)
-                        (member major-mode which-func-modes)))))))))
+  (when which-function-mode
+    ;;Turn it on.
+    (setq which-func-update-timer
+          (run-with-idle-timer idle-update-delay t #'which-func-update))
+    (dolist (buf (buffer-list))
+      (with-current-buffer buf (which-func-try-to-enable)))))
 
 (defvar which-function-imenu-failed nil
   "Locally t in a buffer if `imenu--make-index-alist' found nothing there.")
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 89a0604..6a3b42f 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -23,14 +23,21 @@
 ;; referencing commands, in particular "find-definition".
 ;;
 ;; Some part of the functionality must be implemented in a language
-;; dependent way and that's done by defining `xref-find-function',
-;; `xref-identifier-at-point-function' and
-;; `xref-identifier-completion-table-function', which see.
+;; dependent way and that's done by defining an xref backend.
 ;;
-;; A major mode should make these variables buffer-local first.
+;; That consists of a constructor function, which should return a
+;; backend value, and a set of implementations for the generic
+;; functions:
 ;;
-;; `xref-find-function' can be called in several ways, see its
-;; description.  It has to operate with "xref" and "location" values.
+;; `xref-backend-identifier-at-point',
+;; `xref-backend-identifier-completion-table',
+;; `xref-backend-definitions', `xref-backend-references',
+;; `xref-backend-apropos', which see.
+;;
+;; A major mode would normally use `add-hook' to add the backend
+;; constructor to `xref-backend-functions'.
+;;
+;; The last three methods operate with "xref" and "location" values.
 ;;
 ;; One would usually call `make-xref' and `xref-make-file-location',
 ;; `xref-make-buffer-location' or `xref-make-bogus-location' to create
@@ -38,15 +45,19 @@
 ;; class inheriting from `xref-location' and implementing
 ;; `xref-location-group' and `xref-location-marker'.
 ;;
+;; There's a special kind of xrefs we call "match xrefs", which
+;; correspond to search results.  For these values,
+;; `xref-match-length' must be defined, and `xref-location-marker'
+;; must return the beginning of the match.
+;;
 ;; Each identifier must be represented as a string.  Implementers can
 ;; use string properties to store additional information about the
 ;; identifier, but they should keep in mind that values returned from
-;; `xref-identifier-completion-table-function' should still be
+;; `xref-backend-identifier-completion-table' should still be
 ;; distinct, because the user can't see the properties when making the
 ;; choice.
 ;;
-;; See the functions `etags-xref-find' and `elisp-xref-find' for full
-;; examples.
+;; See the etags and elisp-mode implementations for full examples.
 
 ;;; Code:
 
@@ -79,8 +90,8 @@ This is typically the filename.")
   "Return the line number corresponding to the location."
   nil)
 
-(cl-defgeneric xref-match-bounds (_item)
-  "Return a cons with columns of the beginning and end of the match."
+(cl-defgeneric xref-match-length (_item)
+  "Return the length of the match."
   nil)
 
 ;;;; Commonly needed location classes are defined here:
@@ -109,7 +120,7 @@ Line numbers start from 1 and columns from 0.")
         (save-excursion
           (goto-char (point-min))
           (beginning-of-line line)
-          (move-to-column column)
+          (forward-char column)
           (point-marker))))))
 
 (cl-defmethod xref-location-group ((l xref-file-location))
@@ -176,55 +187,60 @@ LOCATION is an `xref-location'."
    (location :initarg :location
              :type xref-file-location
              :reader xref-item-location)
-   (end-column :initarg :end-column))
-  :comment "An xref item describes a reference to a location
-somewhere.")
-
-(cl-defmethod xref-match-bounds ((i xref-match-item))
-  (with-slots (end-column location) i
-    (cons (xref-file-location-column location)
-          end-column)))
+   (length :initarg :length :reader xref-match-length))
+  :comment "A match xref item describes a search result.")
 
-(defun xref-make-match (summary end-column location)
+(defun xref-make-match (summary location length)
   "Create and return a new `xref-match-item'.
 SUMMARY is a short string to describe the xref.
-END-COLUMN is the match end column number inside SUMMARY.
-LOCATION is an `xref-location'."
-  (make-instance 'xref-match-item :summary summary :location location
-                 :end-column end-column))
+LOCATION is an `xref-location'.
+LENGTH is the match length, in characters."
+  (make-instance 'xref-match-item :summary summary
+                 :location location :length length))
 
 
 ;;; API
 
-(declare-function etags-xref-find "etags" (action id))
-(declare-function tags-lazy-completion-table "etags" ())
+;; We make the etags backend the default for now, until something
+;; better comes along.
+(defvar xref-backend-functions (list #'xref--etags-backend)
+  "Special hook to find the xref backend for the current context.
+Each functions on this hook is called in turn with no arguments
+and should return either nil to mean that it is not applicable,
+or an xref backend, which is a value to be used to dispatch the
+generic functions.")
 
-;; For now, make the etags backend the default.
-(defvar xref-find-function #'etags-xref-find
-  "Function to look for cross-references.
-It can be called in several ways:
+(defun xref-find-backend ()
+  (run-hook-with-args-until-success 'xref-backend-functions))
 
- (definitions IDENTIFIER): Find definitions of IDENTIFIER.  The
-result must be a list of xref objects.  If IDENTIFIER contains
-sufficient information to determine a unique definition, returns
-only that definition. If there are multiple possible definitions,
-return all of them.  If no definitions can be found, return nil.
+(defun xref--etags-backend () 'etags)
 
- (references IDENTIFIER): Find references of IDENTIFIER.  The
-result must be a list of xref objects.  If no references can be
-found, return nil.
+(cl-defgeneric xref-backend-definitions (backend identifier)
+  "Find definitions of IDENTIFIER.
 
- (apropos PATTERN): Find all symbols that match PATTERN.  PATTERN
-is a regexp.
+The result must be a list of xref objects.  If IDENTIFIER
+contains sufficient information to determine a unique definition,
+return only that definition. If there are multiple possible
+definitions, return all of them.  If no definitions can be found,
+return nil.
 
 IDENTIFIER can be any string returned by
-`xref-identifier-at-point-function', or from the table returned
-by `xref-identifier-completion-table-function'.
+`xref-backend-identifier-at-point', or from the table returned by
+`xref-backend-identifier-completion-table'.
 
 To create an xref object, call `xref-make'.")
 
-(defvar xref-identifier-at-point-function #'xref-default-identifier-at-point
-  "Function to get the relevant identifier at point.
+(cl-defgeneric xref-backend-references (backend identifier)
+  "Find references of IDENTIFIER.
+The result must be a list of xref objects.  If no references can
+be found, return nil.")
+
+(cl-defgeneric xref-backend-apropos (backend pattern)
+  "Find all symbols that match PATTERN.
+PATTERN is a regexp")
+
+(cl-defgeneric xref-backend-identifier-at-point (_backend)
+  "Return the relevant identifier at point.
 
 The return value must be a string or nil.  nil means no
 identifier at point found.
@@ -232,16 +248,14 @@ identifier at point found.
 If it's hard to determine the identifier precisely (e.g., because
 it's a method call on unknown type), the implementation can
 return a simple string (such as symbol at point) marked with a
-special text property which `xref-find-function' would recognize
-and then delegate the work to an external process.")
-
-(defvar xref-identifier-completion-table-function #'tags-lazy-completion-table
-  "Function that returns the completion table for identifiers.")
-
-(defun xref-default-identifier-at-point ()
+special text property which e.g. `xref-backend-definitions' would
+recognize and then delegate the work to an external process."
   (let ((thing (thing-at-point 'symbol)))
     (and thing (substring-no-properties thing))))
 
+(cl-defgeneric xref-backend-identifier-completion-table (backend)
+  "Returns the completion table for identifiers.")
+
 
 ;;; misc utilities
 (defun xref--alistify (list key test)
@@ -345,22 +359,14 @@ elements is negated."
   (pcase-let ((`(,beg . ,end)
                (save-excursion
                  (or
-                  (xref--match-buffer-bounds xref--current-item)
+                  (let ((length (xref-match-length xref--current-item)))
+                    (and length (cons (point) (+ (point) length))))
                   (back-to-indentation)
                   (if (eolp)
                       (cons (line-beginning-position) (1+ (point)))
                     (cons (point) (line-end-position)))))))
     (pulse-momentary-highlight-region beg end 'next-error)))
 
-(defun xref--match-buffer-bounds (item)
-  (save-excursion
-    (let ((bounds (xref-match-bounds item)))
-      (when bounds
-        (cons (progn (move-to-column (car bounds))
-                     (point))
-              (progn (move-to-column (cdr bounds))
-                     (point)))))))
-
 ;; etags.el needs this
 (defun xref-clear-marker-stack ()
   "Discard all markers from the marker stack."
@@ -487,50 +493,54 @@ WINDOW controls how the buffer is displayed:
         (progn
           (save-excursion
             (goto-char (point-min))
-            ;; TODO: Check that none of the matches are out of date;
-            ;; offer to re-scan otherwise.  Note that saving the last
-            ;; modification tick won't work, as long as not all of the
-            ;; buffers are kept open.
             (while (setq item (xref--search-property 'xref-item))
-              (when (xref-match-bounds item)
+              (when (xref-match-length item)
                 (save-excursion
-                  ;; FIXME: Get rid of xref--goto-location, by making
-                  ;; xref-match-bounds return markers already.
-                  (xref--goto-location (xref-item-location item))
-                  (let ((bounds (xref--match-buffer-bounds item))
-                        (beg (make-marker))
-                        (end (make-marker)))
-                    (move-marker beg (car bounds))
-                    (move-marker end (cdr bounds))
-                    (push (cons beg end) pairs)))))
+                  (let* ((loc (xref-item-location item))
+                         (beg (xref-location-marker loc))
+                         (len (xref-match-length item)))
+                    ;; Perform sanity check first.
+                    (xref--goto-location loc)
+                    ;; FIXME: The check should probably be a generic
+                    ;; function, instead of the assumption that all
+                    ;; matches contain the full line as summary.
+                    ;; TODO: Offer to re-scan otherwise.
+                    (unless (equal (buffer-substring-no-properties
+                                    (line-beginning-position)
+                                    (line-end-position))
+                                   (xref-item-summary item))
+                      (user-error "Search results out of date"))
+                    (push (cons beg len) pairs)))))
             (setq pairs (nreverse pairs)))
           (unless pairs (user-error "No suitable matches here"))
           (xref--query-replace-1 from to pairs))
       (dolist (pair pairs)
-        (move-marker (car pair) nil)
-        (move-marker (cdr pair) nil)))))
+        (move-marker (car pair) nil)))))
 
+;; FIXME: Write a nicer UI.
 (defun xref--query-replace-1 (from to pairs)
   (let* ((query-replace-lazy-highlight nil)
-         current-pair current-buf
+         current-beg current-len current-buf
          ;; Counteract the "do the next match now" hack in
          ;; `perform-replace'.  And still, it'll report that those
          ;; matches were "filtered out" at the end.
          (isearch-filter-predicate
           (lambda (beg end)
-            (and current-pair
+            (and current-beg
                  (eq (current-buffer) current-buf)
-                 (>= beg (car current-pair))
-                 (<= end (cdr current-pair)))))
+                 (>= beg current-beg)
+                 (<= end (+ current-beg current-len)))))
          (replace-re-search-function
           (lambda (from &optional _bound noerror)
-            (let (found)
+            (let (found pair)
               (while (and (not found) pairs)
-                (setq current-pair (pop pairs)
-                      current-buf  (marker-buffer (car current-pair)))
+                (setq pair (pop pairs)
+                      current-beg (car pair)
+                      current-len (cdr pair)
+                      current-buf (marker-buffer current-beg))
                 (pop-to-buffer current-buf)
-                (goto-char (car current-pair))
-                (when (re-search-forward from (cdr current-pair) noerror)
+                (goto-char current-beg)
+                (when (re-search-forward from (+ current-beg current-len) 
noerror)
                   (setq found t)))
               found))))
     ;; FIXME: Despite this being a multi-buffer replacement, `N'
@@ -695,7 +705,8 @@ 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)))
+  (let* ((backend (xref-find-backend))
+         (id (xref-backend-identifier-at-point backend)))
     (cond ((or current-prefix-arg
                (not id)
                (xref--prompt-p this-command))
@@ -705,7 +716,7 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)."
                                                              "[ :]+\\'" 
prompt))
                                         id)
                               prompt)
-                            (funcall xref-identifier-completion-table-function)
+                            (xref-backend-identifier-completion-table backend)
                             nil nil nil
                             'xref--read-identifier-history id))
           (t id))))
@@ -714,7 +725,9 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)."
 ;;; Commands
 
 (defun xref--find-xrefs (input kind arg window)
-  (let ((xrefs (funcall xref-find-function kind arg)))
+  (let ((xrefs (funcall (intern (format "xref-backend-%s" kind))
+                        (xref-find-backend)
+                        arg)))
     (unless xrefs
       (user-error "No %s found for: %s" (symbol-name kind) input))
     (xref--show-xrefs xrefs window)))
@@ -799,14 +812,9 @@ and just use etags."
   :lighter ""
   (if xref-etags-mode
       (progn
-        (setq xref-etags-mode--saved
-              (cons xref-find-function
-                    xref-identifier-completion-table-function))
-        (kill-local-variable 'xref-find-function)
-        (kill-local-variable 'xref-identifier-completion-table-function))
-    (setq-local xref-find-function (car xref-etags-mode--saved))
-    (setq-local xref-identifier-completion-table-function
-                (cdr xref-etags-mode--saved))))
+        (setq xref-etags-mode--saved xref-backend-functions)
+        (kill-local-variable 'xref-backend-functions))
+    (setq-local xref-backend-functions xref-etags-mode--saved)))
 
 (declare-function semantic-symref-find-references-by-name "semantic/symref")
 (declare-function semantic-find-file-noselect "semantic/fw")
@@ -826,10 +834,11 @@ tools are used, and when."
          (hits (and res (oref res hit-lines)))
          (orig-buffers (buffer-list)))
     (unwind-protect
-        (delq nil
-              (mapcar (lambda (hit) (xref--collect-match
-                                hit (format "\\_<%s\\_>" (regexp-quote 
symbol))))
-                      hits))
+        (cl-mapcan (lambda (hit) (xref--collect-matches
+                             hit (format "\\_<%s\\_>" (regexp-quote symbol))))
+                   hits)
+      ;; TODO: Implement "lightweight" buffer visiting, so that we
+      ;; don't have to kill them.
       (mapc #'kill-buffer
             (cl-set-difference (buffer-list) orig-buffers)))))
 
@@ -860,9 +869,9 @@ IGNORES is a list of glob patterns."
                     (match-string 1))
               hits)))
     (unwind-protect
-        (delq nil
-              (mapcar (lambda (hit) (xref--collect-match hit regexp))
-                      (nreverse hits)))
+        (cl-mapcan (lambda (hit) (xref--collect-matches hit regexp))
+                   (nreverse hits))
+      ;; TODO: Same as above.
       (mapc #'kill-buffer
             (cl-set-difference (buffer-list) orig-buffers)))))
 
@@ -918,7 +927,7 @@ IGNORES is a list of glob patterns."
                (match-string 1 str)))))
    str t t))
 
-(defun xref--collect-match (hit regexp)
+(defun xref--collect-matches (hit regexp)
   (pcase-let* ((`(,line . ,file) hit)
                (buf (or (find-buffer-visiting file)
                         (semantic-find-file-noselect file))))
@@ -926,18 +935,22 @@ IGNORES is a list of glob patterns."
       (save-excursion
         (goto-char (point-min))
         (forward-line (1- line))
-        (syntax-propertize (line-end-position))
-        ;; TODO: Handle multiple matches per line.
-        (when (re-search-forward regexp (line-end-position) t)
-          (goto-char (match-beginning 0))
-          (let ((loc (xref-make-file-location file line
-                                              (current-column))))
-            (goto-char (match-end 0))
-            (xref-make-match (buffer-substring
-                              (line-beginning-position)
-                              (line-end-position))
-                             (current-column)
-                             loc)))))))
+        (let ((line-end (line-end-position))
+              (line-beg (line-beginning-position))
+              matches)
+          (syntax-propertize line-end)
+          ;; FIXME: This results in several lines with the same
+          ;; summary. Solve with composite pattern?
+          (while (re-search-forward regexp line-end t)
+            (let* ((beg-column (- (match-beginning 0) line-beg))
+                   (end-column (- (match-end 0) line-beg))
+                   (loc (xref-make-file-location file line beg-column))
+                   (summary (buffer-substring line-beg line-end)))
+              (add-face-text-property beg-column end-column 'highlight
+                                      t summary)
+              (push (xref-make-match summary loc (- end-column beg-column))
+                    matches)))
+          (nreverse matches))))))
 
 (provide 'xref)
 
diff --git a/lisp/rect.el b/lisp/rect.el
index acd3a48..46ebbf2 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -257,6 +257,19 @@ Return it as a list of strings, one for each line of the 
rectangle."
     (apply-on-rectangle 'extract-rectangle-line start end lines)
     (nreverse (cdr lines))))
 
+(defun extract-rectangle-bounds (start end)
+  "Return the bounds of the rectangle with corners at START and END.
+Return it as a list of (START . END) positions, one for each line of
+the rectangle."
+  (let (bounds)
+    (apply-on-rectangle
+     (lambda (startcol endcol)
+       (move-to-column startcol)
+       (push (cons (prog1 (point) (move-to-column endcol)) (point))
+            bounds))
+     start end)
+    (nreverse bounds)))
+
 (defvar killed-rectangle nil
   "Rectangle for `yank-rectangle' to insert.")
 
@@ -563,6 +576,8 @@ with a prefix argument, prompt for START-AT and FORMAT."
               #'rectangle--unhighlight-for-redisplay)
 (add-function :around region-extract-function
               #'rectangle--extract-region)
+(add-function :around region-insert-function
+              #'rectangle--insert-region)
 
 (defvar rectangle-mark-mode-map
   (let ((map (make-sparse-keymap)))
@@ -681,8 +696,12 @@ Ignores `line-move-visual'."
 
 
 (defun rectangle--extract-region (orig &optional delete)
-  (if (not rectangle-mark-mode)
-      (funcall orig delete)
+  (cond
+   ((not rectangle-mark-mode)
+    (funcall orig delete))
+   ((eq delete 'bounds)
+    (extract-rectangle-bounds (region-beginning) (region-end)))
+   (t
     (let* ((strs (funcall (if delete
                               #'delete-extract-rectangle
                             #'extract-rectangle)
@@ -696,7 +715,14 @@ Ignores `line-move-visual'."
         (put-text-property 0 (length str) 'yank-handler
                            `(rectangle--insert-for-yank ,strs t)
                            str)
-        str))))
+        str)))))
+
+(defun rectangle--insert-region (orig strings)
+  (cond
+   ((not rectangle-mark-mode)
+    (funcall orig strings))
+   (t
+    (funcall #'insert-rectangle strings))))
 
 (defun rectangle--insert-for-yank (strs)
   (push (point) buffer-undo-list)
diff --git a/lisp/replace.el b/lisp/replace.el
index d6590c5..b6802ae 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -284,7 +284,7 @@ the original string if not."
          (and current-prefix-arg (not (eq current-prefix-arg '-)))
          (and current-prefix-arg (eq current-prefix-arg '-)))))
 
-(defun query-replace (from-string to-string &optional delimited start end 
backward)
+(defun query-replace (from-string to-string &optional delimited start end 
backward region-noncontiguous-p)
   "Replace some occurrences of FROM-STRING with TO-STRING.
 As each match is found, the user must type a character saying
 what to do with it.  For directions, type \\[help-command] at that time.
@@ -328,22 +328,21 @@ To customize possible responses, change the bindings in 
`query-replace-map'."
                   (if current-prefix-arg
                       (if (eq current-prefix-arg '-) " backward" " word")
                     "")
-                  (if (and transient-mark-mode mark-active) " in region" ""))
+                  (if (use-region-p) " in region" ""))
           nil)))
      (list (nth 0 common) (nth 1 common) (nth 2 common)
           ;; These are done separately here
           ;; so that command-history will record these expressions
           ;; rather than the values they had this time.
-          (if (and transient-mark-mode mark-active)
-              (region-beginning))
-          (if (and transient-mark-mode mark-active)
-              (region-end))
-          (nth 3 common))))
-  (perform-replace from-string to-string t nil delimited nil nil start end 
backward))
+          (if (use-region-p) (region-beginning))
+          (if (use-region-p) (region-end))
+          (nth 3 common)
+          (if (use-region-p) (region-noncontiguous-p)))))
+  (perform-replace from-string to-string t nil delimited nil nil start end 
backward region-noncontiguous-p))
 
 (define-key esc-map "%" 'query-replace)
 
-(defun query-replace-regexp (regexp to-string &optional delimited start end 
backward)
+(defun query-replace-regexp (regexp to-string &optional delimited start end 
backward region-noncontiguous-p)
   "Replace some things after point matching REGEXP with TO-STRING.
 As each match is found, the user must type a character saying
 what to do with it.  For directions, type \\[help-command] at that time.
@@ -408,18 +407,17 @@ Use \\[repeat-complex-command] after this command for 
details."
                       (if (eq current-prefix-arg '-) " backward" " word")
                     "")
                   " regexp"
-                  (if (and transient-mark-mode mark-active) " in region" ""))
+                  (if (use-region-p) " in region" ""))
           t)))
      (list (nth 0 common) (nth 1 common) (nth 2 common)
           ;; These are done separately here
           ;; so that command-history will record these expressions
           ;; rather than the values they had this time.
-          (if (and transient-mark-mode mark-active)
-              (region-beginning))
-          (if (and transient-mark-mode mark-active)
-              (region-end))
-          (nth 3 common))))
-  (perform-replace regexp to-string t t delimited nil nil start end backward))
+          (if (use-region-p) (region-beginning))
+          (if (use-region-p) (region-end))
+          (nth 3 common)
+          (if (use-region-p) (region-noncontiguous-p)))))
+  (perform-replace regexp to-string t t delimited nil nil start end backward 
region-noncontiguous-p))
 
 (define-key esc-map [?\C-%] 'query-replace-regexp)
 
@@ -485,10 +483,8 @@ for Lisp calls." "22.1"))
        ;; and the user might enter a single token.
        (replace-match-string-symbols to)
        (list from (car to) current-prefix-arg
-            (if (and transient-mark-mode mark-active)
-                (region-beginning))
-            (if (and transient-mark-mode mark-active)
-                (region-end))))))
+            (if (use-region-p) (region-beginning))
+            (if (use-region-p) (region-end))))))
   (perform-replace regexp (cons 'replace-eval-replacement to-expr)
                   t 'literal delimited nil nil start end))
 
@@ -523,10 +519,8 @@ Fourth and fifth arg START and END specify the region to 
operate on."
      (list from to
           (and current-prefix-arg
                (prefix-numeric-value current-prefix-arg))
-          (if (and transient-mark-mode mark-active)
-              (region-beginning))
-          (if (and transient-mark-mode mark-active)
-              (region-end)))))
+          (if (use-region-p) (region-beginning))
+          (if (use-region-p) (region-end)))))
   (let (replacements)
     (if (listp to-strings)
        (setq replacements to-strings)
@@ -587,13 +581,11 @@ and TO-STRING is also null.)"
                       (if (eq current-prefix-arg '-) " backward" " word")
                     "")
                   " string"
-                  (if (and transient-mark-mode mark-active) " in region" ""))
+                  (if (use-region-p) " in region" ""))
           nil)))
      (list (nth 0 common) (nth 1 common) (nth 2 common)
-          (if (and transient-mark-mode mark-active)
-              (region-beginning))
-          (if (and transient-mark-mode mark-active)
-              (region-end))
+          (if (use-region-p) (region-beginning))
+          (if (use-region-p) (region-end))
           (nth 3 common))))
   (perform-replace from-string to-string nil nil delimited nil nil start end 
backward))
 
@@ -661,13 +653,11 @@ which will run faster and will not set the mark or print 
anything."
                       (if (eq current-prefix-arg '-) " backward" " word")
                     "")
                   " regexp"
-                  (if (and transient-mark-mode mark-active) " in region" ""))
+                  (if (use-region-p) " in region" ""))
           t)))
      (list (nth 0 common) (nth 1 common) (nth 2 common)
-          (if (and transient-mark-mode mark-active)
-              (region-beginning))
-          (if (and transient-mark-mode mark-active)
-              (region-end))
+          (if (use-region-p) (region-beginning))
+          (if (use-region-p) (region-end))
           (nth 3 common))))
   (perform-replace regexp to-string nil t delimited nil nil start end 
backward))
 
@@ -832,7 +822,7 @@ a previously found match."
                  (unless (or (bolp) (eobp))
                    (forward-line 0))
                  (point-marker)))))
-    (if (and interactive transient-mark-mode mark-active)
+    (if (and interactive (use-region-p))
        (setq rstart (region-beginning)
              rend (progn
                     (goto-char (region-end))
@@ -901,7 +891,7 @@ starting on the same line at which another match ended is 
ignored."
       (progn
        (goto-char (min rstart rend))
        (setq rend (copy-marker (max rstart rend))))
-    (if (and interactive transient-mark-mode mark-active)
+    (if (and interactive (use-region-p))
        (setq rstart (region-beginning)
              rend (copy-marker (region-end)))
       (setq rstart (point)
@@ -951,7 +941,7 @@ a previously found match."
               (setq rend (max rstart rend)))
           (goto-char rstart)
           (setq rend (point-max)))
-      (if (and interactive transient-mark-mode mark-active)
+      (if (and interactive (use-region-p))
          (setq rstart (region-beginning)
                rend (region-end))
        (setq rstart (point)
@@ -2068,7 +2058,7 @@ It is called with three arguments, as if it were
 
 (defun perform-replace (from-string replacements
                        query-flag regexp-flag delimited-flag
-                       &optional repeat-count map start end backward)
+                       &optional repeat-count map start end backward 
region-noncontiguous-p)
   "Subroutine of `query-replace'.  Its complexity handles interactive queries.
 Don't use this in your own program unless you want to query and set the mark
 just as `query-replace' does.  Instead, write a simple loop like this:
@@ -2115,6 +2105,9 @@ It must return a string."
 
          ;; If non-nil, it is marker saying where in the buffer to stop.
          (limit nil)
+         ;; Use local binding in add-function below.
+         (isearch-filter-predicate isearch-filter-predicate)
+         (region-bounds nil)
 
          ;; Data for the next match.  If a cons, it has the same format as
          ;; (match-data); otherwise it is t if a match is possible at point.
@@ -2127,6 +2120,24 @@ It must return a string."
                       "Query replacing %s with %s: 
(\\<query-replace-map>\\[help] for help) ")
                      minibuffer-prompt-properties))))
 
+    ;; Unless a single contiguous chunk is selected, operate on multiple 
chunks.
+    (when region-noncontiguous-p
+      (setq region-bounds
+            (mapcar (lambda (position)
+                      (cons (copy-marker (car position))
+                            (copy-marker (cdr position))))
+                    (funcall region-extract-function 'bounds)))
+      (add-function :after-while isearch-filter-predicate
+                    (lambda (start end)
+                      (delq nil (mapcar
+                                 (lambda (bounds)
+                                   (and
+                                    (>= start (car bounds))
+                                    (<= start (cdr bounds))
+                                    (>= end   (car bounds))
+                                    (<= end   (cdr bounds))))
+                                 region-bounds)))))
+
     ;; If region is active, in Transient Mark mode, operate on region.
     (if backward
        (when end
diff --git a/lisp/simple.el b/lisp/simple.el
index b115a2a..deb5c88 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -970,15 +970,34 @@ instead of deleted."
 (defvar region-extract-function
   (lambda (delete)
     (when (region-beginning)
-      (if (eq delete 'delete-only)
-          (delete-region (region-beginning) (region-end))
-        (filter-buffer-substring (region-beginning) (region-end) delete))))
+      (cond
+       ((eq delete 'bounds)
+        (list (cons (region-beginning) (region-end))))
+       ((eq delete 'delete-only)
+        (delete-region (region-beginning) (region-end)))
+       (t
+        (filter-buffer-substring (region-beginning) (region-end) delete)))))
   "Function to get the region's content.
 Called with one argument DELETE.
 If DELETE is `delete-only', then only delete the region and the return value
 is undefined.  If DELETE is nil, just return the content as a string.
+If DELETE is `bounds', then don't delete, but just return the
+boundaries of the region as a list of (START . END) positions.
 If anything else, delete the region and return its content as a string.")
 
+(defvar region-insert-function
+  (lambda (lines)
+    (let ((first t))
+      (while lines
+        (or first
+            (insert ?\n))
+        (insert-for-yank (car lines))
+        (setq lines (cdr lines)
+              first nil))))
+  "Function to insert the region's content.
+Called with one argument LINES.
+Insert the region as a list of lines.")
+
 (defun delete-backward-char (n &optional killflag)
   "Delete the previous N characters (following if N is negative).
 If Transient Mark mode is enabled, the mark is active, and N is 1,
@@ -3419,7 +3438,8 @@ and only used if a buffer is displayed."
 
 (defun shell-command-on-region (start end command
                                      &optional output-buffer replace
-                                     error-buffer display-error-buffer)
+                                     error-buffer display-error-buffer
+                                     region-noncontiguous-p)
   "Execute string COMMAND in inferior shell with region as input.
 Normally display output (if any) in temp buffer `*Shell Command Output*';
 Prefix arg means replace the region with it.  Return the exit code of
@@ -3482,7 +3502,8 @@ interactively, this is t."
                       current-prefix-arg
                       current-prefix-arg
                       shell-command-default-error-buffer
-                      t)))
+                      t
+                      (region-noncontiguous-p))))
   (let ((error-file
         (if error-buffer
             (make-temp-file
@@ -3491,96 +3512,109 @@ interactively, this is t."
                                    temporary-file-directory)))
           nil))
        exit-status)
-    (if (or replace
-           (and output-buffer
-                (not (or (bufferp output-buffer) (stringp output-buffer)))))
-       ;; Replace specified region with output from command.
-       (let ((swap (and replace (< start end))))
-         ;; Don't muck with mark unless REPLACE says we should.
-         (goto-char start)
-         (and replace (push-mark (point) 'nomsg))
-         (setq exit-status
-               (call-process-region start end shell-file-name replace
-                                    (if error-file
-                                        (list t error-file)
-                                      t)
-                                    nil shell-command-switch command))
-         ;; It is rude to delete a buffer which the command is not using.
-         ;; (let ((shell-buffer (get-buffer "*Shell Command Output*")))
-         ;;   (and shell-buffer (not (eq shell-buffer (current-buffer)))
-         ;;     (kill-buffer shell-buffer)))
-         ;; Don't muck with mark unless REPLACE says we should.
-         (and replace swap (exchange-point-and-mark)))
-      ;; No prefix argument: put the output in a temp buffer,
-      ;; replacing its entire contents.
-      (let ((buffer (get-buffer-create
-                    (or output-buffer "*Shell Command Output*"))))
-       (unwind-protect
-           (if (eq buffer (current-buffer))
-               ;; If the input is the same buffer as the output,
-               ;; delete everything but the specified region,
-               ;; then replace that region with the output.
-               (progn (setq buffer-read-only nil)
-                      (delete-region (max start end) (point-max))
-                      (delete-region (point-min) (min start end))
-                      (setq exit-status
-                            (call-process-region (point-min) (point-max)
-                                                 shell-file-name t
-                                                 (if error-file
-                                                     (list t error-file)
-                                                   t)
-                                                 nil shell-command-switch
-                                                 command)))
-             ;; Clear the output buffer, then run the command with
-             ;; output there.
-             (let ((directory default-directory))
-               (with-current-buffer buffer
-                 (setq buffer-read-only nil)
-                 (if (not output-buffer)
-                     (setq default-directory directory))
-                 (erase-buffer)))
-             (setq exit-status
-                   (call-process-region start end shell-file-name nil
-                                        (if error-file
-                                            (list buffer error-file)
-                                          buffer)
-                                        nil shell-command-switch command)))
-         ;; Report the output.
-         (with-current-buffer buffer
-           (setq mode-line-process
-                 (cond ((null exit-status)
-                        " - Error")
-                       ((stringp exit-status)
-                        (format " - Signal [%s]" exit-status))
-                       ((not (equal 0 exit-status))
-                        (format " - Exit [%d]" exit-status)))))
-         (if (with-current-buffer buffer (> (point-max) (point-min)))
-             ;; There's some output, display it
-             (display-message-or-buffer buffer)
-           ;; No output; error?
-           (let ((output
-                  (if (and error-file
-                           (< 0 (nth 7 (file-attributes error-file))))
-                      (format "some error output%s"
-                              (if shell-command-default-error-buffer
-                                  (format " to the \"%s\" buffer"
-                                          shell-command-default-error-buffer)
-                                ""))
-                    "no output")))
-             (cond ((null exit-status)
-                    (message "(Shell command failed with error)"))
-                   ((equal 0 exit-status)
-                    (message "(Shell command succeeded with %s)"
-                             output))
-                   ((stringp exit-status)
-                    (message "(Shell command killed by signal %s)"
-                             exit-status))
-                   (t
-                    (message "(Shell command failed with code %d and %s)"
-                             exit-status output))))
-           ;; Don't kill: there might be useful info in the undo-log.
-           ;; (kill-buffer buffer)
-           ))))
+    ;; Unless a single contiguous chunk is selected, operate on multiple 
chunks.
+    (if region-noncontiguous-p
+        (let ((input (concat (funcall region-extract-function 'delete) "\n"))
+              output)
+          (with-temp-buffer
+            (insert input)
+            (call-process-region (point-min) (point-max)
+                                 shell-file-name t t
+                                 nil shell-command-switch
+                                 command)
+            (setq output (split-string (buffer-string) "\n")))
+          (goto-char start)
+          (funcall region-insert-function output))
+      (if (or replace
+              (and output-buffer
+                   (not (or (bufferp output-buffer) (stringp output-buffer)))))
+          ;; Replace specified region with output from command.
+          (let ((swap (and replace (< start end))))
+            ;; Don't muck with mark unless REPLACE says we should.
+            (goto-char start)
+            (and replace (push-mark (point) 'nomsg))
+            (setq exit-status
+                  (call-process-region start end shell-file-name replace
+                                       (if error-file
+                                           (list t error-file)
+                                         t)
+                                       nil shell-command-switch command))
+            ;; It is rude to delete a buffer which the command is not using.
+            ;; (let ((shell-buffer (get-buffer "*Shell Command Output*")))
+            ;;   (and shell-buffer (not (eq shell-buffer (current-buffer)))
+            ;;          (kill-buffer shell-buffer)))
+            ;; Don't muck with mark unless REPLACE says we should.
+            (and replace swap (exchange-point-and-mark)))
+        ;; No prefix argument: put the output in a temp buffer,
+        ;; replacing its entire contents.
+        (let ((buffer (get-buffer-create
+                       (or output-buffer "*Shell Command Output*"))))
+          (unwind-protect
+              (if (eq buffer (current-buffer))
+                  ;; If the input is the same buffer as the output,
+                  ;; delete everything but the specified region,
+                  ;; then replace that region with the output.
+                  (progn (setq buffer-read-only nil)
+                         (delete-region (max start end) (point-max))
+                         (delete-region (point-min) (min start end))
+                         (setq exit-status
+                               (call-process-region (point-min) (point-max)
+                                                    shell-file-name t
+                                                    (if error-file
+                                                        (list t error-file)
+                                                      t)
+                                                    nil shell-command-switch
+                                                    command)))
+                ;; Clear the output buffer, then run the command with
+                ;; output there.
+                (let ((directory default-directory))
+                  (with-current-buffer buffer
+                    (setq buffer-read-only nil)
+                    (if (not output-buffer)
+                        (setq default-directory directory))
+                    (erase-buffer)))
+                (setq exit-status
+                      (call-process-region start end shell-file-name nil
+                                           (if error-file
+                                               (list buffer error-file)
+                                             buffer)
+                                           nil shell-command-switch command)))
+            ;; Report the output.
+            (with-current-buffer buffer
+              (setq mode-line-process
+                    (cond ((null exit-status)
+                           " - Error")
+                          ((stringp exit-status)
+                           (format " - Signal [%s]" exit-status))
+                          ((not (equal 0 exit-status))
+                           (format " - Exit [%d]" exit-status)))))
+            (if (with-current-buffer buffer (> (point-max) (point-min)))
+                ;; There's some output, display it
+                (display-message-or-buffer buffer)
+              ;; No output; error?
+              (let ((output
+                     (if (and error-file
+                              (< 0 (nth 7 (file-attributes error-file))))
+                         (format "some error output%s"
+                                 (if shell-command-default-error-buffer
+                                     (format " to the \"%s\" buffer"
+                                             
shell-command-default-error-buffer)
+                                   ""))
+                       "no output")))
+                (cond ((null exit-status)
+                       (message "(Shell command failed with error)"))
+                      ((equal 0 exit-status)
+                       (message "(Shell command succeeded with %s)"
+                                output))
+                      ((stringp exit-status)
+                       (message "(Shell command killed by signal %s)"
+                                exit-status))
+                      (t
+                       (message "(Shell command failed with code %d and %s)"
+                                exit-status output))))
+              ;; Don't kill: there might be useful info in the undo-log.
+              ;; (kill-buffer buffer)
+              )))))
 
     (when (and error-file (file-exists-p error-file))
       (if (< 0 (nth 7 (file-attributes error-file)))
@@ -5175,6 +5209,11 @@ also checks the value of `use-empty-active-region'."
        ;; region is active when there's no mark.
        (progn (cl-assert (mark)) t)))
 
+(defun region-noncontiguous-p ()
+  "Return non-nil if the region contains several pieces.
+An example is a rectangular region handled as a list of
+separate contiguous regions for each line."
+  (> (length (funcall region-extract-function 'bounds)) 1))
 
 (defvar redisplay-unhighlight-region-function
   (lambda (rol) (when (overlayp rol) (delete-overlay rol))))
diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el
index a5d9f37..bafe3e5 100644
--- a/lisp/url/url-handlers.el
+++ b/lisp/url/url-handlers.el
@@ -309,6 +309,29 @@ They count bytes from the beginning of the body."
 
 (defvar url-http-codes)
 
+(defun url-insert-buffer-contents (buffer url &optional visit beg end replace)
+  "Insert the contents of BUFFER into current buffer.
+This is like `url-insert', but also decodes the current buffer as
+if it had been inserted from a file named URL."
+  (if visit (setq buffer-file-name url))
+  (save-excursion
+    (let* ((start (point))
+           (size-and-charset (url-insert buffer beg end)))
+      (kill-buffer buffer)
+      (when replace
+        (delete-region (point-min) start)
+        (delete-region (point) (point-max)))
+      (unless (cadr size-and-charset)
+        ;; If the headers don't specify any particular charset, use the
+        ;; usual heuristic/rules that we apply to files.
+        (decode-coding-inserted-region (point-min) (point) url
+                                       visit beg end replace))
+      (let ((inserted (car size-and-charset)))
+        (when (fboundp 'after-insert-file-set-coding)
+          (let ((insval (after-insert-file-set-coding inserted visit)))
+            (if insval (setq inserted insval))))
+        (list url inserted)))))
+
 ;;;###autoload
 (defun url-insert-file-contents (url &optional visit beg end replace)
   (let ((buffer (url-retrieve-synchronously url)))
@@ -323,24 +346,7 @@ They count bytes from the beginning of the body."
             (kill-buffer buffer)
             ;; Signal file-error per http://debbugs.gnu.org/16733.
             (signal 'file-error (list url desc))))))
-    (if visit (setq buffer-file-name url))
-    (save-excursion
-      (let* ((start (point))
-             (size-and-charset (url-insert buffer beg end)))
-        (kill-buffer buffer)
-        (when replace
-          (delete-region (point-min) start)
-          (delete-region (point) (point-max)))
-        (unless (cadr size-and-charset)
-          ;; If the headers don't specify any particular charset, use the
-          ;; usual heuristic/rules that we apply to files.
-          (decode-coding-inserted-region start (point) url
-                                         visit beg end replace))
-        (let ((inserted (car size-and-charset)))
-          (when (fboundp 'after-insert-file-set-coding)
-            (let ((insval (after-insert-file-set-coding inserted visit)))
-              (if insval (setq inserted insval))))
-          (list url inserted))))))
+    (url-insert-buffer-contents buffer url visit beg end replace)))
 
 (put 'insert-file-contents 'url-file-handlers 'url-insert-file-contents)
 
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 464e375..f4d7fe7 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1821,7 +1821,7 @@ With a prefix argument, try to REVERSE the hunk."
   "Kill all hunks that have already been applied starting at point."
   (interactive)
   (while (not (eobp))
-    (pcase-let ((`(,buf ,line-offset ,pos ,src ,_dst ,switched)
+    (pcase-let ((`(,_buf ,line-offset ,_pos ,_src ,_dst ,switched)
                  (diff-find-source-location nil nil)))
       (if (and line-offset switched)
           (diff-hunk-kill)
diff --git a/msdos/sed2v2.inp b/msdos/sed2v2.inp
index e1609f2..c82b27a 100644
--- a/msdos/sed2v2.inp
+++ b/msdos/sed2v2.inp
@@ -66,7 +66,7 @@
 /^#undef PACKAGE_TARNAME/s/^.*$/#define PACKAGE_TARNAME ""/
 /^#undef PACKAGE_VERSION/s/^.*$/#define PACKAGE_VERSION ""/
 /^#undef PENDING_OUTPUT_COUNT/s/^.*$/#define PENDING_OUTPUT_COUNT(FILE) 
((FILE)->_ptr - (FILE)->_base)/
-/^#undef VERSION/s/^.*$/#define VERSION "25.0.50"/
+/^#undef VERSION/s/^.*$/#define VERSION "25.1.50"/
 /^#undef SYSTEM_TYPE/s/^.*$/#define SYSTEM_TYPE "ms-dos"/
 /^#undef HAVE_DECL_GETENV/s/^.*$/#define HAVE_DECL_GETENV 1/
 /^#undef SYS_SIGLIST_DECLARED/s/^.*$/#define SYS_SIGLIST_DECLARED 1/
diff --git a/src/Makefile.in b/src/Makefile.in
index 859bc1b..8a523bb 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -163,12 +163,13 @@ SETTINGS_LIBS = @SETTINGS_LIBS@
 ## gtkutil.o if USE_GTK, else empty.
 address@hidden@
 
-## gfilenotify.o if HAVE_GFILENOTIFY.
 ## inotify.o if HAVE_INOTIFY.
+## kqueue.o if HAVE_KQUEUE.
+## gfilenotify.o if HAVE_GFILENOTIFY.
 ## w32notify.o if HAVE_W32NOTIFY.
 NOTIFY_OBJ = @NOTIFY_OBJ@
-GFILENOTIFY_CFLAGS = @GFILENOTIFY_CFLAGS@
-GFILENOTIFY_LIBS = @GFILENOTIFY_LIBS@
+NOTIFY_CFLAGS = @NOTIFY_CFLAGS@
+NOTIFY_LIBS = @NOTIFY_LIBS@
 
 ## -ltermcap, or -lncurses, or -lcurses, or "".
 address@hidden@
@@ -364,7 +365,7 @@ ALL_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I$(srcdir) \
   $(WEBKIT_CFLAGS) $(GIR_CFLAGS) \
   $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \
   $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) \
-  $(LIBGNUTLS_CFLAGS) $(GFILENOTIFY_CFLAGS) $(CAIRO_CFLAGS) \
+  $(LIBGNUTLS_CFLAGS) $(NOTIFY_CFLAGS) $(CAIRO_CFLAGS) \
   $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS)
 ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS)
 
@@ -479,7 +480,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) 
$(LIBIMAGE) \
    $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
    $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
    $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) \
-   $(GFILENOTIFY_LIBS) $(LIB_MATH) $(LIBZ)
+   $(NOTIFY_LIBS) $(LIB_MATH) $(LIBZ)
 
 $(leimdir)/leim-list.el: bootstrap-emacs$(EXEEXT)
        $(MAKE) -C ../leim leim-list.el EMACS="$(bootstrap_exe)"
diff --git a/src/casefiddle.c b/src/casefiddle.c
index b94ea8e..6a2983e 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -306,14 +306,30 @@ See also `capitalize-region'.  */)
   return Qnil;
 }
 
-DEFUN ("downcase-region", Fdowncase_region, Sdowncase_region, 2, 2, "r",
+DEFUN ("downcase-region", Fdowncase_region, Sdowncase_region, 2, 3,
+       "(list (region-beginning) (region-end) (region-noncontiguous-p))",
        doc: /* Convert the region to lower case.  In programs, wants two 
arguments.
 These arguments specify the starting and ending character numbers of
 the region to operate on.  When used as a command, the text between
 point and the mark is operated on.  */)
-  (Lisp_Object beg, Lisp_Object end)
+  (Lisp_Object beg, Lisp_Object end, Lisp_Object region_noncontiguous_p)
 {
-  casify_region (CASE_DOWN, beg, end);
+  Lisp_Object bounds = Qnil;
+
+  if (!NILP (region_noncontiguous_p))
+    {
+      bounds = call1 (Fsymbol_value (intern ("region-extract-function")),
+                     intern ("bounds"));
+
+      while (CONSP (bounds))
+       {
+         casify_region (CASE_DOWN, XCAR (XCAR (bounds)), XCDR (XCAR (bounds)));
+         bounds = XCDR (bounds);
+       }
+    }
+  else
+    casify_region (CASE_DOWN, beg, end);
+
   return Qnil;
 }
 
diff --git a/src/emacs.c b/src/emacs.c
index 825b3c1..d0b1eac 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1353,6 +1353,10 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
     tzset ();
 #endif /* MSDOS */
 
+#ifdef HAVE_KQUEUE
+  globals_of_kqueue ();
+#endif
+
 #ifdef HAVE_GFILENOTIFY
   globals_of_gfilenotify ();
 #endif
@@ -1526,14 +1530,18 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
 
       syms_of_gnutls ();
 
-#ifdef HAVE_GFILENOTIFY
-      syms_of_gfilenotify ();
-#endif /* HAVE_GFILENOTIFY */
-
 #ifdef HAVE_INOTIFY
       syms_of_inotify ();
 #endif /* HAVE_INOTIFY */
 
+#ifdef HAVE_KQUEUE
+      syms_of_kqueue ();
+#endif /* HAVE_KQUEUE */
+
+#ifdef HAVE_GFILENOTIFY
+      syms_of_gfilenotify ();
+#endif /* HAVE_GFILENOTIFY */
+
 #ifdef HAVE_DBUS
       syms_of_dbusbind ();
 #endif /* HAVE_DBUS */
diff --git a/src/ftfont.c b/src/ftfont.c
index 57ded17..17e41a9 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1776,9 +1776,11 @@ setup_otf_gstring (int size)
 {
   if (otf_gstring.size < size)
     {
-      otf_gstring.glyphs = xnrealloc (otf_gstring.glyphs,
-                                     size, sizeof (OTF_Glyph));
-      otf_gstring.size = size;
+      ptrdiff_t new_size = otf_gstring.size;
+      xfree (otf_gstring.glyphs);
+      otf_gstring.glyphs = xpalloc (NULL, &new_size, size - otf_gstring.size,
+                                   INT_MAX, sizeof *otf_gstring.glyphs);
+      otf_gstring.size = new_size;
     }
   otf_gstring.used = size;
   memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * size);
@@ -2505,8 +2507,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font 
*font,
   ptrdiff_t i;
   struct MFLTFontFT flt_font_ft;
   MFLT *flt = NULL;
-  bool with_variation_selector = 0;
-  MFLTGlyphFT *glyphs;
+  bool with_variation_selector = false;
 
   if (! m17n_flt_initialized)
     {
@@ -2527,7 +2528,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font 
*font,
        break;
       c = LGLYPH_CHAR (g);
       if (CHAR_VARIATION_SELECTOR_P (c))
-       with_variation_selector = 1;
+       with_variation_selector = true;
     }
 
   len = i;
@@ -2561,39 +2562,6 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font 
*font,
        }
     }
 
-  int len2;
-  if (INT_MULTIPLY_WRAPV (len, 2, &len2))
-    memory_full (SIZE_MAX);
-
-  if (gstring.allocated == 0)
-    {
-      gstring.glyph_size = sizeof (MFLTGlyphFT);
-      gstring.glyphs = xnmalloc (len2, sizeof (MFLTGlyphFT));
-      gstring.allocated = len2;
-    }
-  else if (gstring.allocated < len2)
-    {
-      gstring.glyphs = xnrealloc (gstring.glyphs, len2,
-                                 sizeof (MFLTGlyphFT));
-      gstring.allocated = len2;
-    }
-  glyphs = (MFLTGlyphFT *) (gstring.glyphs);
-  memset (glyphs, 0, len * sizeof (MFLTGlyphFT));
-  for (i = 0; i < len; i++)
-    {
-      Lisp_Object g = LGSTRING_GLYPH (lgstring, i);
-
-      glyphs[i].g.c = LGLYPH_CHAR (g);
-      if (with_variation_selector)
-       {
-         glyphs[i].g.code = LGLYPH_CODE (g);
-         glyphs[i].g.encoded = 1;
-       }
-    }
-
-  gstring.used = len;
-  gstring.r2l = 0;
-
   {
     Lisp_Object family = Ffont_get (LGSTRING_FONT (lgstring), QCfamily);
 
@@ -2614,24 +2582,50 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font 
*font,
   flt_font_ft.ft_face = ft_face;
   flt_font_ft.otf = otf;
   flt_font_ft.matrix = matrix->xx != 0 ? matrix : 0;
-  if (len > 1
-      && gstring.glyphs[1].c >= 0x300 && gstring.glyphs[1].c <= 0x36F)
-    /* A little bit ad hoc.  Perhaps, shaper must get script and
-       language information, and select a proper flt for them
-       here.  */
-    flt = mflt_get (msymbol ("combining"));
-  for (i = 0; i < 3; i++)
-    {
-      int result = mflt_run (&gstring, 0, len, &flt_font_ft.flt_font, flt);
-      if (result != -2)
-       break;
-      int len2;
-      if (INT_MULTIPLY_WRAPV (gstring.allocated, 2, &len2))
-       memory_full (SIZE_MAX);
-      gstring.glyphs = xnrealloc (gstring.glyphs,
-                                 gstring.allocated, 2 * sizeof (MFLTGlyphFT));
-      gstring.allocated = len2;
+
+  if (1 < len)
+    {
+      /* A little bit ad hoc.  Perhaps, shaper must get script and
+        language information, and select a proper flt for them
+        here.  */
+      int c1 = LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, 1));
+      if (0x300 <= c1 && c1 <= 0x36F)
+       flt = mflt_get (msymbol ("combining"));
+    }
+
+  MFLTGlyphFT *glyphs = (MFLTGlyphFT *) gstring.glyphs;
+  ptrdiff_t allocated = gstring.allocated;
+  ptrdiff_t incr_min = len - allocated;
+
+  do
+    {
+      if (0 < incr_min)
+       {
+         xfree (glyphs);
+         glyphs = xpalloc (NULL, &allocated, incr_min, INT_MAX, sizeof 
*glyphs);
+       }
+      incr_min = 1;
+
+      for (i = 0; i < len; i++)
+       {
+         Lisp_Object g = LGSTRING_GLYPH (lgstring, i);
+         memset (&glyphs[i], 0, sizeof glyphs[i]);
+         glyphs[i].g.c = LGLYPH_CHAR (g);
+         if (with_variation_selector)
+           {
+             glyphs[i].g.code = LGLYPH_CODE (g);
+             glyphs[i].g.encoded = 1;
+           }
+       }
+
+      gstring.glyph_size = sizeof *glyphs;
+      gstring.glyphs = (MFLTGlyph *) glyphs;
+      gstring.allocated = allocated;
+      gstring.used = len;
+      gstring.r2l = 0;
     }
+  while (mflt_run (&gstring, 0, len, &flt_font_ft.flt_font, flt) == -2);
+
   if (gstring.used > LGSTRING_GLYPH_LEN (lgstring))
     return Qnil;
   for (i = 0; i < gstring.used; i++)
diff --git a/src/inotify.c b/src/inotify.c
index d1a80bb..6577ee2 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -46,8 +46,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 static int inotifyfd = -1;
 
 /* Assoc list of files being watched.
-   Format:
-   (watch-descriptor . callback)
+   Format: (watch-descriptor name callback)
  */
 static Lisp_Object watch_list;
 
@@ -106,12 +105,14 @@ inotifyevent_to_event (Lisp_Object watch_object, struct 
inotify_event const *ev)
       name = make_unibyte_string (ev->name, min (len, ev->len));
       name = DECODE_FILE (name);
     }
+  else
+    name = XCAR (XCDR (watch_object));
 
   return list2 (list4 (make_watch_descriptor (ev->wd),
                        mask_to_aspects (ev->mask),
                        name,
                        make_number (ev->cookie)),
-                XCDR (watch_object));
+               Fnth (make_number (2), watch_object));
 }
 
 /* This callback is called when the FD is available for read.  The inotify
@@ -325,7 +326,7 @@ is managed internally and there is no corresponding 
inotify_init.  Use
       watch_list = Fdelete (watch_object, watch_list);
 
   /* Store watch object in watch list.  */
-  watch_object = Fcons (watch_descriptor, callback);
+  watch_object = list3 (watch_descriptor, encoded_file_name, callback);
   watch_list = Fcons (watch_object, watch_list);
 
   return watch_descriptor;
diff --git a/src/keyboard.c b/src/keyboard.c
index 92ef21a..b36431e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5960,12 +5960,12 @@ make_lispy_event (struct input_event *event)
 #endif
 
 
-#if defined HAVE_GFILENOTIFY || defined HAVE_INOTIFY
+#if defined HAVE_INOTIFY || defined HAVE_KQUEUE || defined HAVE_GFILENOTIFY
     case FILE_NOTIFY_EVENT:
       {
         return Fcons (Qfile_notify, event->arg);
       }
-#endif /* defined HAVE_GFILENOTIFY || defined HAVE_INOTIFY */
+#endif /* HAVE_INOTIFY || HAVE_KQUEUE || HAVE_GFILENOTIFY */
 
     case CONFIG_CHANGED_EVENT:
        return list3 (Qconfig_changed_event,
diff --git a/src/kqueue.c b/src/kqueue.c
new file mode 100644
index 0000000..1830040
--- /dev/null
+++ b/src/kqueue.c
@@ -0,0 +1,520 @@
+/* Filesystem notifications support with kqueue API.
+   Copyright (C) 2015 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#ifdef HAVE_KQUEUE
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/event.h>
+#include <sys/time.h>
+#include <sys/file.h>
+#include "lisp.h"
+#include "keyboard.h"
+#include "process.h"
+
+
+/* File handle for kqueue.  */
+static int kqueuefd = -1;
+
+/* This is a list, elements are (DESCRIPTOR FILE FLAGS CALLBACK [DIRLIST]).  */
+static Lisp_Object watch_list;
+
+/* Generate a list from the directory_files_internal output.
+   Items are (INODE FILE-NAME LAST-MOD LAST-STATUS-MOD SIZE).  */
+Lisp_Object
+kqueue_directory_listing (Lisp_Object directory_files)
+{
+  Lisp_Object dl, result = Qnil;
+
+  for (dl = directory_files; ! NILP (dl); dl = XCDR (dl)) {
+    /* We ignore "." and "..".  */
+    if ((strcmp (".", SSDATA (XCAR (XCAR (dl)))) == 0) ||
+       (strcmp ("..", SSDATA (XCAR (XCAR (dl)))) == 0))
+      continue;
+
+    result = Fcons
+      (list5 (/* inode.  */
+             Fnth (make_number (11), XCAR (dl)),
+             /* filename.  */
+             XCAR (XCAR (dl)),
+             /* last modification time.  */
+             Fnth (make_number (6), XCAR (dl)),
+             /* last status change time.  */
+             Fnth (make_number (7), XCAR (dl)),
+             /* size.  */
+             Fnth (make_number (8), XCAR (dl))),
+       result);
+  }
+  return result;
+}
+
+/* Generate a file notification event.  */
+static void
+kqueue_generate_event
+(Lisp_Object watch_object, Lisp_Object actions,
+ Lisp_Object file, Lisp_Object file1)
+{
+  Lisp_Object flags, action, entry;
+  struct input_event event;
+
+  /* Check, whether all actions shall be monitored.  */
+  flags = Fnth (make_number (2), watch_object);
+  action = actions;
+  do {
+    if (NILP (action))
+      break;
+    entry = XCAR (action);
+    if (NILP (Fmember (entry, flags))) {
+      action = XCDR (action);
+      actions = Fdelq (entry, actions);
+    } else
+      action = XCDR (action);
+  } while (1);
+
+  /* Store it into the input event queue.  */
+  if (! NILP (actions)) {
+    EVENT_INIT (event);
+    event.kind = FILE_NOTIFY_EVENT;
+    event.frame_or_window = Qnil;
+    event.arg = list2 (Fcons (XCAR (watch_object),
+                             Fcons (actions,
+                                    NILP (file1)
+                                    ? Fcons (file, Qnil)
+                                    : list2 (file, file1))),
+                      Fnth (make_number (3), watch_object));
+    kbd_buffer_store_event (&event);
+  }
+}
+
+/* This compares two directory listings in case of a `write' event for
+   a directory.  Generate resulting file notification events.  The old
+   directory listing is retrieved from watch_object, it will be
+   replaced by the new directory listing at the end of this
+   function.  */
+static void
+kqueue_compare_dir_list
+(Lisp_Object watch_object)
+{
+  Lisp_Object dir, pending_dl, deleted_dl;
+  Lisp_Object old_directory_files, old_dl, new_directory_files, new_dl, dl;
+
+  dir = XCAR (XCDR (watch_object));
+  pending_dl = Qnil;
+  deleted_dl = Qnil;
+
+  old_directory_files = Fnth (make_number (4), watch_object);
+  old_dl = kqueue_directory_listing (old_directory_files);
+
+  /* When the directory is not accessible anymore, it has been deleted.  */
+  if (NILP (Ffile_directory_p (dir))) {
+    kqueue_generate_event (watch_object, Fcons (Qdelete, Qnil), dir, Qnil);
+    return;
+  }
+  new_directory_files =
+    directory_files_internal (dir, Qnil, Qnil, Qnil, 1, Qnil);
+  new_dl = kqueue_directory_listing (new_directory_files);
+
+  /* Parse through the old list.  */
+  dl = old_dl;
+  while (1) {
+    Lisp_Object old_entry, new_entry, dl1;
+    if (NILP (dl))
+      break;
+
+    /* Search for an entry with the same inode.  */
+    old_entry = XCAR (dl);
+    new_entry = assq_no_quit (XCAR (old_entry), new_dl);
+    if (! NILP (Fequal (old_entry, new_entry))) {
+      /* Both entries are identical.  Nothing to do.  */
+      new_dl = Fdelq (new_entry, new_dl);
+      goto the_end;
+    }
+
+    /* Both entries have the same inode.  */
+    if (! NILP (new_entry)) {
+      /* Both entries have the same file name.  */
+      if (strcmp (SSDATA (XCAR (XCDR (old_entry))),
+                 SSDATA (XCAR (XCDR (new_entry)))) == 0) {
+       /* Modification time has been changed, the file has been written.  */
+       if (NILP (Fequal (Fnth (make_number (2), old_entry),
+                         Fnth (make_number (2), new_entry))))
+         kqueue_generate_event
+           (watch_object, Fcons (Qwrite, Qnil), XCAR (XCDR (old_entry)), Qnil);
+       /* Status change time has been changed, the file attributes
+          have changed.  */
+         if (NILP (Fequal (Fnth (make_number (3), old_entry),
+                           Fnth (make_number (3), new_entry))))
+         kqueue_generate_event
+           (watch_object, Fcons (Qattrib, Qnil),
+            XCAR (XCDR (old_entry)), Qnil);
+
+      } else {
+       /* The file has been renamed.  */
+       kqueue_generate_event
+         (watch_object, Fcons (Qrename, Qnil),
+          XCAR (XCDR (old_entry)), XCAR (XCDR (new_entry)));
+       deleted_dl = Fcons (new_entry, deleted_dl);
+      }
+      new_dl = Fdelq (new_entry, new_dl);
+      goto the_end;
+    }
+
+    /* Search, whether there is a file with the same name but another
+       inode.  */
+    for (dl1 = new_dl; ! NILP (dl1); dl1 = XCDR (dl1)) {
+      new_entry = XCAR (dl1);
+      if (strcmp (SSDATA (XCAR (XCDR (old_entry))),
+                 SSDATA (XCAR (XCDR (new_entry)))) == 0) {
+       pending_dl = Fcons (new_entry, pending_dl);
+       new_dl = Fdelq (new_entry, new_dl);
+       goto the_end;
+      }
+    }
+
+    /* Check, whether this a pending file.  */
+    new_entry = assq_no_quit (XCAR (old_entry), pending_dl);
+
+    if (NILP (new_entry)) {
+      /* Check, whether this is an already deleted file (by rename).  */
+      for (dl1 = deleted_dl; ! NILP (dl1); dl1 = XCDR (dl1)) {
+       new_entry = XCAR (dl1);
+       if (strcmp (SSDATA (XCAR (XCDR (old_entry))),
+                   SSDATA (XCAR (XCDR (new_entry)))) == 0) {
+         deleted_dl = Fdelq (new_entry, deleted_dl);
+         goto the_end;
+       }
+      }
+      /* The file has been deleted.  */
+      kqueue_generate_event
+       (watch_object, Fcons (Qdelete, Qnil), XCAR (XCDR (old_entry)), Qnil);
+
+    } else {
+      /* The file has been renamed.  */
+      kqueue_generate_event
+       (watch_object, Fcons (Qrename, Qnil),
+        XCAR (XCDR (old_entry)), XCAR (XCDR (new_entry)));
+      pending_dl = Fdelq (new_entry, pending_dl);
+    }
+
+  the_end:
+    dl = XCDR (dl);
+    old_dl = Fdelq (old_entry, old_dl);
+  }
+
+  /* Parse through the resulting new list.  */
+  dl = new_dl;
+  while (1) {
+    Lisp_Object entry;
+    if (NILP (dl))
+      break;
+
+    /* A new file has appeared.  */
+    entry = XCAR (dl);
+    kqueue_generate_event
+      (watch_object, Fcons (Qcreate, Qnil), XCAR (XCDR (entry)), Qnil);
+
+    /* Check size of that file.  */
+    Lisp_Object size = Fnth (make_number (4), entry);
+    if (FLOATP (size) || (XINT (size) > 0))
+      kqueue_generate_event
+       (watch_object, Fcons (Qwrite, Qnil), XCAR (XCDR (entry)), Qnil);
+
+    dl = XCDR (dl);
+    new_dl = Fdelq (entry, new_dl);
+  }
+
+  /* Parse through the resulting pending_dl list.  */
+  dl = pending_dl;
+  while (1) {
+    Lisp_Object entry;
+    if (NILP (dl))
+      break;
+
+    /* A file is still pending.  Assume it was a write.  */
+    entry = XCAR (dl);
+    kqueue_generate_event
+      (watch_object, Fcons (Qwrite, Qnil), XCAR (XCDR (entry)), Qnil);
+
+    dl = XCDR (dl);
+    pending_dl = Fdelq (entry, pending_dl);
+  }
+
+  /* At this point, old_dl, new_dl and pending_dl shall be empty.
+     deleted_dl might not be empty when there was a rename to a
+     nonexisting file.  Let's make a check for this (might be removed
+     once the code is stable).  */
+  if (! NILP (old_dl))
+    report_file_error ("Old list not empty", old_dl);
+  if (! NILP (new_dl))
+    report_file_error ("New list not empty", new_dl);
+  if (! NILP (pending_dl))
+    report_file_error ("Pending events list not empty", pending_dl);
+  //  if (! NILP (deleted_dl))
+  //    report_file_error ("Deleted events list not empty", deleted_dl);
+
+  /* Replace old directory listing with the new one.  */
+  XSETCDR (Fnthcdr (make_number (3), watch_object),
+          Fcons (new_directory_files, Qnil));
+  return;
+}
+
+/* This is the callback function for arriving input on kqueuefd.  It
+   shall create a Lisp event, and put it into the Emacs input queue.  */
+static void
+kqueue_callback (int fd, void *data)
+{
+  for (;;) {
+    struct kevent kev;
+    static const struct timespec nullts = { 0, 0 };
+    Lisp_Object descriptor, watch_object, file, actions;
+
+    /* Read one event.  */
+    int ret = kevent (kqueuefd, NULL, 0, &kev, 1, &nullts);
+    if (ret < 1) {
+      /* All events read.  */
+      return;
+    }
+
+    /* Determine descriptor and file name.  */
+    descriptor = make_number (kev.ident);
+    watch_object = assq_no_quit (descriptor, watch_list);
+    if (CONSP (watch_object))
+      file = XCAR (XCDR (watch_object));
+    else
+      continue;
+
+    /* Determine event actions.  */
+    actions = Qnil;
+    if (kev.fflags & NOTE_DELETE)
+      actions = Fcons (Qdelete, actions);
+    if (kev.fflags & NOTE_WRITE) {
+      /* Check, whether this is a directory event.  */
+      if (NILP (Fnth (make_number (4), watch_object)))
+       actions = Fcons (Qwrite, actions);
+      else
+       kqueue_compare_dir_list (watch_object);
+    }
+    if (kev.fflags & NOTE_EXTEND)
+      actions = Fcons (Qextend, actions);
+    if (kev.fflags & NOTE_ATTRIB)
+      actions = Fcons (Qattrib, actions);
+    if (kev.fflags & NOTE_LINK)
+      actions = Fcons (Qlink, actions);
+    /* It would be useful to know the target of the rename operation.
+       At this point, it is not possible.  Happens only when the upper
+       directory is monitored.  */
+    if (kev.fflags & NOTE_RENAME)
+      actions = Fcons (Qrename, actions);
+
+    /* Create the event.  */
+    if (! NILP (actions))
+      kqueue_generate_event (watch_object, actions, file, Qnil);
+
+    /* Cancel monitor if file or directory is deleted or renamed.  */
+    if (kev.fflags & (NOTE_DELETE | NOTE_RENAME))
+      Fkqueue_rm_watch (descriptor);
+  }
+  return;
+}
+
+DEFUN ("kqueue-add-watch", Fkqueue_add_watch, Skqueue_add_watch, 3, 3, 0,
+       doc: /* Add a watch for filesystem events pertaining to FILE.
+
+This arranges for filesystem events pertaining to FILE to be reported
+to Emacs.  Use `kqueue-rm-watch' to cancel the watch.
+
+Returned value is a descriptor for the added watch.  If the file cannot be
+watched for some reason, this function signals a `file-notify-error' error.
+
+FLAGS is a list of events to be watched for.  It can include the
+following symbols:
+
+  `create' -- FILE was created
+  `delete' -- FILE was deleted
+  `write'  -- FILE has changed
+  `extend' -- FILE was extended
+  `attrib' -- a FILE attribute was changed
+  `link'   -- a FILE's link count was changed
+  `rename' -- FILE was moved to FILE1
+
+When any event happens, Emacs will call the CALLBACK function passing
+it a single argument EVENT, which is of the form
+
+  (DESCRIPTOR ACTIONS FILE [FILE1])
+
+DESCRIPTOR is the same object as the one returned by this function.
+ACTIONS is a list of events.
+
+FILE is the name of the file whose event is being reported.  FILE1
+will be reported only in case of the `rename' event.  This is possible
+only when the upper directory of the renamed file is watched.  */)
+  (Lisp_Object file, Lisp_Object flags, Lisp_Object callback)
+{
+  Lisp_Object watch_object, dir_list;
+  int fd, oflags;
+  u_short fflags = 0;
+  struct kevent kev;
+
+  /* Check parameters.  */
+  CHECK_STRING (file);
+  file = Fdirectory_file_name (Fexpand_file_name (file, Qnil));
+  if (NILP (Ffile_exists_p (file)))
+    report_file_error ("File does not exist", file);
+
+  CHECK_LIST (flags);
+
+  if (! FUNCTIONP (callback))
+    wrong_type_argument (Qinvalid_function, callback);
+
+  if (kqueuefd < 0)
+    {
+      /* Create kqueue descriptor.  */
+      kqueuefd = kqueue ();
+      if (kqueuefd < 0)
+       report_file_notify_error ("File watching is not available", Qnil);
+
+      /* Start monitoring for possible I/O.  */
+      add_read_fd (kqueuefd, kqueue_callback, NULL);
+
+      watch_list = Qnil;
+    }
+
+  /* Open file.  */
+  file = ENCODE_FILE (file);
+  oflags = O_NONBLOCK;
+#if O_EVTONLY
+  oflags |= O_EVTONLY;
+#else
+  oflags |= O_RDONLY;
+#endif
+#if O_SYMLINK
+    oflags |= O_SYMLINK;
+#else
+    oflags |= O_NOFOLLOW;
+#endif
+  fd = emacs_open (SSDATA (file), oflags, 0);
+  if (fd == -1)
+    report_file_error ("File cannot be opened", file);
+
+  /* Assemble filter flags  */
+  if (! NILP (Fmember (Qdelete, flags))) fflags |= NOTE_DELETE;
+  if (! NILP (Fmember (Qwrite, flags)))  fflags |= NOTE_WRITE;
+  if (! NILP (Fmember (Qextend, flags))) fflags |= NOTE_EXTEND;
+  if (! NILP (Fmember (Qattrib, flags))) fflags |= NOTE_ATTRIB;
+  if (! NILP (Fmember (Qlink, flags)))   fflags |= NOTE_LINK;
+  if (! NILP (Fmember (Qrename, flags))) fflags |= NOTE_RENAME;
+
+  /* Register event.  */
+  EV_SET (&kev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR,
+         fflags, 0, NULL);
+
+  if (kevent (kqueuefd, &kev, 1, NULL, 0, NULL) < 0) {
+    emacs_close (fd);
+    report_file_error ("Cannot watch file", file);
+  }
+
+  /* Store watch object in watch list.  */
+  Lisp_Object watch_descriptor = make_number (fd);
+  if (NILP (Ffile_directory_p (file)))
+    watch_object = list4 (watch_descriptor, file, flags, callback);
+  else {
+    dir_list = directory_files_internal (file, Qnil, Qnil, Qnil, 1, Qnil);
+    watch_object = list5 (watch_descriptor, file, flags, callback, dir_list);
+  }
+  watch_list = Fcons (watch_object, watch_list);
+
+  return watch_descriptor;
+}
+
+DEFUN ("kqueue-rm-watch", Fkqueue_rm_watch, Skqueue_rm_watch, 1, 1, 0,
+       doc: /* Remove an existing WATCH-DESCRIPTOR.
+
+WATCH-DESCRIPTOR should be an object returned by `kqueue-add-watch'.  */)
+     (Lisp_Object watch_descriptor)
+{
+  Lisp_Object watch_object = assq_no_quit (watch_descriptor, watch_list);
+
+  if (! CONSP (watch_object))
+    xsignal2 (Qfile_notify_error, build_string ("Not a watch descriptor"),
+             watch_descriptor);
+
+  eassert (INTEGERP (watch_descriptor));
+  int fd = XINT (watch_descriptor);
+  if ( fd >= 0)
+    emacs_close (fd);
+
+  /* Remove watch descriptor from watch list.  */
+  watch_list = Fdelq (watch_object, watch_list);
+
+  if (NILP (watch_list) && (kqueuefd >= 0)) {
+    delete_read_fd (kqueuefd);
+    emacs_close (kqueuefd);
+    kqueuefd = -1;
+  }
+
+  return Qt;
+}
+
+DEFUN ("kqueue-valid-p", Fkqueue_valid_p, Skqueue_valid_p, 1, 1, 0,
+       doc: /* "Check a watch specified by its WATCH-DESCRIPTOR.
+
+WATCH-DESCRIPTOR should be an object returned by `kqueue-add-watch'.
+
+A watch can become invalid if the file or directory it watches is
+deleted, or if the watcher thread exits abnormally for any other
+reason.  Removing the watch by calling `kqueue-rm-watch' also makes it
+invalid.  */)
+     (Lisp_Object watch_descriptor)
+{
+  return NILP (assq_no_quit (watch_descriptor, watch_list)) ? Qnil : Qt;
+}
+
+
+void
+globals_of_kqueue (void)
+{
+  watch_list = Qnil;
+}
+
+void
+syms_of_kqueue (void)
+{
+  defsubr (&Skqueue_add_watch);
+  defsubr (&Skqueue_rm_watch);
+  defsubr (&Skqueue_valid_p);
+
+  /* Event types.  */
+  DEFSYM (Qcreate, "create");
+  DEFSYM (Qdelete, "delete");  /* NOTE_DELETE  */
+  DEFSYM (Qwrite, "write");    /* NOTE_WRITE  */
+  DEFSYM (Qextend, "extend");  /* NOTE_EXTEND  */
+  DEFSYM (Qattrib, "attrib");  /* NOTE_ATTRIB  */
+  DEFSYM (Qlink, "link");      /* NOTE_LINK  */
+  DEFSYM (Qrename, "rename");  /* NOTE_RENAME  */
+
+  staticpro (&watch_list);
+
+  Fprovide (intern_c_string ("kqueue"), Qnil);
+}
+
+#endif /* HAVE_KQUEUE  */
+
+/* PROBLEMS
+   * https://bugs.launchpad.net/ubuntu/+source/libkqueue/+bug/1514837
+     prevents tests on Ubuntu.  */
diff --git a/src/lisp.h b/src/lisp.h
index 63dadef..0df76ba 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4263,17 +4263,23 @@ extern void init_font (void);
 extern void syms_of_fontset (void);
 #endif
 
+/* Defined in inotify.c */
+#ifdef HAVE_INOTIFY
+extern void syms_of_inotify (void);
+#endif
+
+/* Defined in kqueue.c */
+#ifdef HAVE_KQUEUE
+extern void globals_of_kqueue (void);
+extern void syms_of_kqueue (void);
+#endif
+
 /* Defined in gfilenotify.c */
 #ifdef HAVE_GFILENOTIFY
 extern void globals_of_gfilenotify (void);
 extern void syms_of_gfilenotify (void);
 #endif
 
-/* Defined in inotify.c */
-#ifdef HAVE_INOTIFY
-extern void syms_of_inotify (void);
-#endif
-
 #ifdef HAVE_W32NOTIFY
 /* Defined on w32notify.c.  */
 extern void syms_of_w32notify (void);
diff --git a/src/xfns.c b/src/xfns.c
index 9d90b7b..313ac52 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -450,10 +450,11 @@ x_real_pos_and_offsets (struct frame *f,
           if (prop)
             {
               if (prop->type == target_type
-                  && xcb_get_property_value_length (prop) == 4
-                  && prop->format == 32)
+                  && prop->format == 32
+                  && (xcb_get_property_value_length (prop)
+                     == 4 * sizeof (int32_t)))
                 {
-                  long *fe = xcb_get_property_value (prop);
+                  int32_t *fe = xcb_get_property_value (prop);
 
                   outer_x = -fe[0];
                   outer_y = -fe[2];
diff --git a/src/xterm.c b/src/xterm.c
index 653593b..dd43486 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10115,17 +10115,19 @@ get_current_wm_state (struct frame *f,
   bool is_hidden = false;
   struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
   long max_len = 65536;
-  unsigned char *tmp_data = NULL;
   Atom target_type = XA_ATOM;
   /* If XCB is available, we can avoid three XSync calls.  */
 #ifdef USE_XCB
   xcb_get_property_cookie_t prop_cookie;
   xcb_get_property_reply_t *prop;
+  xcb_atom_t *reply_data;
 #else
   Display *dpy = FRAME_X_DISPLAY (f);
   unsigned long bytes_remaining;
   int rc, actual_format;
   Atom actual_type;
+  unsigned char *tmp_data = NULL;
+  Atom *reply_data;
 #endif
 
   *sticky = false;
@@ -10140,8 +10142,10 @@ get_current_wm_state (struct frame *f,
   prop = xcb_get_property_reply (dpyinfo->xcb_connection, prop_cookie, NULL);
   if (prop && prop->type == target_type)
     {
-      tmp_data = xcb_get_property_value (prop);
-      actual_size = xcb_get_property_value_length (prop);
+      int actual_bytes = xcb_get_property_value_length (prop);
+      eassume (0 <= actual_bytes);
+      actual_size = actual_bytes / sizeof *reply_data;
+      reply_data = xcb_get_property_value (prop);
     }
   else
     {
@@ -10155,7 +10159,9 @@ get_current_wm_state (struct frame *f,
                            &actual_type, &actual_format, &actual_size,
                            &bytes_remaining, &tmp_data);
 
-  if (rc != Success || actual_type != target_type || x_had_errors_p (dpy))
+  if (rc == Success && actual_type == target_type && ! x_had_errors_p (dpy))
+    reply_data = (Atom *) tmp_data;
+  else
     {
       actual_size = 0;
       is_hidden = FRAME_ICONIFIED_P (f);
@@ -10166,7 +10172,7 @@ get_current_wm_state (struct frame *f,
 
   for (i = 0; i < actual_size; ++i)
     {
-      Atom a = ((Atom*)tmp_data)[i];
+      Atom a = reply_data[i];
       if (a == dpyinfo->Xatom_net_wm_state_hidden)
        is_hidden = true;
       else if (a == dpyinfo->Xatom_net_wm_state_maximized_horz)
diff --git a/test/automated/Makefile.in b/test/Makefile.in
similarity index 76%
rename from test/automated/Makefile.in
rename to test/Makefile.in
index 41f54f8..1e76675 100644
--- a/test/automated/Makefile.in
+++ b/test/Makefile.in
@@ -37,7 +37,7 @@ SEPCHAR = @SEPCHAR@
 # We never change directory before running Emacs, so a relative file
 # name is fine, and makes life easier.  If we need to change
 # directory, we can use emacs --chdir.
-EMACS = ../../src/emacs
+EMACS = ../src/emacs
 
 EMACS_EXTRAOPT=
 
@@ -87,7 +87,7 @@ WRITE_LOG = > $@ 2>&1 || { stat=ERROR; cat $@; }; echo 
$$stat: $@
 ## to change this; bug#17848 - if that gets done, this can be simplified).
 ##
 ## Beware: it approximates 'no-byte-compile', so watch out for false-positives!
-%.log: ${srcdir}/%.el
+%.log: %.el
        @if grep '^;.*no-byte-compile: t' $< > /dev/null; then \
          loadfile=$<; \
        else \
@@ -96,12 +96,18 @@ WRITE_LOG = > $@ 2>&1 || { stat=ERROR; cat $@; }; echo 
$$stat: $@
        fi; \
        echo Testing $$loadfile; \
        stat=OK ; \
+       mkdir --parents $(dir $@) ; \
        $(emacs) -l ert -l $$loadfile \
          -f ert-run-tests-batch-and-exit ${WRITE_LOG}
 
-ELFILES = $(sort $(wildcard ${srcdir}/*.el))
-LOGFILES = $(patsubst %.el,%.log,$(notdir ${ELFILES}))
-TESTS = ${LOGFILES:.log=}
+ELFILES = $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \
+               -path "*resources" -prune -o -name "*el" -print)
+## .elc files may be in a different directory for out of source builds
+ELCFILES = $(patsubst %.el,%.elc, \
+               $(patsubst $(srcdir)%,.%,$(ELFILES)))
+LOGFILES = $(patsubst %.elc,%.log,${ELCFILES})
+LOGSAVEFILES  = $(patsubst %.elc,%.log~,${ELCFILES})
+TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=))
 
 ## If we have to interrupt a hanging test, preserve the log so we can
 ## see what the problem was.
@@ -110,18 +116,27 @@ TESTS = ${LOGFILES:.log=}
 .PHONY: ${TESTS}
 
 ## The short aliases that always re-run the tests, with no logging.
+## Define an alias both with and without the directory name for ease
+## of use.
 define test_template
 $(1):
-       @test ! -f $(1).log || mv $(1).log $(1).log~
-       @${MAKE} $(1).log WRITE_LOG=
+       @test ! -f ./$(1).log || mv ./$(1).log ./$(1).log~
+       @${MAKE} ./$(1).log WRITE_LOG=
+
+$(notdir $(1)): $(1)
 endef
 
 $(foreach test,${TESTS},$(eval $(call test_template,${test})))
 
+## Include dependencies between test files and the files they test.
+## We do this without the file and eval directly, but then we would
+## have to run Emacs for every make invocation, and it might not be
+## available during clean.
+-include make-test-deps.mk
 
 ## Re-run all the tests every time.
 check:
-       address@hidden f in *.log; do test ! -f $$f || mv $$f $$f~; done
+       address@hidden f in $(LOGFILES); do test ! -f $$f || mv $$f $$f~; done
        @${MAKE} check-maybe
 
 ## Only re-run tests whose .log is older than the test.
@@ -132,14 +147,19 @@ check-maybe: ${LOGFILES}
 .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
 
 clean mostlyclean:
-       -rm -f *.log *.log~
+       -rm -f ${LOGFILES} ${LOGSAVEFILES}
+       -rm make-test-deps.mk
 
 bootstrap-clean: clean
-       -rm -f ${srcdir}/*.elc
+       -rm -f ${ELCFILES}
 
 distclean: clean
        rm -f Makefile
 
 maintainer-clean: distclean bootstrap-clean
 
+make-test-deps.mk: $(ELFILES) make-test-deps.emacs-lisp
+       $(EMACS) --batch -l $(srcdir)/make-test-deps.emacs-lisp \
+       --eval "(make-test-deps \"$(srcdir)\")" \
+       2> $@
 # Makefile ends here.
diff --git a/test/automated/abbrev-tests.el b/test/automated/abbrev-tests.el
deleted file mode 100644
index d08e026..0000000
--- a/test/automated/abbrev-tests.el
+++ /dev/null
@@ -1,43 +0,0 @@
-;;; abbrev-tests.el --- Test suite for abbrevs.
-
-;; Copyright (C) 2015 Free Software Foundation, Inc.
-
-;; Author: Eli Zaretskii <address@hidden>
-;; Keywords: abbrevs
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Code:
-
-(require 'ert)
-(require 'abbrev)
-
-(ert-deftest copy-abbrev-table-test ()
-  (defvar foo-abbrev-table nil)         ; Avoid compiler warning
-  (define-abbrev-table 'foo-abbrev-table
-    '())
-  (should (abbrev-table-p foo-abbrev-table))
-  ;; Bug 21828
-  (let ((new-foo-abbrev-table
-         (condition-case nil
-             (copy-abbrev-table foo-abbrev-table)
-           (error nil))))
-    (should (abbrev-table-p new-foo-abbrev-table)))
-  (should-not (string-equal (buffer-name) "*Backtrace*")))
-
-(provide 'abbrev-tests)
-
-;;; abbrev-tests.el ends here
diff --git a/test/automated/data/decompress/foo.gz b/test/data/decompress/foo.gz
similarity index 100%
rename from test/automated/data/decompress/foo.gz
rename to test/data/decompress/foo.gz
diff --git a/test/automated/data/epg/pubkey.asc b/test/data/epg/pubkey.asc
similarity index 100%
rename from test/automated/data/epg/pubkey.asc
rename to test/data/epg/pubkey.asc
diff --git a/test/automated/data/epg/seckey.asc b/test/data/epg/seckey.asc
similarity index 100%
rename from test/automated/data/epg/seckey.asc
rename to test/data/epg/seckey.asc
diff --git a/test/automated/data/files-bug18141.el.gz 
b/test/data/files-bug18141.el.gz
similarity index 100%
rename from test/automated/data/files-bug18141.el.gz
rename to test/data/files-bug18141.el.gz
diff --git a/test/file-organisation.org b/test/file-organisation.org
new file mode 100644
index 0000000..b754000
--- /dev/null
+++ b/test/file-organisation.org
@@ -0,0 +1,54 @@
+#+TITLE: The Location of Emacs-Lisp Tests
+
+
+
+* The Main Emacs Repository
+
+The Emacs repository contains a very large number of Emacs-Lisp files, many of
+which pre-date both formal package support for Emacs and automated unit
+testing.
+
+All paths are relative to the Emacs root directory.
+
+** Source
+
+Lisp files are stored in the ~lisp~ directory or its sub-directories.
+Sub-directories are in many cases themed after packages (~gnus~, ~org~,
+~calc~), related functionality (~net~, ~emacs-lisp~, ~progmodes~) or status
+(~obsolete~).
+
+C source is stored in the ~src~ directory, which is flat.
+
+** Test Files
+
+Automated tests should be stored in the ~test/automated/lisp~ directory. Tests
+should reflect the directory structure of the source tree; so tests for files
+in the ~emacs-lisp~ source directory should reside in the
+~test/lisp/emacs-lisp~ directory.
+
+Tests should normally reside in a file with ~-tests~ added to the name of
+the tested source file; hence ~ert.el~ is tested in ~ert-tests.el~, or
+~pcase.el~ is tested in ~pcase-tests.el~. Exceptionally, tests for a
+single feature may be placed into multiple files of any name which are
+themselves placed in a directory named after the feature with ~-tests~
+appended, such as ~/test/lisp/emacs-lisp/eieio-tests~
+
+Where features of the C source are tested using Emacs-Lisp test files, these
+should reside in ~/test/src~ and be named after the C file.
+
+A few test suites which predate this scheme and do not fit cleanly
+into it are placed in ~/test/lisp/legacy~.
+
+There are also some test materials that cannot be run automatically
+(i.e. via ert). These should be placed in ~/test/manual~
+
+** Resource Files
+
+Resource files for tests (containing test data) should reside in a directory
+named after the feature with a ~-resources~ suffix, and located in the same
+directory as the feature. Hence, the lisp file ~flymake.el~ should have test
+files in ~/test/automated/lisp/progmodes/flymake-tests.el~ should reside in a
+directory called ~/test/automated/lisp/progmodes/flymake-resources~.
+
+No guidance is given for the organisation of resource files inside the
+~-resource~ directory; files can be organised at the author's discretion.
diff --git a/test/lisp/abbrev-tests.el b/test/lisp/abbrev-tests.el
new file mode 100644
index 0000000..17aea5d
--- /dev/null
+++ b/test/lisp/abbrev-tests.el
@@ -0,0 +1,74 @@
+;;; abbrev-tests.el --- Test suite for abbrevs  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Eli Zaretskii <address@hidden>
+;; Keywords: abbrevs
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ert)
+(require 'abbrev)
+
+(ert-deftest abbrev-table-p-test ()
+  (should-not (abbrev-table-p 42))
+  (should-not (abbrev-table-p "aoeu"))
+  (should-not (abbrev-table-p '()))
+  (should-not (abbrev-table-p []))
+  ;; Missing :abbrev-table-modiff counter:
+  (should-not (abbrev-table-p (obarray-make)))
+  (let* ((table (obarray-make)))
+    (abbrev-table-put table :abbrev-table-modiff 42)
+    (should (abbrev-table-p table))))
+
+(ert-deftest abbrev-make-abbrev-table-test ()
+  ;; Table without properties:
+  (let ((table (make-abbrev-table)))
+    (should (abbrev-table-p table))
+    (should (= (length table) obarray-default-size)))
+  ;; Table with one property 'foo with value 'bar:
+  (let ((table (make-abbrev-table '(foo bar))))
+    (should (abbrev-table-p table))
+    (should (= (length table) obarray-default-size))
+    (should (eq (abbrev-table-get table 'foo) 'bar))))
+
+(ert-deftest abbrev-table-get-put-test ()
+  (let ((table (make-abbrev-table)))
+    (should-not (abbrev-table-get table 'foo))
+    (should (= (abbrev-table-put table 'foo 42) 42))
+    (should (= (abbrev-table-get table 'foo) 42))
+    (should (eq (abbrev-table-put table 'foo 'bar) 'bar))
+    (should (eq (abbrev-table-get table 'foo) 'bar))))
+
+(ert-deftest copy-abbrev-table-test ()
+  (defvar foo-abbrev-table nil)         ; Avoid compiler warning
+  (define-abbrev-table 'foo-abbrev-table
+    '())
+  (should (abbrev-table-p foo-abbrev-table))
+  ;; Bug 21828
+  (let ((new-foo-abbrev-table
+         (condition-case nil
+             (copy-abbrev-table foo-abbrev-table)
+           (error nil))))
+    (should (abbrev-table-p new-foo-abbrev-table)))
+  (should-not (string-equal (buffer-name) "*Backtrace*")))
+
+(provide 'abbrev-tests)
+;;; abbrev-tests.el ends here
diff --git a/test/automated/auto-revert-tests.el b/test/lisp/autorevert-tests.el
similarity index 99%
rename from test/automated/auto-revert-tests.el
rename to test/lisp/autorevert-tests.el
index 2745f10..6f18697 100644
--- a/test/automated/auto-revert-tests.el
+++ b/test/lisp/autorevert-tests.el
@@ -136,7 +136,7 @@
           ;; Strange, that `copy-directory' does not work as expected.
           ;; The following shell command is not portable on all
           ;; platforms, unfortunately.
-          (shell-command (format "%s -f %s/* %s" cp tmpdir2 tmpdir1))
+          (shell-command (format "%s %s/* %s" cp tmpdir2 tmpdir1))
 
           ;; Check, that the buffers have been reverted.
           (dolist (buf (list buf1 buf2))
diff --git a/test/automated/calc-tests.el b/test/lisp/calc/calc-tests.el
similarity index 100%
rename from test/automated/calc-tests.el
rename to test/lisp/calc/calc-tests.el
diff --git a/test/automated/icalendar-tests.el 
b/test/lisp/calendar/icalendar-tests.el
similarity index 100%
rename from test/automated/icalendar-tests.el
rename to test/lisp/calendar/icalendar-tests.el
diff --git a/test/automated/character-fold-tests.el 
b/test/lisp/character-fold-tests.el
similarity index 100%
rename from test/automated/character-fold-tests.el
rename to test/lisp/character-fold-tests.el
diff --git a/test/automated/comint-testsuite.el b/test/lisp/comint-tests.el
similarity index 100%
rename from test/automated/comint-testsuite.el
rename to test/lisp/comint-tests.el
diff --git a/test/automated/descr-text-test.el b/test/lisp/descr-text-tests.el
similarity index 100%
rename from test/automated/descr-text-test.el
rename to test/lisp/descr-text-tests.el
diff --git a/test/automated/electric-tests.el b/test/lisp/electric-tests.el
similarity index 100%
rename from test/automated/electric-tests.el
rename to test/lisp/electric-tests.el
diff --git a/test/automated/cl-generic-tests.el 
b/test/lisp/emacs-lisp/cl-generic-tests.el
similarity index 100%
rename from test/automated/cl-generic-tests.el
rename to test/lisp/emacs-lisp/cl-generic-tests.el
diff --git a/test/automated/cl-lib-tests.el 
b/test/lisp/emacs-lisp/cl-lib-tests.el
similarity index 100%
rename from test/automated/cl-lib-tests.el
rename to test/lisp/emacs-lisp/cl-lib-tests.el
diff --git a/test/automated/eieio-test-methodinvoke.el 
b/test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el
similarity index 100%
rename from test/automated/eieio-test-methodinvoke.el
rename to test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el
diff --git a/test/automated/eieio-test-persist.el 
b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
similarity index 100%
rename from test/automated/eieio-test-persist.el
rename to test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
diff --git a/test/automated/eieio-tests.el 
b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
similarity index 100%
rename from test/automated/eieio-tests.el
rename to test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
diff --git a/test/automated/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el
similarity index 100%
rename from test/automated/ert-tests.el
rename to test/lisp/emacs-lisp/ert-tests.el
diff --git a/test/automated/ert-x-tests.el b/test/lisp/emacs-lisp/ert-x-tests.el
similarity index 100%
rename from test/automated/ert-x-tests.el
rename to test/lisp/emacs-lisp/ert-x-tests.el
diff --git a/test/automated/generator-tests.el 
b/test/lisp/emacs-lisp/generator-tests.el
similarity index 100%
rename from test/automated/generator-tests.el
rename to test/lisp/emacs-lisp/generator-tests.el
diff --git a/test/automated/let-alist.el 
b/test/lisp/emacs-lisp/let-alist-tests.el
similarity index 100%
rename from test/automated/let-alist.el
rename to test/lisp/emacs-lisp/let-alist-tests.el
diff --git a/test/automated/map-tests.el b/test/lisp/emacs-lisp/map-tests.el
similarity index 100%
rename from test/automated/map-tests.el
rename to test/lisp/emacs-lisp/map-tests.el
diff --git a/test/automated/advice-tests.el 
b/test/lisp/emacs-lisp/nadvice-tests.el
similarity index 100%
rename from test/automated/advice-tests.el
rename to test/lisp/emacs-lisp/nadvice-tests.el
diff --git a/test/automated/data/package/archive-contents 
b/test/lisp/emacs-lisp/package-resources/archive-contents
similarity index 100%
rename from test/automated/data/package/archive-contents
rename to test/lisp/emacs-lisp/package-resources/archive-contents
diff --git a/test/automated/data/package/key.pub 
b/test/lisp/emacs-lisp/package-resources/key.pub
similarity index 100%
rename from test/automated/data/package/key.pub
rename to test/lisp/emacs-lisp/package-resources/key.pub
diff --git a/test/automated/data/package/key.sec 
b/test/lisp/emacs-lisp/package-resources/key.sec
similarity index 100%
rename from test/automated/data/package/key.sec
rename to test/lisp/emacs-lisp/package-resources/key.sec
diff --git a/test/automated/data/package/multi-file-0.2.3.tar 
b/test/lisp/emacs-lisp/package-resources/multi-file-0.2.3.tar
similarity index 100%
rename from test/automated/data/package/multi-file-0.2.3.tar
rename to test/lisp/emacs-lisp/package-resources/multi-file-0.2.3.tar
diff --git a/test/automated/data/package/multi-file-readme.txt 
b/test/lisp/emacs-lisp/package-resources/multi-file-readme.txt
similarity index 100%
rename from test/automated/data/package/multi-file-readme.txt
rename to test/lisp/emacs-lisp/package-resources/multi-file-readme.txt
diff --git a/test/automated/data/package/newer-versions/archive-contents 
b/test/lisp/emacs-lisp/package-resources/newer-versions/archive-contents
similarity index 100%
rename from test/automated/data/package/newer-versions/archive-contents
rename to test/lisp/emacs-lisp/package-resources/newer-versions/archive-contents
diff --git a/test/automated/data/package/newer-versions/new-pkg-1.0.el 
b/test/lisp/emacs-lisp/package-resources/newer-versions/new-pkg-1.0.el
similarity index 100%
rename from test/automated/data/package/newer-versions/new-pkg-1.0.el
rename to test/lisp/emacs-lisp/package-resources/newer-versions/new-pkg-1.0.el
diff --git a/test/automated/data/package/newer-versions/simple-single-1.4.el 
b/test/lisp/emacs-lisp/package-resources/newer-versions/simple-single-1.4.el
similarity index 100%
rename from test/automated/data/package/newer-versions/simple-single-1.4.el
rename to 
test/lisp/emacs-lisp/package-resources/newer-versions/simple-single-1.4.el
diff --git a/test/automated/data/package/package-test-server.py 
b/test/lisp/emacs-lisp/package-resources/package-test-server.py
similarity index 100%
rename from test/automated/data/package/package-test-server.py
rename to test/lisp/emacs-lisp/package-resources/package-test-server.py
diff --git a/test/automated/data/package/signed/archive-contents 
b/test/lisp/emacs-lisp/package-resources/signed/archive-contents
similarity index 100%
rename from test/automated/data/package/signed/archive-contents
rename to test/lisp/emacs-lisp/package-resources/signed/archive-contents
diff --git a/test/automated/data/package/signed/archive-contents.sig 
b/test/lisp/emacs-lisp/package-resources/signed/archive-contents.sig
similarity index 100%
rename from test/automated/data/package/signed/archive-contents.sig
rename to test/lisp/emacs-lisp/package-resources/signed/archive-contents.sig
diff --git a/test/automated/data/package/signed/signed-bad-1.0.el 
b/test/lisp/emacs-lisp/package-resources/signed/signed-bad-1.0.el
similarity index 100%
rename from test/automated/data/package/signed/signed-bad-1.0.el
rename to test/lisp/emacs-lisp/package-resources/signed/signed-bad-1.0.el
diff --git a/test/automated/data/package/signed/signed-bad-1.0.el.sig 
b/test/lisp/emacs-lisp/package-resources/signed/signed-bad-1.0.el.sig
similarity index 100%
rename from test/automated/data/package/signed/signed-bad-1.0.el.sig
rename to test/lisp/emacs-lisp/package-resources/signed/signed-bad-1.0.el.sig
diff --git a/test/automated/data/package/signed/signed-good-1.0.el 
b/test/lisp/emacs-lisp/package-resources/signed/signed-good-1.0.el
similarity index 100%
rename from test/automated/data/package/signed/signed-good-1.0.el
rename to test/lisp/emacs-lisp/package-resources/signed/signed-good-1.0.el
diff --git a/test/automated/data/package/signed/signed-good-1.0.el.sig 
b/test/lisp/emacs-lisp/package-resources/signed/signed-good-1.0.el.sig
similarity index 100%
rename from test/automated/data/package/signed/signed-good-1.0.el.sig
rename to test/lisp/emacs-lisp/package-resources/signed/signed-good-1.0.el.sig
diff --git a/test/automated/data/package/simple-depend-1.0.el 
b/test/lisp/emacs-lisp/package-resources/simple-depend-1.0.el
similarity index 100%
rename from test/automated/data/package/simple-depend-1.0.el
rename to test/lisp/emacs-lisp/package-resources/simple-depend-1.0.el
diff --git a/test/automated/data/package/simple-single-1.3.el 
b/test/lisp/emacs-lisp/package-resources/simple-single-1.3.el
similarity index 100%
rename from test/automated/data/package/simple-single-1.3.el
rename to test/lisp/emacs-lisp/package-resources/simple-single-1.3.el
diff --git a/test/automated/data/package/simple-single-readme.txt 
b/test/lisp/emacs-lisp/package-resources/simple-single-readme.txt
similarity index 100%
rename from test/automated/data/package/simple-single-readme.txt
rename to test/lisp/emacs-lisp/package-resources/simple-single-readme.txt
diff --git a/test/automated/data/package/simple-two-depend-1.1.el 
b/test/lisp/emacs-lisp/package-resources/simple-two-depend-1.1.el
similarity index 100%
rename from test/automated/data/package/simple-two-depend-1.1.el
rename to test/lisp/emacs-lisp/package-resources/simple-two-depend-1.1.el
diff --git a/test/automated/package-test.el 
b/test/lisp/emacs-lisp/package-tests.el
similarity index 96%
rename from test/automated/package-test.el
rename to test/lisp/emacs-lisp/package-tests.el
index de41c3b..6b3069c 100644
--- a/test/automated/package-test.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -97,7 +97,7 @@
                                (multi-file (0 1))))
   "`package-desc' used for testing dependencies.")
 
-(defvar package-test-data-dir (expand-file-name "data/package" 
package-test-file-dir)
+(defvar package-test-data-dir (expand-file-name "package-resources" 
package-test-file-dir)
   "Base directory of package test files.")
 
 (defvar package-test-fake-contents-file
@@ -190,18 +190,18 @@ Must called from within a `tar-mode' buffer."
 
 (ert-deftest package-test-desc-from-buffer ()
   "Parse an elisp buffer to get a `package-desc' object."
-  (with-package-test (:basedir "data/package" :file "simple-single-1.3.el")
+  (with-package-test (:basedir "package-resources" :file 
"simple-single-1.3.el")
     (should (equal (package-buffer-info) simple-single-desc)))
-  (with-package-test (:basedir "data/package" :file "simple-depend-1.0.el")
+  (with-package-test (:basedir "package-resources" :file 
"simple-depend-1.0.el")
     (should (equal (package-buffer-info) simple-depend-desc)))
-  (with-package-test (:basedir "data/package"
+  (with-package-test (:basedir "package-resources"
                                :file "multi-file-0.2.3.tar")
     (tar-mode)
     (should (equal (package-tar-file-info) multi-file-desc))))
 
 (ert-deftest package-test-install-single ()
   "Install a single file without using an archive."
-  (with-package-test (:basedir "data/package" :file "simple-single-1.3.el")
+  (with-package-test (:basedir "package-resources" :file 
"simple-single-1.3.el")
     (should (package-install-from-buffer))
     (package-initialize)
     (should (package-installed-p 'simple-single))
@@ -269,7 +269,7 @@ Must called from within a `tar-mode' buffer."
 (ert-deftest package-test-install-prioritized ()
   "Install a lower version from a higher-prioritized archive."
   (with-package-test ()
-    (let* ((newer-version (expand-file-name "data/package/newer-versions"
+    (let* ((newer-version (expand-file-name "package-resources/newer-versions"
                                             package-test-file-dir))
            (package-archives `(("older" . ,package-test-data-dir)
                                ("newer" . ,newer-version)))
@@ -285,7 +285,7 @@ Must called from within a `tar-mode' buffer."
 
 (ert-deftest package-test-install-multifile ()
   "Check properties of the installed multi-file package."
-  (with-package-test (:basedir "data/package" :install '(multi-file))
+  (with-package-test (:basedir "package-resources" :install '(multi-file))
     (let ((autoload-file
            (expand-file-name "multi-file-autoloads.el"
                              (expand-file-name
@@ -336,7 +336,7 @@ Must called from within a `tar-mode' buffer."
       (package-menu-execute)
       (should (package-installed-p 'simple-single))
       (let ((package-test-data-dir
-             (expand-file-name "data/package/newer-versions" 
package-test-file-dir)))
+             (expand-file-name "package-resources/newer-versions" 
package-test-file-dir)))
         (setq package-archives `(("gnu" . ,package-test-data-dir)))
         (package-menu-refresh)
 
@@ -456,7 +456,7 @@ Must called from within a `tar-mode' buffer."
                     (delete-directory homedir t)))))
   (let* ((keyring (expand-file-name "key.pub" package-test-data-dir))
         (package-test-data-dir
-          (expand-file-name "data/package/signed" package-test-file-dir)))
+          (expand-file-name "package-resources/signed" package-test-file-dir)))
     (with-package-test ()
       (package-initialize)
       (package-import-keyring keyring)
@@ -508,7 +508,7 @@ Must called from within a `tar-mode' buffer."
 
 (ert-deftest package-x-test-upload-buffer ()
   "Test creating an \"archive-contents\" file"
-  (with-package-test (:basedir "data/package"
+  (with-package-test (:basedir "package-resources"
                                :file "simple-single-1.3.el"
                                :upload-base t)
     (package-upload-buffer)
@@ -532,7 +532,7 @@ Must called from within a `tar-mode' buffer."
 
 (ert-deftest package-x-test-upload-new-version ()
   "Test uploading a new version of a package"
-  (with-package-test (:basedir "data/package"
+  (with-package-test (:basedir "package-resources"
                                :file "simple-single-1.3.el"
                                :upload-base t)
     (package-upload-buffer)
@@ -599,6 +599,7 @@ Must called from within a `tar-mode' buffer."
                simple-depend-desc-2)))
     (should
      (equal (package--sort-by-dependence delete-list)
+
             (list simple-depend-desc-2 simple-depend-desc-1 new-pkg-desc
                   multi-file-desc simple-depend-desc simple-single-desc)))
     (should
diff --git a/test/automated/pcase-tests.el b/test/lisp/emacs-lisp/pcase-tests.el
similarity index 100%
rename from test/automated/pcase-tests.el
rename to test/lisp/emacs-lisp/pcase-tests.el
diff --git a/test/automated/regexp-tests.el 
b/test/lisp/emacs-lisp/regexp-opt-tests.el
similarity index 100%
rename from test/automated/regexp-tests.el
rename to test/lisp/emacs-lisp/regexp-opt-tests.el
diff --git a/test/automated/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el
similarity index 100%
rename from test/automated/seq-tests.el
rename to test/lisp/emacs-lisp/seq-tests.el
diff --git a/test/automated/subr-x-tests.el 
b/test/lisp/emacs-lisp/subr-x-tests.el
similarity index 100%
rename from test/automated/subr-x-tests.el
rename to test/lisp/emacs-lisp/subr-x-tests.el
diff --git a/test/automated/tabulated-list-test.el 
b/test/lisp/emacs-lisp/tabulated-list-test.el
similarity index 100%
rename from test/automated/tabulated-list-test.el
rename to test/lisp/emacs-lisp/tabulated-list-test.el
diff --git a/test/automated/thunk-tests.el b/test/lisp/emacs-lisp/thunk-tests.el
similarity index 100%
rename from test/automated/thunk-tests.el
rename to test/lisp/emacs-lisp/thunk-tests.el
diff --git a/test/automated/timer-tests.el b/test/lisp/emacs-lisp/timer-tests.el
similarity index 100%
rename from test/automated/timer-tests.el
rename to test/lisp/emacs-lisp/timer-tests.el
diff --git a/test/automated/epg-tests.el b/test/lisp/epg-tests.el
similarity index 100%
rename from test/automated/epg-tests.el
rename to test/lisp/epg-tests.el
diff --git a/test/automated/eshell.el b/test/lisp/eshell/eshell.el
similarity index 100%
rename from test/automated/eshell.el
rename to test/lisp/eshell/eshell.el
diff --git a/test/automated/faces-tests.el b/test/lisp/faces-tests.el
similarity index 100%
rename from test/automated/faces-tests.el
rename to test/lisp/faces-tests.el
diff --git a/test/automated/file-notify-tests.el b/test/lisp/filenotify-tests.el
similarity index 50%
rename from test/automated/file-notify-tests.el
rename to test/lisp/filenotify-tests.el
index 67e929a..d6322c2 100644
--- a/test/automated/file-notify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -61,11 +61,14 @@
 (defvar file-notify--test-results nil)
 (defvar file-notify--test-event nil)
 (defvar file-notify--test-events nil)
-(defvar file-notify--test-expected-events nil)
 
 (defun file-notify--test-timeout ()
   "Timeout to wait for arriving events, in seconds."
-  (if (file-remote-p temporary-file-directory) 6 3))
+  (cond
+   ((file-remote-p temporary-file-directory) 6)
+   ((string-equal (file-notify--test-library) "w32notify") 20)
+   ((eq system-type 'cygwin) 10)
+   (t 3)))
 
 (defun file-notify--test-cleanup ()
   "Cleanup after a test."
@@ -89,8 +92,7 @@
         file-notify--test-tmpfile1 nil
         file-notify--test-desc nil
         file-notify--test-results nil
-        file-notify--test-events nil
-        file-notify--test-expected-events nil)
+        file-notify--test-events nil)
   (when file-notify--test-event
     (error "file-notify--test-event should not be set but bound dynamically")))
 
@@ -133,6 +135,18 @@ being the result.")
   ;; Return result.
   (cdr file-notify--test-remote-enabled-checked))
 
+(defun file-notify--test-library ()
+  "The used libray for the test, as string.
+In the remote case, it is the process name which runs on the
+remote host, or nil."
+  (if (null (file-remote-p temporary-file-directory))
+      (symbol-name file-notify--library)
+    (and (consp file-notify--test-remote-enabled-checked)
+        (processp (cdr file-notify--test-remote-enabled-checked))
+        (replace-regexp-in-string
+         "<[[:digit:]]+>\\'" ""
+         (process-name (cdr file-notify--test-remote-enabled-checked))))))
+
 (defmacro file-notify--deftest-remote (test docstring)
   "Define ert `TEST-remote' for remote files."
   (declare (indent 1))
@@ -150,12 +164,7 @@ being the result.")
   "Test availability of `file-notify'."
   (skip-unless (file-notify--test-local-enabled))
   ;; Report the native library which has been used.
-  (if (null (file-remote-p temporary-file-directory))
-      (message "Local library: `%s'" file-notify--library)
-    (message "Remote command: `%s'"
-             (replace-regexp-in-string
-              "<[[:digit:]]+>\\'" ""
-              (process-name (cdr file-notify--test-remote-enabled-checked)))))
+  (message "Library: `%s'" (file-notify--test-library))
   (should
    (setq file-notify--test-desc
          (file-notify-add-watch temporary-file-directory '(change) 'ignore)))
@@ -189,12 +198,13 @@ being the result.")
          (file-notify-add-watch
           temporary-file-directory '(change attribute-change) 'ignore)))
   (file-notify-rm-watch file-notify--test-desc)
-  ;; The file does not need to exist, just the upper directory.
+  (write-region "any text" nil file-notify--test-tmpfile nil 'no-message)
   (should
    (setq file-notify--test-desc
          (file-notify-add-watch
           file-notify--test-tmpfile '(change attribute-change) 'ignore)))
   (file-notify-rm-watch file-notify--test-desc)
+  (delete-file file-notify--test-tmpfile)
 
   ;; Check error handling.
   (should-error (file-notify-add-watch 1 2 3 4)
@@ -235,16 +245,17 @@ is bound somewhere."
   (should
    (or (string-equal (file-notify--event-file-name file-notify--test-event)
                     file-notify--test-tmpfile)
-       (string-equal (directory-file-name
-                     (file-name-directory
-                      (file-notify--event-file-name file-notify--test-event)))
-                    file-notify--test-tmpfile)))
+       (string-equal (file-notify--event-file-name file-notify--test-event)
+                    file-notify--test-tmpfile1)
+       (string-equal (file-notify--event-file-name file-notify--test-event)
+                    temporary-file-directory)))
   ;; Check the second file name if exists.
   (when (eq (nth 1 file-notify--test-event) 'renamed)
     (should
-     (string-equal
-      (file-notify--event-file1-name file-notify--test-event)
-      file-notify--test-tmpfile1))))
+     (or (string-equal (file-notify--event-file1-name file-notify--test-event)
+                      file-notify--test-tmpfile1)
+        (string-equal (file-notify--event-file1-name file-notify--test-event)
+                      temporary-file-directory)))))
 
 (defun file-notify--test-event-handler (event)
   "Run a test over FILE-NOTIFY--TEST-EVENT.
@@ -253,7 +264,7 @@ and the event to `file-notify--test-events'."
   (let* ((file-notify--test-event event)
          (result
           (ert-run-test (make-ert-test :body 'file-notify--test-event-test))))
-    ;; Do not add temporary files, this would confuse the checks.
+    ;; Do not add lock files, this would confuse the checks.
     (unless (string-match
             (regexp-quote ".#")
             (file-notify--event-file-name file-notify--test-event))
@@ -277,137 +288,246 @@ TIMEOUT is the maximum time to wait for, in seconds."
 
 (defmacro file-notify--test-with-events (events &rest body)
   "Run BODY collecting events and then compare with EVENTS.
-Don't wait longer than timeout seconds for the events to be delivered."
+EVENTS is either a simple list of events, or a list of lists of
+events, which represent different possible results.  Don't wait
+longer than timeout seconds for the events to be delivered."
   (declare (indent 1))
   (let ((outer (make-symbol "outer")))
-    `(let ((,outer file-notify--test-events))
-       (setq file-notify--test-expected-events
-            (append file-notify--test-expected-events ,events))
+    `(let* ((,outer file-notify--test-events)
+            (events (if (consp (car ,events)) ,events (list ,events)))
+            (max-length (apply 'max (mapcar 'length events)))
+            create-lockfiles result)
+       ;; Flush pending events.
+       (file-notify--wait-for-events
+        (file-notify--test-timeout)
+        (input-pending-p))
        (let (file-notify--test-events)
          ,@body
          (file-notify--wait-for-events
-          (file-notify--test-timeout)
-          (= (length ,events) (length file-notify--test-events)))
-         (should (equal ,events (mapcar #'cadr file-notify--test-events)))
+          ;; More events need more time.  Use some fudge factor.
+          (* (ceiling max-length 100) (file-notify--test-timeout))
+          (= max-length (length file-notify--test-events)))
+         ;; One of the possible results shall match.
+         (should
+          (dolist (elt events result)
+            (setq result
+                  (or result
+                      (equal elt (mapcar #'cadr file-notify--test-events))))))
          (setq ,outer (append ,outer file-notify--test-events)))
        (setq file-notify--test-events ,outer))))
 
 (ert-deftest file-notify-test02-events ()
   "Check file creation/change/removal notifications."
   (skip-unless (file-notify--test-local-enabled))
-  ;; Under cygwin there are so bad timings that it doesn't make sense to test.
-  (skip-unless (not (eq system-type 'cygwin)))
-
-  (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
-       file-notify--test-tmpfile1 (file-notify--test-make-temp-name))
 
   (unwind-protect
       (progn
-        ;; Check creation, change and deletion.
-       (setq file-notify--test-desc
-              (file-notify-add-watch
-               file-notify--test-tmpfile
-               '(change) 'file-notify--test-event-handler))
-        (file-notify--test-with-events '(created changed deleted)
+        ;; Check file creation, change and deletion.  It doesn't work
+        ;; for cygwin and kqueue, because we don't use an implicit
+        ;; directory monitor (kqueue), or the timings are too bad (cygwin).
+        (unless (or (eq system-type 'cygwin)
+                   (string-equal (file-notify--test-library) "kqueue"))
+          (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
+          (should
+           (setq file-notify--test-desc
+                 (file-notify-add-watch
+                  file-notify--test-tmpfile
+                  '(change) 'file-notify--test-event-handler)))
+          (file-notify--test-with-events
+              (cond
+               ;; cygwin recognizes only `deleted' and `stopped' events.
+               ((eq system-type 'cygwin)
+                '(deleted stopped))
+               (t '(created changed deleted stopped)))
+            (write-region
+             "another text" nil file-notify--test-tmpfile nil 'no-message)
+            (read-event nil nil 0.1)
+            (delete-file file-notify--test-tmpfile))
+          ;; `file-notify-rm-watch' fires the `stopped' event.  Suppress it.
+          (let (file-notify--test-events)
+            (file-notify-rm-watch file-notify--test-desc)))
+
+        ;; Check file change and deletion.
+       (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
+        (write-region "any text" nil file-notify--test-tmpfile nil 'no-message)
+       (should
+        (setq file-notify--test-desc
+              (file-notify-add-watch
+               file-notify--test-tmpfile
+               '(change) 'file-notify--test-event-handler)))
+        (file-notify--test-with-events
+           (cond
+            ;; cygwin recognizes only `deleted' and `stopped' events.
+            ((eq system-type 'cygwin)
+             '(deleted stopped))
+             ;; inotify and kqueue raise just one `changed' event.
+             ((or (string-equal "inotify" (file-notify--test-library))
+                  (string-equal "kqueue" (file-notify--test-library)))
+             '(changed deleted stopped))
+             ;; gfilenotify raises one or two `changed' events
+             ;; randomly, no chance to test.  So we accept both cases.
+             ((string-equal "gfilenotify" (file-notify--test-library))
+              '((changed deleted stopped)
+                (changed changed deleted stopped)))
+            (t '(changed changed deleted stopped)))
+          (read-event nil nil 0.1)
           (write-region
-           "any text" nil file-notify--test-tmpfile nil 'no-message)
+           "another text" nil file-notify--test-tmpfile nil 'no-message)
+          (read-event nil nil 0.1)
           (delete-file file-notify--test-tmpfile))
        ;; `file-notify-rm-watch' fires the `stopped' event.  Suppress it.
        (let (file-notify--test-events)
          (file-notify-rm-watch file-notify--test-desc))
 
-        ;; Check creation, change and deletion.  There must be a
-        ;; `stopped' event when deleting the directory.  It doesn't
-        ;; work for w32notify.
-        (unless (eq file-notify--library 'w32notify)
-         (make-directory file-notify--test-tmpfile)
-         (setq file-notify--test-desc
-               (file-notify-add-watch
-                file-notify--test-tmpfile
-                '(change) 'file-notify--test-event-handler))
+        ;; Check file creation, change and deletion when watching a
+        ;; directory.  There must be a `stopped' event when deleting
+        ;; the directory.
+       (let ((temporary-file-directory
+              (make-temp-file "file-notify-test-parent" t)))
+         (should
+          (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
+                file-notify--test-desc
+                (file-notify-add-watch
+                 temporary-file-directory
+                 '(change) 'file-notify--test-event-handler)))
          (file-notify--test-with-events
-             ;; There are two `deleted' events, for the file and for
-             ;; the directory.
-             '(created changed deleted deleted stopped)
+             (cond
+              ;; w32notify does raise a `stopped' event when a
+              ;; watched directory is deleted.
+              ((string-equal (file-notify--test-library) "w32notify")
+               '(created changed deleted))
+              ;; cygwin recognizes only `deleted' and `stopped' events.
+              ((eq system-type 'cygwin)
+               '(deleted stopped))
+              ;; There are two `deleted' events, for the file and for
+              ;; the directory.  Except for kqueue.
+              ((string-equal (file-notify--test-library) "kqueue")
+               '(created changed deleted stopped))
+              (t '(created changed deleted deleted stopped)))
+           (read-event nil nil 0.1)
            (write-region
-            "any text" nil (expand-file-name "foo" file-notify--test-tmpfile)
-            nil 'no-message)
-           (delete-directory file-notify--test-tmpfile 'recursive))
+            "any text" nil file-notify--test-tmpfile nil 'no-message)
+           (read-event nil nil 0.1)
+           (delete-directory temporary-file-directory 'recursive))
          ;; `file-notify-rm-watch' fires the `stopped' event.  Suppress it.
          (let (file-notify--test-events)
            (file-notify-rm-watch file-notify--test-desc)))
 
-        ;; Check copy.
-        (setq file-notify--test-desc
-              (file-notify-add-watch
-               file-notify--test-tmpfile
-               '(change) 'file-notify--test-event-handler))
-        (should file-notify--test-desc)
-        (file-notify--test-with-events
-            ;; w32notify does not distinguish between `changed' and
-            ;; `attribute-changed'.
-            (if (eq file-notify--library 'w32notify)
-                '(created changed changed deleted)
-              '(created changed deleted))
-          (write-region
-           "any text" nil file-notify--test-tmpfile nil 'no-message)
-          (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
-          ;; The next two events shall not be visible.
-          (set-file-modes file-notify--test-tmpfile 000)
-          (read-event nil nil 0.1) ; In order to distinguish the events.
-          (set-file-times file-notify--test-tmpfile '(0 0))
-          (delete-file file-notify--test-tmpfile)
-          (delete-file file-notify--test-tmpfile1))
-       ;; `file-notify-rm-watch' fires the `stopped' event.  Suppress it.
-       (let (file-notify--test-events)
-         (file-notify-rm-watch file-notify--test-desc))
+        ;; Check copy of files inside a directory.
+       (let ((temporary-file-directory
+              (make-temp-file "file-notify-test-parent" t)))
+         (should
+          (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
+                file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
+                file-notify--test-desc
+                (file-notify-add-watch
+                 temporary-file-directory
+                 '(change) 'file-notify--test-event-handler)))
+         (file-notify--test-with-events
+             (cond
+              ;; w32notify does not distinguish between `changed' and
+              ;; `attribute-changed'.
+              ((string-equal (file-notify--test-library) "w32notify")
+               '(created changed created changed changed changed changed
+                 deleted deleted))
+              ;; cygwin recognizes only `deleted' and `stopped' events.
+              ((eq system-type 'cygwin)
+               '(deleted stopped))
+              ;; There are three `deleted' events, for two files and
+              ;; for the directory.  Except for kqueue.
+              ((string-equal (file-notify--test-library) "kqueue")
+               '(created changed created changed deleted stopped))
+              (t '(created changed created changed
+                   deleted deleted deleted stopped)))
+           (read-event nil nil 0.1)
+           (write-region
+            "any text" nil file-notify--test-tmpfile nil 'no-message)
+           (read-event nil nil 0.1)
+           (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
+           ;; The next two events shall not be visible.
+           (read-event nil nil 0.1)
+           (set-file-modes file-notify--test-tmpfile 000)
+           (read-event nil nil 0.1)
+           (set-file-times file-notify--test-tmpfile '(0 0))
+           (read-event nil nil 0.1)
+           (delete-directory temporary-file-directory 'recursive))
+         ;; `file-notify-rm-watch' fires the `stopped' event.  Suppress it.
+         (let (file-notify--test-events)
+           (file-notify-rm-watch file-notify--test-desc)))
 
-        ;; Check rename.
-        (setq file-notify--test-desc
-              (file-notify-add-watch
-               file-notify--test-tmpfile
-               '(change) 'file-notify--test-event-handler))
-        (should file-notify--test-desc)
-        (file-notify--test-with-events '(created changed renamed)
-          (write-region
-           "any text" nil file-notify--test-tmpfile nil 'no-message)
-          (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
-          ;; After the rename, we won't get events anymore.
-          (delete-file file-notify--test-tmpfile1))
-       ;; `file-notify-rm-watch' fires the `stopped' event.  Suppress it.
-       (let (file-notify--test-events)
-         (file-notify-rm-watch file-notify--test-desc))
+        ;; Check rename of files inside a directory.
+       (let ((temporary-file-directory
+              (make-temp-file "file-notify-test-parent" t)))
+         (should
+          (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
+                file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
+                file-notify--test-desc
+                (file-notify-add-watch
+                 temporary-file-directory
+                 '(change) 'file-notify--test-event-handler)))
+         (file-notify--test-with-events
+             (cond
+              ;; w32notify does not distinguish between `changed' and
+              ;; `attribute-changed'.
+              ((string-equal (file-notify--test-library) "w32notify")
+               '(created changed renamed deleted))
+              ;; cygwin recognizes only `deleted' and `stopped' events.
+              ((eq system-type 'cygwin)
+               '(deleted stopped))
+              ;; There are two `deleted' events, for the file and for
+              ;; the directory.  Except for kqueue.
+              ((string-equal (file-notify--test-library) "kqueue")
+               '(created changed renamed deleted stopped))
+              (t '(created changed renamed deleted deleted stopped)))
+           (read-event nil nil 0.1)
+           (write-region
+            "any text" nil file-notify--test-tmpfile nil 'no-message)
+           (read-event nil nil 0.1)
+           (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
+           ;; After the rename, we won't get events anymore.
+           (read-event nil nil 0.1)
+           (delete-directory temporary-file-directory 'recursive))
+         ;; `file-notify-rm-watch' fires the `stopped' event.  Suppress it.
+         (let (file-notify--test-events)
+           (file-notify-rm-watch file-notify--test-desc)))
 
-        ;; Check attribute change.  It doesn't work for w32notify.
-        (unless (eq file-notify--library 'w32notify)
-          (setq file-notify--test-desc
-                (file-notify-add-watch
-                 file-notify--test-tmpfile
-                 '(attribute-change) 'file-notify--test-event-handler))
-          (file-notify--test-with-events
-              (if (file-remote-p temporary-file-directory)
-                  ;; In the remote case, `write-region' raises also an
-                  ;; `attribute-changed' event.
-                  '(attribute-changed attribute-changed attribute-changed)
-                '(attribute-changed attribute-changed))
-            ;; We must use short delays between the operations.
-            ;; Otherwise, not all events arrive us in the remote case.
-            (write-region
-             "any text" nil file-notify--test-tmpfile nil 'no-message)
-            (read-event nil nil 0.1)
-            (set-file-modes file-notify--test-tmpfile 000)
-            (read-event nil nil 0.1)
-            (set-file-times file-notify--test-tmpfile '(0 0))
-            (read-event nil nil 0.1)
-            (delete-file file-notify--test-tmpfile))
+        ;; Check attribute change.  Does not work for cygwin.
+       (unless (eq system-type 'cygwin)
+         (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
+         (write-region
+          "any text" nil file-notify--test-tmpfile nil 'no-message)
+         (should
+          (setq file-notify--test-desc
+                (file-notify-add-watch
+                 file-notify--test-tmpfile
+                 '(attribute-change) 'file-notify--test-event-handler)))
+         (file-notify--test-with-events
+             (cond
+              ;; w32notify does not distinguish between `changed' and
+              ;; `attribute-changed'.
+              ((string-equal (file-notify--test-library) "w32notify")
+               '(changed changed changed changed))
+              ;; For kqueue and in the remote case, `write-region'
+              ;; raises also an `attribute-changed' event.
+              ((or (string-equal (file-notify--test-library) "kqueue")
+                   (file-remote-p temporary-file-directory))
+               '(attribute-changed attribute-changed attribute-changed))
+              (t '(attribute-changed attribute-changed)))
+           (read-event nil nil 0.1)
+           (write-region
+            "any text" nil file-notify--test-tmpfile nil 'no-message)
+           (read-event nil nil 0.1)
+           (set-file-modes file-notify--test-tmpfile 000)
+           (read-event nil nil 0.1)
+           (set-file-times file-notify--test-tmpfile '(0 0))
+           (read-event nil nil 0.1)
+           (delete-file file-notify--test-tmpfile))
          ;; `file-notify-rm-watch' fires the `stopped' event.  Suppress it.
          (let (file-notify--test-events)
            (file-notify-rm-watch file-notify--test-desc)))
 
         ;; Check the global sequence again just to make sure that
         ;; `file-notify--test-events' has been set correctly.
-        (should (equal (mapcar #'cadr file-notify--test-events)
-                      file-notify--test-expected-events))
         (should file-notify--test-results)
         (dolist (result file-notify--test-results)
           (when (ert-test-failed-p result)
@@ -475,28 +595,31 @@ Don't wait longer than timeout seconds for the events to 
be delivered."
            (should (string-match "another text" (buffer-string)))
 
             ;; Stop file notification.  Autorevert shall still work via 
polling.
-           (file-notify-rm-watch auto-revert-notify-watch-descriptor)
-            (file-notify--wait-for-events
-             timeout (null auto-revert-use-notify))
-           (should-not auto-revert-use-notify)
-           (should-not auto-revert-notify-watch-descriptor)
-
-           ;; Modify file.  We wait for two seconds, in order to have
-           ;; another timestamp.  One second seems to be too short.
-            (with-current-buffer (get-buffer-create "*Messages*")
-              (narrow-to-region (point-max) (point-max)))
-           (sleep-for 2)
-            (write-region
-             "foo bla" nil file-notify--test-tmpfile nil 'no-message)
-
-           ;; Check, that the buffer has been reverted.
-           (with-current-buffer (get-buffer-create "*Messages*")
+           ;; It doesn't work for `w32notify'.
+           (unless (string-equal (file-notify--test-library) "w32notify")
+             (file-notify-rm-watch auto-revert-notify-watch-descriptor)
              (file-notify--wait-for-events
-              timeout
-              (string-match
-                (format-message "Reverting buffer `%s'." (buffer-name buf))
-                (buffer-string))))
-           (should (string-match "foo bla" (buffer-string)))))
+              timeout (null auto-revert-use-notify))
+             (should-not auto-revert-use-notify)
+             (should-not auto-revert-notify-watch-descriptor)
+
+             ;; Modify file.  We wait for two seconds, in order to
+             ;; have another timestamp.  One second seems to be too
+             ;; short.
+             (with-current-buffer (get-buffer-create "*Messages*")
+               (narrow-to-region (point-max) (point-max)))
+             (sleep-for 2)
+             (write-region
+              "foo bla" nil file-notify--test-tmpfile nil 'no-message)
+
+             ;; Check, that the buffer has been reverted.
+             (with-current-buffer (get-buffer-create "*Messages*")
+               (file-notify--wait-for-events
+                timeout
+                (string-match
+                 (format-message "Reverting buffer `%s'." (buffer-name buf))
+                 (buffer-string))))
+             (should (string-match "foo bla" (buffer-string))))))
 
       ;; Cleanup.
       (with-current-buffer "*Messages*" (widen))
@@ -509,51 +632,94 @@ Don't wait longer than timeout seconds for the events to 
be delivered."
 (ert-deftest file-notify-test04-file-validity ()
   "Check `file-notify-valid-p' for files."
   (skip-unless (file-notify--test-local-enabled))
-  ;; Under cygwin there are so bad timings that it doesn't make sense to test.
-  (skip-unless (not (eq system-type 'cygwin)))
 
   (unwind-protect
       (progn
-        (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
-              file-notify--test-desc
-              (file-notify-add-watch
-               file-notify--test-tmpfile
-               '(change) #'file-notify--test-event-handler))
-        (file-notify--test-with-events '(created changed deleted)
+        (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
+       (write-region "any text" nil file-notify--test-tmpfile nil 'no-message)
+       (should
+        (setq file-notify--test-desc
+              (file-notify-add-watch
+               file-notify--test-tmpfile
+               '(change) #'file-notify--test-event-handler)))
+        (should (file-notify-valid-p file-notify--test-desc))
+       ;; After calling `file-notify-rm-watch', the descriptor is not
+       ;; valid anymore.
+        (file-notify-rm-watch file-notify--test-desc)
+        (should-not (file-notify-valid-p file-notify--test-desc))
+       (delete-file file-notify--test-tmpfile))
+
+    ;; Cleanup.
+    (file-notify--test-cleanup))
+
+  (unwind-protect
+      (progn
+        (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
+       (write-region "any text" nil file-notify--test-tmpfile nil 'no-message)
+       (should
+        (setq file-notify--test-desc
+              (file-notify-add-watch
+               file-notify--test-tmpfile
+               '(change) #'file-notify--test-event-handler)))
+        (file-notify--test-with-events
+            (cond
+             ;; cygwin recognizes only `deleted' and `stopped' events.
+            ((eq system-type 'cygwin)
+             '(deleted stopped))
+             ;; inotify and kqueue raise just one `changed' event.
+             ((or (string-equal "inotify" (file-notify--test-library))
+                  (string-equal "kqueue" (file-notify--test-library)))
+             '(changed deleted stopped))
+             ;; gfilenotify raises one or two `changed' events
+             ;; randomly, no chance to test.  So we accept both cases.
+             ((string-equal "gfilenotify" (file-notify--test-library))
+              '((changed deleted stopped)
+                (changed changed deleted stopped)))
+            (t '(changed changed deleted stopped)))
           (should (file-notify-valid-p file-notify--test-desc))
+         (read-event nil nil 0.1)
           (write-region
-           "any text" nil file-notify--test-tmpfile nil 'no-message)
+           "another text" nil file-notify--test-tmpfile nil 'no-message)
+         (read-event nil nil 0.1)
          (delete-file file-notify--test-tmpfile))
-       ;; After deleting the file, the descriptor is still valid.
-        (should (file-notify-valid-p file-notify--test-desc))
-       ;; After removing the watch, the descriptor must not be valid
-        ;; anymore.
-        (file-notify-rm-watch file-notify--test-desc)
-        (should-not (file-notify-valid-p file-notify--test-desc)))
+       ;; After deleting the file, the descriptor is not valid anymore.
+        (should-not (file-notify-valid-p file-notify--test-desc))
+        (file-notify-rm-watch file-notify--test-desc))
 
     ;; Cleanup.
     (file-notify--test-cleanup))
 
   (unwind-protect
-      ;; The batch-mode operation of w32notify is fragile (there's no
-      ;; input threads to send the message to).
-      ;(unless (and noninteractive (eq file-notify--library 'w32notify))
-      (unless (eq file-notify--library 'w32notify)
-        (let ((temporary-file-directory
+      ;; w32notify does not send a `stopped' event when deleting a
+      ;; directory.  The test does not work, therefore.
+      (unless (string-equal (file-notify--test-library) "w32notify")
+       (let ((temporary-file-directory
               (make-temp-file "file-notify-test-parent" t)))
-          (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
-                file-notify--test-desc
-                (file-notify-add-watch
-                 file-notify--test-tmpfile
-                 '(change) #'file-notify--test-event-handler))
-          (file-notify--test-with-events '(created changed deleted stopped)
-            (should (file-notify-valid-p file-notify--test-desc))
-            (write-region
-             "any text" nil file-notify--test-tmpfile nil 'no-message)
+         (should
+          (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
+                file-notify--test-desc
+                (file-notify-add-watch
+                 temporary-file-directory
+                 '(change) #'file-notify--test-event-handler)))
+         (file-notify--test-with-events
+             (cond
+              ;; cygwin recognizes only `deleted' and `stopped' events.
+              ((eq system-type 'cygwin)
+               '(deleted stopped))
+              ;; There are two `deleted' events, for the file and for
+              ;; the directory.  Except for kqueue.
+              ((string-equal (file-notify--test-library) "kqueue")
+               '(created changed deleted stopped))
+              (t '(created changed deleted deleted stopped)))
+           (should (file-notify-valid-p file-notify--test-desc))
+           (read-event nil nil 0.1)
+           (write-region
+            "any text" nil file-notify--test-tmpfile nil 'no-message)
+           (read-event nil nil 0.1)
            (delete-directory temporary-file-directory t))
-          ;; After deleting the parent directory, the descriptor must
-          ;; not be valid anymore.
-          (should-not (file-notify-valid-p file-notify--test-desc))))
+         ;; After deleting the parent directory, the descriptor must
+         ;; not be valid anymore.
+         (should-not (file-notify-valid-p file-notify--test-desc))))
 
     ;; Cleanup.
     (file-notify--test-cleanup)))
@@ -570,10 +736,11 @@ Don't wait longer than timeout seconds for the events to 
be delivered."
         (setq file-notify--test-tmpfile
              (file-name-as-directory (file-notify--test-make-temp-name)))
         (make-directory file-notify--test-tmpfile)
-        (setq file-notify--test-desc
-              (file-notify-add-watch
-               file-notify--test-tmpfile
-               '(change) #'file-notify--test-event-handler))
+       (should
+        (setq file-notify--test-desc
+              (file-notify-add-watch
+               file-notify--test-tmpfile
+               '(change) #'file-notify--test-event-handler)))
         (should (file-notify-valid-p file-notify--test-desc))
         ;; After removing the watch, the descriptor must not be valid
         ;; anymore.
@@ -589,20 +756,22 @@ Don't wait longer than timeout seconds for the events to 
be delivered."
   (unwind-protect
       ;; The batch-mode operation of w32notify is fragile (there's no
       ;; input threads to send the message to).
-      (unless (and noninteractive (eq file-notify--library 'w32notify))
+      (unless (and noninteractive
+                  (string-equal (file-notify--test-library) "w32notify"))
         (setq file-notify--test-tmpfile
              (file-name-as-directory (file-notify--test-make-temp-name)))
         (make-directory file-notify--test-tmpfile)
-        (setq file-notify--test-desc
-              (file-notify-add-watch
-               file-notify--test-tmpfile
-               '(change) #'file-notify--test-event-handler))
+       (should
+        (setq file-notify--test-desc
+              (file-notify-add-watch
+               file-notify--test-tmpfile
+               '(change) #'file-notify--test-event-handler)))
         (should (file-notify-valid-p file-notify--test-desc))
         ;; After deleting the directory, the descriptor must not be
         ;; valid anymore.
         (delete-directory file-notify--test-tmpfile t)
         (file-notify--wait-for-events
-         (file-notify--test-timeout)
+        (file-notify--test-timeout)
         (not (file-notify-valid-p file-notify--test-desc)))
         (should-not (file-notify-valid-p file-notify--test-desc)))
 
@@ -612,6 +781,61 @@ Don't wait longer than timeout seconds for the events to 
be delivered."
 (file-notify--deftest-remote file-notify-test05-dir-validity
   "Check `file-notify-valid-p' via file notification for remote directories.")
 
+(ert-deftest file-notify-test06-many-events ()
+  "Check that events are not dropped."
+  (skip-unless (file-notify--test-local-enabled))
+  ;; Under cygwin events arrive in random order.  Impossible to define a test.
+  (skip-unless (not (eq system-type 'cygwin)))
+
+  (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
+  (make-directory file-notify--test-tmpfile)
+  (should
+   (setq file-notify--test-desc
+        (file-notify-add-watch
+         file-notify--test-tmpfile
+         '(change) 'file-notify--test-event-handler)))
+  (unwind-protect
+      (let ((n 1000)
+            source-file-list target-file-list
+            (default-directory file-notify--test-tmpfile))
+        (dotimes (i n)
+         ;; It matters which direction we rename, at least for
+         ;; kqueue.  This backend parses directories in alphabetic
+         ;; order (x%d before y%d).  So we rename both directions.
+         (if (zerop (mod i 2))
+             (progn
+               (push (expand-file-name (format "x%d" i)) source-file-list)
+               (push (expand-file-name (format "y%d" i)) target-file-list))
+           (push (expand-file-name (format "y%d" i)) source-file-list)
+           (push (expand-file-name (format "x%d" i)) target-file-list)))
+        (file-notify--test-with-events (make-list (+ n n) 'created)
+          (let ((source-file-list source-file-list)
+                (target-file-list target-file-list))
+            (while (and source-file-list target-file-list)
+              (read-event nil nil 0.1)
+              (write-region "" nil (pop source-file-list) nil 'no-message)
+              (read-event nil nil 0.1)
+              (write-region "" nil (pop target-file-list) nil 'no-message))))
+        (file-notify--test-with-events
+           (cond
+            ;; w32notify fires both `deleted' and `renamed' events.
+            ((string-equal (file-notify--test-library) "w32notify")
+             (let (r)
+               (dotimes (_i n r)
+                 (setq r (append '(deleted renamed) r)))))
+            (t (make-list n 'renamed)))
+          (let ((source-file-list source-file-list)
+                (target-file-list target-file-list))
+            (while (and source-file-list target-file-list)
+              (rename-file (pop source-file-list) (pop target-file-list) t))))
+        (file-notify--test-with-events (make-list n 'deleted)
+          (dolist (file target-file-list)
+            (delete-file file))))
+    (file-notify--test-cleanup)))
+
+(file-notify--deftest-remote file-notify-test06-many-events
+   "Check that events are not dropped for remote directories.")
+
 (defun file-notify-test-all (&optional interactive)
   "Run all tests for \\[file-notify]."
   (interactive "p")
@@ -622,7 +846,7 @@ Don't wait longer than timeout seconds for the events to be 
delivered."
 ;; TODO:
 
 ;; * For w32notify, no stopped events arrive when a directory is removed.
-;; * Try to handle arriving events under cygwin reliably.
+;; * Check, why cygwin recognizes only `deleted' and `stopped' events.
 
 (provide 'file-notify-tests)
 ;;; file-notify-tests.el ends here
diff --git a/test/automated/auth-source-tests.el 
b/test/lisp/gnus/auth-source-tests.el
similarity index 100%
rename from test/automated/auth-source-tests.el
rename to test/lisp/gnus/auth-source-tests.el
diff --git a/test/automated/gnus-tests.el b/test/lisp/gnus/gnus-tests.el
similarity index 100%
rename from test/automated/gnus-tests.el
rename to test/lisp/gnus/gnus-tests.el
diff --git a/test/automated/message-mode-tests.el 
b/test/lisp/gnus/message-tests.el
similarity index 100%
rename from test/automated/message-mode-tests.el
rename to test/lisp/gnus/message-tests.el
diff --git a/test/automated/help-fns.el b/test/lisp/help-fns-tests.el
similarity index 100%
rename from test/automated/help-fns.el
rename to test/lisp/help-fns-tests.el
diff --git a/test/automated/imenu-test.el b/test/lisp/imenu-tests.el
similarity index 100%
rename from test/automated/imenu-test.el
rename to test/lisp/imenu-tests.el
diff --git a/test/automated/info-xref.el b/test/lisp/info-xref-tests.el
similarity index 100%
rename from test/automated/info-xref.el
rename to test/lisp/info-xref-tests.el
diff --git a/test/automated/mule-util.el 
b/test/lisp/international/mule-util-tests.el
similarity index 100%
rename from test/automated/mule-util.el
rename to test/lisp/international/mule-util-tests.el
diff --git a/test/automated/isearch-tests.el b/test/lisp/isearch-tests.el
similarity index 100%
rename from test/automated/isearch-tests.el
rename to test/lisp/isearch-tests.el
diff --git a/test/automated/json-tests.el b/test/lisp/json-tests.el
similarity index 100%
rename from test/automated/json-tests.el
rename to test/lisp/json-tests.el
diff --git a/test/automated/bytecomp-tests.el 
b/test/lisp/legacy/bytecomp-tests.el
similarity index 100%
rename from test/automated/bytecomp-tests.el
rename to test/lisp/legacy/bytecomp-tests.el
diff --git a/test/automated/coding-tests.el b/test/lisp/legacy/coding-tests.el
similarity index 100%
rename from test/automated/coding-tests.el
rename to test/lisp/legacy/coding-tests.el
diff --git a/test/automated/core-elisp-tests.el 
b/test/lisp/legacy/core-elisp-tests.el
similarity index 100%
rename from test/automated/core-elisp-tests.el
rename to test/lisp/legacy/core-elisp-tests.el
diff --git a/test/automated/decoder-tests.el b/test/lisp/legacy/decoder-tests.el
similarity index 100%
rename from test/automated/decoder-tests.el
rename to test/lisp/legacy/decoder-tests.el
diff --git a/test/automated/files.el b/test/lisp/legacy/files-tests.el
similarity index 100%
rename from test/automated/files.el
rename to test/lisp/legacy/files-tests.el
diff --git a/test/automated/font-parse-tests.el 
b/test/lisp/legacy/font-parse-tests.el
similarity index 100%
rename from test/automated/font-parse-tests.el
rename to test/lisp/legacy/font-parse-tests.el
diff --git a/test/automated/lexbind-tests.el b/test/lisp/legacy/lexbind-tests.el
similarity index 100%
rename from test/automated/lexbind-tests.el
rename to test/lisp/legacy/lexbind-tests.el
diff --git a/test/automated/occur-tests.el b/test/lisp/legacy/occur-tests.el
similarity index 100%
rename from test/automated/occur-tests.el
rename to test/lisp/legacy/occur-tests.el
diff --git a/test/automated/process-tests.el b/test/lisp/legacy/process-tests.el
similarity index 100%
rename from test/automated/process-tests.el
rename to test/lisp/legacy/process-tests.el
diff --git a/test/automated/syntax-tests.el b/test/lisp/legacy/syntax-tests.el
similarity index 100%
rename from test/automated/syntax-tests.el
rename to test/lisp/legacy/syntax-tests.el
diff --git a/test/automated/textprop-tests.el 
b/test/lisp/legacy/textprop-tests.el
similarity index 100%
rename from test/automated/textprop-tests.el
rename to test/lisp/legacy/textprop-tests.el
diff --git a/test/automated/undo-tests.el b/test/lisp/legacy/undo-tests.el
similarity index 100%
rename from test/automated/undo-tests.el
rename to test/lisp/legacy/undo-tests.el
diff --git a/test/automated/man-tests.el b/test/lisp/man-tests.el
similarity index 100%
rename from test/automated/man-tests.el
rename to test/lisp/man-tests.el
diff --git a/test/automated/completion-tests.el b/test/lisp/minibuffer-tests.el
similarity index 100%
rename from test/automated/completion-tests.el
rename to test/lisp/minibuffer-tests.el
diff --git a/test/automated/dbus-tests.el b/test/lisp/net/dbus-tests.el
similarity index 100%
rename from test/automated/dbus-tests.el
rename to test/lisp/net/dbus-tests.el
diff --git a/test/automated/newsticker-tests.el 
b/test/lisp/net/newsticker-tests.el
similarity index 100%
rename from test/automated/newsticker-tests.el
rename to test/lisp/net/newsticker-tests.el
diff --git a/test/automated/sasl-scram-rfc-tests.el 
b/test/lisp/net/sasl-scram-rfc-tests.el
similarity index 100%
rename from test/automated/sasl-scram-rfc-tests.el
rename to test/lisp/net/sasl-scram-rfc-tests.el
diff --git a/test/automated/tramp-tests.el b/test/lisp/net/tramp-tests.el
similarity index 100%
rename from test/automated/tramp-tests.el
rename to test/lisp/net/tramp-tests.el
diff --git a/test/automated/obarray-tests.el b/test/lisp/obarray-tests.el
similarity index 100%
rename from test/automated/obarray-tests.el
rename to test/lisp/obarray-tests.el
diff --git a/test/automated/compile-tests.el 
b/test/lisp/progmodes/compile-tests.el
similarity index 100%
rename from test/automated/compile-tests.el
rename to test/lisp/progmodes/compile-tests.el
diff --git a/test/automated/elisp-mode-tests.el 
b/test/lisp/progmodes/elisp-mode-tests.el
similarity index 94%
rename from test/automated/elisp-mode-tests.el
rename to test/lisp/progmodes/elisp-mode-tests.el
index 38c0b3b..97f86a9 100644
--- a/test/automated/elisp-mode-tests.el
+++ b/test/lisp/progmodes/elisp-mode-tests.el
@@ -244,7 +244,7 @@ to (xref-elisp-test-descr-to-target xref)."
     (xref-make "(cl-defstruct (xref-elisp-location (:constructor 
xref-make-elisp-location)))"
                (xref-make-elisp-location
                 'xref-elisp-location 'define-type
-                (expand-file-name "../../lisp/progmodes/elisp-mode.el" 
emacs-test-dir)))
+                (expand-file-name "../../../lisp/progmodes/elisp-mode.el" 
emacs-test-dir)))
     ;; It's not worth adding another special case to 
`xref-elisp-test-descr-to-target' for this
     "(cl-defstruct (xref-elisp-location")
    ))
@@ -255,11 +255,11 @@ to (xref-elisp-test-descr-to-target xref)."
    (xref-make "(defalias Buffer-menu-sort)"
              (xref-make-elisp-location
               'Buffer-menu-sort 'defalias
-              (expand-file-name "../../lisp/buff-menu.elc" emacs-test-dir)))
+              (expand-file-name "../../../lisp/buff-menu.elc" emacs-test-dir)))
    (xref-make "(defun tabulated-list-sort)"
              (xref-make-elisp-location
               'tabulated-list-sort nil
-              (expand-file-name "../../lisp/emacs-lisp/tabulated-list.el" 
emacs-test-dir)))
+              (expand-file-name "../../../lisp/emacs-lisp/tabulated-list.el" 
emacs-test-dir)))
    ))
 
 ;; FIXME: defconst
@@ -406,27 +406,27 @@ to (xref-elisp-test-descr-to-target xref)."
    (xref-make "(cl-defgeneric xref-location-marker)"
              (xref-make-elisp-location
               'xref-location-marker 'cl-defgeneric
-              (expand-file-name "../../lisp/progmodes/xref.el" 
emacs-test-dir)))
+              (expand-file-name "../../../lisp/progmodes/xref.el" 
emacs-test-dir)))
    (xref-make "(cl-defmethod xref-location-marker ((l xref-elisp-location)))"
              (xref-make-elisp-location
               '(xref-location-marker xref-elisp-location) 'cl-defmethod
-              (expand-file-name "../../lisp/progmodes/elisp-mode.el" 
emacs-test-dir)))
+              (expand-file-name "../../../lisp/progmodes/elisp-mode.el" 
emacs-test-dir)))
    (xref-make "(cl-defmethod xref-location-marker ((l xref-file-location)))"
              (xref-make-elisp-location
               '(xref-location-marker xref-file-location) 'cl-defmethod
-              (expand-file-name "../../lisp/progmodes/xref.el" 
emacs-test-dir)))
+              (expand-file-name "../../../lisp/progmodes/xref.el" 
emacs-test-dir)))
    (xref-make "(cl-defmethod xref-location-marker ((l xref-buffer-location)))"
              (xref-make-elisp-location
               '(xref-location-marker xref-buffer-location) 'cl-defmethod
-              (expand-file-name "../../lisp/progmodes/xref.el" 
emacs-test-dir)))
+              (expand-file-name "../../../lisp/progmodes/xref.el" 
emacs-test-dir)))
    (xref-make "(cl-defmethod xref-location-marker ((l xref-bogus-location)))"
              (xref-make-elisp-location
               '(xref-location-marker xref-bogus-location) 'cl-defmethod
-              (expand-file-name "../../lisp/progmodes/xref.el" 
emacs-test-dir)))
+              (expand-file-name "../../../lisp/progmodes/xref.el" 
emacs-test-dir)))
    (xref-make "(cl-defmethod xref-location-marker ((l xref-etags-location)))"
               (xref-make-elisp-location
                '(xref-location-marker xref-etags-location) 'cl-defmethod
-               (expand-file-name "../../lisp/progmodes/etags.el" 
emacs-test-dir)))
+               (expand-file-name "../../../lisp/progmodes/etags.el" 
emacs-test-dir)))
    ))
 
 (xref-elisp-deftest find-defs-defgeneric-eval
@@ -528,7 +528,7 @@ to (xref-elisp-test-descr-to-target xref)."
    (xref-make "(defun xref-find-definitions)"
              (xref-make-elisp-location
               'xref-find-definitions nil
-              (expand-file-name "../../lisp/progmodes/xref.el" 
emacs-test-dir)))))
+              (expand-file-name "../../../lisp/progmodes/xref.el" 
emacs-test-dir)))))
 
 (xref-elisp-deftest find-defs-defun-eval
   (elisp--xref-find-definitions (eval '(defun stephe-leake-defun ())))
@@ -543,7 +543,7 @@ to (xref-elisp-test-descr-to-target xref)."
 ;; FIXME: deftype
 
 (xref-elisp-deftest find-defs-defun-c-defvar-c
-  (elisp-xref-find 'definitions "system-name")
+  (elisp--xref-find-definitions 'system-name)
   (list
    (xref-make "(defvar system-name)"
              (xref-make-elisp-location 'system-name 'defvar "src/editfns.c"))
@@ -552,7 +552,7 @@ to (xref-elisp-test-descr-to-target xref)."
   )
 
 (xref-elisp-deftest find-defs-defun-el-defvar-c
-  (elisp-xref-find 'definitions "abbrev-mode")
+  (elisp--xref-find-definitions 'abbrev-mode)
   ;; It's a minor mode, but the variable is defined in buffer.c
   (list
    (xref-make "(defvar abbrev-mode)"
@@ -561,7 +561,7 @@ to (xref-elisp-test-descr-to-target xref)."
     (xref-make "(defun abbrev-mode)"
                (xref-make-elisp-location
                 'abbrev-mode nil
-                (expand-file-name "../../lisp/abbrev.el" emacs-test-dir)))
+                (expand-file-name "../../../lisp/abbrev.el" emacs-test-dir)))
     "(define-minor-mode abbrev-mode"))
   )
 
@@ -582,7 +582,7 @@ to (xref-elisp-test-descr-to-target xref)."
     (xref-make "(defun compilation-minor-mode)"
                (xref-make-elisp-location
                 'compilation-minor-mode nil
-                (expand-file-name "../../lisp/progmodes/compile.el" 
emacs-test-dir)))
+                (expand-file-name "../../../lisp/progmodes/compile.el" 
emacs-test-dir)))
     "(define-minor-mode compilation-minor-mode")
    ))
 
@@ -592,7 +592,7 @@ to (xref-elisp-test-descr-to-target xref)."
    (xref-make "(defvar xref--marker-ring)"
              (xref-make-elisp-location
               'xref--marker-ring 'defvar
-              (expand-file-name "../../lisp/progmodes/xref.el" 
emacs-test-dir)))
+              (expand-file-name "../../../lisp/progmodes/xref.el" 
emacs-test-dir)))
     ))
 
 (xref-elisp-deftest find-defs-defvar-c
@@ -615,11 +615,11 @@ to (xref-elisp-test-descr-to-target xref)."
    (xref-make "(defvar font-lock-keyword-face)"
              (xref-make-elisp-location
               'font-lock-keyword-face 'defvar
-              (expand-file-name "../../lisp/font-lock.el" emacs-test-dir)))
+              (expand-file-name "../../../lisp/font-lock.el" emacs-test-dir)))
    (xref-make "(defface font-lock-keyword-face)"
              (xref-make-elisp-location
               'font-lock-keyword-face 'defface
-              (expand-file-name "../../lisp/font-lock.el" emacs-test-dir)))
+              (expand-file-name "../../../lisp/font-lock.el" emacs-test-dir)))
    ))
 
 (xref-elisp-deftest find-defs-face-eval
@@ -633,7 +633,7 @@ to (xref-elisp-test-descr-to-target xref)."
     (xref-make "(feature xref)"
              (xref-make-elisp-location
               'xref 'feature
-              (expand-file-name "../../lisp/progmodes/xref.el" 
emacs-test-dir)))
+              (expand-file-name "../../../lisp/progmodes/xref.el" 
emacs-test-dir)))
     ";;; Code:")
    ))
 
diff --git a/test/automated/f90.el b/test/lisp/progmodes/f90.el
similarity index 100%
rename from test/automated/f90.el
rename to test/lisp/progmodes/f90.el
diff --git a/test/automated/data/flymake/Makefile 
b/test/lisp/progmodes/flymake-resources/Makefile
similarity index 100%
rename from test/automated/data/flymake/Makefile
rename to test/lisp/progmodes/flymake-resources/Makefile
diff --git a/test/automated/data/flymake/test.c 
b/test/lisp/progmodes/flymake-resources/test.c
similarity index 100%
rename from test/automated/data/flymake/test.c
rename to test/lisp/progmodes/flymake-resources/test.c
diff --git a/test/automated/data/flymake/test.pl 
b/test/lisp/progmodes/flymake-resources/test.pl
similarity index 100%
rename from test/automated/data/flymake/test.pl
rename to test/lisp/progmodes/flymake-resources/test.pl
diff --git a/test/automated/flymake-tests.el 
b/test/lisp/progmodes/flymake-tests.el
similarity index 97%
rename from test/automated/flymake-tests.el
rename to test/lisp/progmodes/flymake-tests.el
index 11231bc..1d8c12c 100644
--- a/test/automated/flymake-tests.el
+++ b/test/lisp/progmodes/flymake-tests.el
@@ -26,7 +26,7 @@
 (require 'flymake)
 
 (defvar flymake-tests-data-directory
-  (expand-file-name "data/flymake" (getenv "EMACS_TEST_DIRECTORY"))
+  (expand-file-name "lisp/progmodes/flymake-resources" (getenv 
"EMACS_TEST_DIRECTORY"))
   "Directory containing flymake test data.")
 
 
diff --git a/test/automated/python-tests.el 
b/test/lisp/progmodes/python-tests.el
similarity index 100%
rename from test/automated/python-tests.el
rename to test/lisp/progmodes/python-tests.el
diff --git a/test/automated/ruby-mode-tests.el 
b/test/lisp/progmodes/ruby-mode-tests.el
similarity index 100%
rename from test/automated/ruby-mode-tests.el
rename to test/lisp/progmodes/ruby-mode-tests.el
diff --git a/test/automated/subword-tests.el 
b/test/lisp/progmodes/subword-tests.el
similarity index 100%
rename from test/automated/subword-tests.el
rename to test/lisp/progmodes/subword-tests.el
diff --git a/test/automated/replace-tests.el b/test/lisp/replace-tests.el
similarity index 100%
rename from test/automated/replace-tests.el
rename to test/lisp/replace-tests.el
diff --git a/test/automated/simple-test.el b/test/lisp/simple-tests.el
similarity index 100%
rename from test/automated/simple-test.el
rename to test/lisp/simple-tests.el
diff --git a/test/automated/sort-tests.el b/test/lisp/sort-tests.el
similarity index 100%
rename from test/automated/sort-tests.el
rename to test/lisp/sort-tests.el
diff --git a/test/automated/subr-tests.el b/test/lisp/subr-tests.el
similarity index 100%
rename from test/automated/subr-tests.el
rename to test/lisp/subr-tests.el
diff --git a/test/automated/reftex-tests.el 
b/test/lisp/textmodes/reftex-tests.el
similarity index 100%
rename from test/automated/reftex-tests.el
rename to test/lisp/textmodes/reftex-tests.el
diff --git a/test/automated/sgml-mode-tests.el 
b/test/lisp/textmodes/sgml-mode-tests.el
similarity index 100%
rename from test/automated/sgml-mode-tests.el
rename to test/lisp/textmodes/sgml-mode-tests.el
diff --git a/test/automated/tildify-tests.el 
b/test/lisp/textmodes/tildify-tests.el
similarity index 100%
rename from test/automated/tildify-tests.el
rename to test/lisp/textmodes/tildify-tests.el
diff --git a/test/automated/thingatpt.el b/test/lisp/thingatpt-tests.el
similarity index 100%
rename from test/automated/thingatpt.el
rename to test/lisp/thingatpt-tests.el
diff --git a/test/automated/url-future-tests.el 
b/test/lisp/url/url-future-tests.el
similarity index 100%
rename from test/automated/url-future-tests.el
rename to test/lisp/url/url-future-tests.el
diff --git a/test/automated/url-util-tests.el b/test/lisp/url/url-util-tests.el
similarity index 100%
rename from test/automated/url-util-tests.el
rename to test/lisp/url/url-util-tests.el
diff --git a/test/automated/add-log-tests.el b/test/lisp/vc/add-log-tests.el
similarity index 100%
rename from test/automated/add-log-tests.el
rename to test/lisp/vc/add-log-tests.el
diff --git a/test/automated/vc-bzr.el b/test/lisp/vc/vc-bzr-tests.el
similarity index 100%
rename from test/automated/vc-bzr.el
rename to test/lisp/vc/vc-bzr-tests.el
diff --git a/test/automated/vc-tests.el b/test/lisp/vc/vc-tests.el
similarity index 100%
rename from test/automated/vc-tests.el
rename to test/lisp/vc/vc-tests.el
diff --git a/test/automated/xml-parse-tests.el b/test/lisp/xml-tests.el
similarity index 100%
rename from test/automated/xml-parse-tests.el
rename to test/lisp/xml-tests.el
diff --git a/test/make-test-deps.emacs-lisp b/test/make-test-deps.emacs-lisp
new file mode 100644
index 0000000..3af0685
--- /dev/null
+++ b/test/make-test-deps.emacs-lisp
@@ -0,0 +1,98 @@
+;; -*- emacs-lisp -*-
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file generates dependencies between test files and the files
+;; that they test.
+
+;; It has an .emacs-lisp extension because it makes the Makefile easier!
+
+(require 'seq)
+
+(defun make-test-deps (src-dir)
+  (let ((src-dir (file-truename src-dir)))
+    (message
+     "%s"
+     (concat
+      (make-test-deps-lisp src-dir)
+      (make-test-deps-src src-dir)))))
+
+(defun make-test-deps-lisp (src-dir)
+  (mapconcat
+   (lambda (file-without-suffix)
+     (format "./%s-tests.log: %s/../%s.el\n"
+             file-without-suffix
+             src-dir
+             file-without-suffix))
+   (make-test-test-files src-dir "lisp") ""))
+
+(defun make-test-deps-src (src-dir)
+  (mapconcat
+   (lambda (file-without-suffix)
+     (format "./%s-tests.log: %s/../%s.c\n"
+             file-without-suffix
+             src-dir
+             file-without-suffix))
+   (make-test-test-files src-dir "src") ""))
+
+(defun make-test-test-files (src-dir sub-src-dir)
+  (make-test-munge-files
+   src-dir
+   (directory-files-recursively
+    (concat src-dir "/"  sub-src-dir)
+    ".*-tests.el$")))
+
+(defun make-test-munge-files (src-dir files)
+  (make-test-sans-suffix
+   (make-test-de-stem
+    src-dir
+    (make-test-no-legacy
+     (make-test-no-test-dir
+      (make-test-no-resources
+       files))))))
+
+(defun make-test-sans-suffix (files)
+  (mapcar
+   (lambda (file)
+     (substring file 0 -9))
+   files))
+
+(defun make-test-de-stem (stem files)
+  (mapcar
+   (lambda (file)
+     (substring
+      file
+      (+ 1 (length stem))))
+   files))
+
+(defun make-test-no-legacy (list)
+  (make-test-remove list "legacy/"))
+
+(defun make-test-no-resources (list)
+  (make-test-remove list "-resources/"))
+
+(defun make-test-no-test-dir (list)
+  (make-test-remove list "-tests/"))
+
+(defun make-test-remove (list match)
+  (seq-remove
+   (lambda (file)
+     (string-match-p match file))
+   list))
diff --git a/test/BidiCharacterTest.txt b/test/manual/BidiCharacterTest.txt
similarity index 100%
rename from test/BidiCharacterTest.txt
rename to test/manual/BidiCharacterTest.txt
diff --git a/test/biditest.el b/test/manual/biditest.el
similarity index 100%
rename from test/biditest.el
rename to test/manual/biditest.el
diff --git a/test/cedet/cedet-utests.el b/test/manual/cedet/cedet-utests.el
similarity index 100%
rename from test/cedet/cedet-utests.el
rename to test/manual/cedet/cedet-utests.el
diff --git a/test/cedet/ede-tests.el b/test/manual/cedet/ede-tests.el
similarity index 100%
rename from test/cedet/ede-tests.el
rename to test/manual/cedet/ede-tests.el
diff --git a/test/cedet/semantic-ia-utest.el 
b/test/manual/cedet/semantic-ia-utest.el
similarity index 100%
rename from test/cedet/semantic-ia-utest.el
rename to test/manual/cedet/semantic-ia-utest.el
diff --git a/test/cedet/semantic-tests.el b/test/manual/cedet/semantic-tests.el
similarity index 100%
rename from test/cedet/semantic-tests.el
rename to test/manual/cedet/semantic-tests.el
diff --git a/test/cedet/semantic-utest-c.el 
b/test/manual/cedet/semantic-utest-c.el
similarity index 100%
rename from test/cedet/semantic-utest-c.el
rename to test/manual/cedet/semantic-utest-c.el
diff --git a/test/cedet/semantic-utest.el b/test/manual/cedet/semantic-utest.el
similarity index 100%
rename from test/cedet/semantic-utest.el
rename to test/manual/cedet/semantic-utest.el
diff --git a/test/cedet/srecode-tests.el b/test/manual/cedet/srecode-tests.el
similarity index 100%
rename from test/cedet/srecode-tests.el
rename to test/manual/cedet/srecode-tests.el
diff --git a/test/cedet/tests/test.c b/test/manual/cedet/tests/test.c
similarity index 100%
rename from test/cedet/tests/test.c
rename to test/manual/cedet/tests/test.c
diff --git a/test/cedet/tests/test.el b/test/manual/cedet/tests/test.el
similarity index 100%
rename from test/cedet/tests/test.el
rename to test/manual/cedet/tests/test.el
diff --git a/test/cedet/tests/test.make b/test/manual/cedet/tests/test.make
similarity index 100%
rename from test/cedet/tests/test.make
rename to test/manual/cedet/tests/test.make
diff --git a/test/cedet/tests/testdoublens.cpp 
b/test/manual/cedet/tests/testdoublens.cpp
similarity index 100%
rename from test/cedet/tests/testdoublens.cpp
rename to test/manual/cedet/tests/testdoublens.cpp
diff --git a/test/cedet/tests/testdoublens.hpp 
b/test/manual/cedet/tests/testdoublens.hpp
similarity index 100%
rename from test/cedet/tests/testdoublens.hpp
rename to test/manual/cedet/tests/testdoublens.hpp
diff --git a/test/cedet/tests/testfriends.cpp 
b/test/manual/cedet/tests/testfriends.cpp
similarity index 100%
rename from test/cedet/tests/testfriends.cpp
rename to test/manual/cedet/tests/testfriends.cpp
diff --git a/test/cedet/tests/testjavacomp.java 
b/test/manual/cedet/tests/testjavacomp.java
similarity index 100%
rename from test/cedet/tests/testjavacomp.java
rename to test/manual/cedet/tests/testjavacomp.java
diff --git a/test/cedet/tests/testnsp.cpp b/test/manual/cedet/tests/testnsp.cpp
similarity index 100%
rename from test/cedet/tests/testnsp.cpp
rename to test/manual/cedet/tests/testnsp.cpp
diff --git a/test/cedet/tests/testpolymorph.cpp 
b/test/manual/cedet/tests/testpolymorph.cpp
similarity index 100%
rename from test/cedet/tests/testpolymorph.cpp
rename to test/manual/cedet/tests/testpolymorph.cpp
diff --git a/test/cedet/tests/testspp.c b/test/manual/cedet/tests/testspp.c
similarity index 100%
rename from test/cedet/tests/testspp.c
rename to test/manual/cedet/tests/testspp.c
diff --git a/test/cedet/tests/testsppcomplete.c 
b/test/manual/cedet/tests/testsppcomplete.c
similarity index 100%
rename from test/cedet/tests/testsppcomplete.c
rename to test/manual/cedet/tests/testsppcomplete.c
diff --git a/test/cedet/tests/testsppreplace.c 
b/test/manual/cedet/tests/testsppreplace.c
similarity index 100%
rename from test/cedet/tests/testsppreplace.c
rename to test/manual/cedet/tests/testsppreplace.c
diff --git a/test/cedet/tests/testsppreplaced.c 
b/test/manual/cedet/tests/testsppreplaced.c
similarity index 100%
rename from test/cedet/tests/testsppreplaced.c
rename to test/manual/cedet/tests/testsppreplaced.c
diff --git a/test/cedet/tests/testsubclass.cpp 
b/test/manual/cedet/tests/testsubclass.cpp
similarity index 100%
rename from test/cedet/tests/testsubclass.cpp
rename to test/manual/cedet/tests/testsubclass.cpp
diff --git a/test/cedet/tests/testsubclass.hh 
b/test/manual/cedet/tests/testsubclass.hh
similarity index 100%
rename from test/cedet/tests/testsubclass.hh
rename to test/manual/cedet/tests/testsubclass.hh
diff --git a/test/cedet/tests/testtypedefs.cpp 
b/test/manual/cedet/tests/testtypedefs.cpp
similarity index 100%
rename from test/cedet/tests/testtypedefs.cpp
rename to test/manual/cedet/tests/testtypedefs.cpp
diff --git a/test/cedet/tests/testvarnames.c 
b/test/manual/cedet/tests/testvarnames.c
similarity index 100%
rename from test/cedet/tests/testvarnames.c
rename to test/manual/cedet/tests/testvarnames.c
diff --git a/test/etags/CTAGS.good b/test/manual/etags/CTAGS.good
similarity index 100%
rename from test/etags/CTAGS.good
rename to test/manual/etags/CTAGS.good
diff --git a/test/etags/ETAGS.good_1 b/test/manual/etags/ETAGS.good_1
similarity index 100%
rename from test/etags/ETAGS.good_1
rename to test/manual/etags/ETAGS.good_1
diff --git a/test/etags/ETAGS.good_2 b/test/manual/etags/ETAGS.good_2
similarity index 100%
rename from test/etags/ETAGS.good_2
rename to test/manual/etags/ETAGS.good_2
diff --git a/test/etags/ETAGS.good_3 b/test/manual/etags/ETAGS.good_3
similarity index 100%
rename from test/etags/ETAGS.good_3
rename to test/manual/etags/ETAGS.good_3
diff --git a/test/etags/ETAGS.good_4 b/test/manual/etags/ETAGS.good_4
similarity index 100%
rename from test/etags/ETAGS.good_4
rename to test/manual/etags/ETAGS.good_4
diff --git a/test/etags/ETAGS.good_5 b/test/manual/etags/ETAGS.good_5
similarity index 100%
rename from test/etags/ETAGS.good_5
rename to test/manual/etags/ETAGS.good_5
diff --git a/test/etags/ETAGS.good_6 b/test/manual/etags/ETAGS.good_6
similarity index 100%
rename from test/etags/ETAGS.good_6
rename to test/manual/etags/ETAGS.good_6
diff --git a/test/etags/Makefile b/test/manual/etags/Makefile
similarity index 97%
rename from test/etags/Makefile
rename to test/manual/etags/Makefile
index f326c90..f5cf2ae 100644
--- a/test/etags/Makefile
+++ b/test/manual/etags/Makefile
@@ -31,8 +31,8 @@ SRCS=${ADASRC} ${ASRC} ${CSRC} ${CPSRC} ${ELSRC} ${ERLSRC} 
${FSRC}\
      ${TEXSRC} ${YSRC}
 NONSRCS=./f-src/entry.strange ./erl-src/lists.erl ./cp-src/clheir.hpp.gz
 
-ETAGS_PROG=../../lib-src/etags
-CTAGS_PROG=../../lib-src/ctags
+ETAGS_PROG=../../../lib-src/etags
+CTAGS_PROG=../../../lib-src/ctags
 
 REGEX=/[ \t]*DEFVAR_[A-Z_ \t\n(]+"\([^"]+\)"/
 xx="this line is here because of a fontlock bug
diff --git a/test/etags/a-src/empty.zz b/test/manual/etags/a-src/empty.zz
similarity index 100%
rename from test/etags/a-src/empty.zz
rename to test/manual/etags/a-src/empty.zz
diff --git a/test/etags/a-src/empty.zz.gz b/test/manual/etags/a-src/empty.zz.gz
similarity index 100%
rename from test/etags/a-src/empty.zz.gz
rename to test/manual/etags/a-src/empty.zz.gz
diff --git a/test/etags/ada-src/2ataspri.adb 
b/test/manual/etags/ada-src/2ataspri.adb
similarity index 100%
rename from test/etags/ada-src/2ataspri.adb
rename to test/manual/etags/ada-src/2ataspri.adb
diff --git a/test/etags/ada-src/2ataspri.ads 
b/test/manual/etags/ada-src/2ataspri.ads
similarity index 100%
rename from test/etags/ada-src/2ataspri.ads
rename to test/manual/etags/ada-src/2ataspri.ads
diff --git a/test/etags/ada-src/etags-test-for.ada 
b/test/manual/etags/ada-src/etags-test-for.ada
similarity index 100%
rename from test/etags/ada-src/etags-test-for.ada
rename to test/manual/etags/ada-src/etags-test-for.ada
diff --git a/test/etags/ada-src/waroquiers.ada 
b/test/manual/etags/ada-src/waroquiers.ada
similarity index 100%
rename from test/etags/ada-src/waroquiers.ada
rename to test/manual/etags/ada-src/waroquiers.ada
diff --git a/test/etags/c-src/a/b/b.c b/test/manual/etags/c-src/a/b/b.c
similarity index 100%
rename from test/etags/c-src/a/b/b.c
rename to test/manual/etags/c-src/a/b/b.c
diff --git a/test/etags/c-src/abbrev.c b/test/manual/etags/c-src/abbrev.c
similarity index 100%
rename from test/etags/c-src/abbrev.c
rename to test/manual/etags/c-src/abbrev.c
diff --git a/test/etags/c-src/c.c b/test/manual/etags/c-src/c.c
similarity index 100%
rename from test/etags/c-src/c.c
rename to test/manual/etags/c-src/c.c
diff --git a/test/etags/c-src/dostorture.c 
b/test/manual/etags/c-src/dostorture.c
similarity index 100%
rename from test/etags/c-src/dostorture.c
rename to test/manual/etags/c-src/dostorture.c
diff --git a/test/etags/c-src/emacs/src/gmalloc.c 
b/test/manual/etags/c-src/emacs/src/gmalloc.c
similarity index 100%
rename from test/etags/c-src/emacs/src/gmalloc.c
rename to test/manual/etags/c-src/emacs/src/gmalloc.c
diff --git a/test/etags/c-src/emacs/src/keyboard.c 
b/test/manual/etags/c-src/emacs/src/keyboard.c
similarity index 100%
rename from test/etags/c-src/emacs/src/keyboard.c
rename to test/manual/etags/c-src/emacs/src/keyboard.c
diff --git a/test/etags/c-src/emacs/src/lisp.h 
b/test/manual/etags/c-src/emacs/src/lisp.h
similarity index 100%
rename from test/etags/c-src/emacs/src/lisp.h
rename to test/manual/etags/c-src/emacs/src/lisp.h
diff --git a/test/etags/c-src/emacs/src/regex.h 
b/test/manual/etags/c-src/emacs/src/regex.h
similarity index 100%
rename from test/etags/c-src/emacs/src/regex.h
rename to test/manual/etags/c-src/emacs/src/regex.h
diff --git a/test/etags/c-src/etags.c b/test/manual/etags/c-src/etags.c
similarity index 100%
rename from test/etags/c-src/etags.c
rename to test/manual/etags/c-src/etags.c
diff --git a/test/etags/c-src/exit.c b/test/manual/etags/c-src/exit.c
similarity index 100%
rename from test/etags/c-src/exit.c
rename to test/manual/etags/c-src/exit.c
diff --git a/test/etags/c-src/exit.strange_suffix 
b/test/manual/etags/c-src/exit.strange_suffix
similarity index 100%
rename from test/etags/c-src/exit.strange_suffix
rename to test/manual/etags/c-src/exit.strange_suffix
diff --git a/test/etags/c-src/fail.c b/test/manual/etags/c-src/fail.c
similarity index 100%
rename from test/etags/c-src/fail.c
rename to test/manual/etags/c-src/fail.c
diff --git a/test/etags/c-src/getopt.h b/test/manual/etags/c-src/getopt.h
similarity index 100%
rename from test/etags/c-src/getopt.h
rename to test/manual/etags/c-src/getopt.h
diff --git a/test/etags/c-src/h.h b/test/manual/etags/c-src/h.h
similarity index 100%
rename from test/etags/c-src/h.h
rename to test/manual/etags/c-src/h.h
diff --git a/test/etags/c-src/machsyscalls.c 
b/test/manual/etags/c-src/machsyscalls.c
similarity index 100%
rename from test/etags/c-src/machsyscalls.c
rename to test/manual/etags/c-src/machsyscalls.c
diff --git a/test/etags/c-src/machsyscalls.h 
b/test/manual/etags/c-src/machsyscalls.h
similarity index 100%
rename from test/etags/c-src/machsyscalls.h
rename to test/manual/etags/c-src/machsyscalls.h
diff --git a/test/etags/c-src/sysdep.h b/test/manual/etags/c-src/sysdep.h
similarity index 100%
rename from test/etags/c-src/sysdep.h
rename to test/manual/etags/c-src/sysdep.h
diff --git a/test/etags/c-src/tab.c b/test/manual/etags/c-src/tab.c
similarity index 100%
rename from test/etags/c-src/tab.c
rename to test/manual/etags/c-src/tab.c
diff --git a/test/etags/c-src/torture.c b/test/manual/etags/c-src/torture.c
similarity index 100%
rename from test/etags/c-src/torture.c
rename to test/manual/etags/c-src/torture.c
diff --git a/test/etags/cp-src/MDiagArray2.h 
b/test/manual/etags/cp-src/MDiagArray2.h
similarity index 100%
rename from test/etags/cp-src/MDiagArray2.h
rename to test/manual/etags/cp-src/MDiagArray2.h
diff --git a/test/etags/cp-src/Range.h b/test/manual/etags/cp-src/Range.h
similarity index 100%
rename from test/etags/cp-src/Range.h
rename to test/manual/etags/cp-src/Range.h
diff --git a/test/etags/cp-src/burton.cpp b/test/manual/etags/cp-src/burton.cpp
similarity index 100%
rename from test/etags/cp-src/burton.cpp
rename to test/manual/etags/cp-src/burton.cpp
diff --git a/test/etags/cp-src/c.C b/test/manual/etags/cp-src/c.C
similarity index 100%
rename from test/etags/cp-src/c.C
rename to test/manual/etags/cp-src/c.C
diff --git a/test/etags/cp-src/clheir.cpp.gz 
b/test/manual/etags/cp-src/clheir.cpp.gz
similarity index 100%
rename from test/etags/cp-src/clheir.cpp.gz
rename to test/manual/etags/cp-src/clheir.cpp.gz
diff --git a/test/etags/cp-src/clheir.hpp b/test/manual/etags/cp-src/clheir.hpp
similarity index 100%
rename from test/etags/cp-src/clheir.hpp
rename to test/manual/etags/cp-src/clheir.hpp
diff --git a/test/etags/cp-src/conway.cpp b/test/manual/etags/cp-src/conway.cpp
similarity index 100%
rename from test/etags/cp-src/conway.cpp
rename to test/manual/etags/cp-src/conway.cpp
diff --git a/test/etags/cp-src/conway.hpp b/test/manual/etags/cp-src/conway.hpp
similarity index 100%
rename from test/etags/cp-src/conway.hpp
rename to test/manual/etags/cp-src/conway.hpp
diff --git a/test/etags/cp-src/fail.C b/test/manual/etags/cp-src/fail.C
similarity index 100%
rename from test/etags/cp-src/fail.C
rename to test/manual/etags/cp-src/fail.C
diff --git a/test/etags/cp-src/functions.cpp 
b/test/manual/etags/cp-src/functions.cpp
similarity index 100%
rename from test/etags/cp-src/functions.cpp
rename to test/manual/etags/cp-src/functions.cpp
diff --git a/test/etags/cp-src/screen.cpp b/test/manual/etags/cp-src/screen.cpp
similarity index 100%
rename from test/etags/cp-src/screen.cpp
rename to test/manual/etags/cp-src/screen.cpp
diff --git a/test/etags/cp-src/screen.hpp b/test/manual/etags/cp-src/screen.hpp
similarity index 100%
rename from test/etags/cp-src/screen.hpp
rename to test/manual/etags/cp-src/screen.hpp
diff --git a/test/etags/cp-src/x.cc b/test/manual/etags/cp-src/x.cc
similarity index 100%
rename from test/etags/cp-src/x.cc
rename to test/manual/etags/cp-src/x.cc
diff --git a/test/etags/el-src/TAGTEST.EL b/test/manual/etags/el-src/TAGTEST.EL
similarity index 100%
rename from test/etags/el-src/TAGTEST.EL
rename to test/manual/etags/el-src/TAGTEST.EL
diff --git a/test/etags/el-src/emacs/lisp/progmodes/etags.el 
b/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el
similarity index 100%
rename from test/etags/el-src/emacs/lisp/progmodes/etags.el
rename to test/manual/etags/el-src/emacs/lisp/progmodes/etags.el
diff --git a/test/etags/erl-src/gs_dialog.erl 
b/test/manual/etags/erl-src/gs_dialog.erl
similarity index 100%
rename from test/etags/erl-src/gs_dialog.erl
rename to test/manual/etags/erl-src/gs_dialog.erl
diff --git a/test/etags/f-src/entry.for b/test/manual/etags/f-src/entry.for
similarity index 100%
rename from test/etags/f-src/entry.for
rename to test/manual/etags/f-src/entry.for
diff --git a/test/etags/f-src/entry.strange.gz 
b/test/manual/etags/f-src/entry.strange.gz
similarity index 100%
rename from test/etags/f-src/entry.strange.gz
rename to test/manual/etags/f-src/entry.strange.gz
diff --git a/test/etags/f-src/entry.strange_suffix 
b/test/manual/etags/f-src/entry.strange_suffix
similarity index 100%
rename from test/etags/f-src/entry.strange_suffix
rename to test/manual/etags/f-src/entry.strange_suffix
diff --git a/test/etags/forth-src/test-forth.fth 
b/test/manual/etags/forth-src/test-forth.fth
similarity index 100%
rename from test/etags/forth-src/test-forth.fth
rename to test/manual/etags/forth-src/test-forth.fth
diff --git a/test/etags/html-src/algrthms.html 
b/test/manual/etags/html-src/algrthms.html
similarity index 100%
rename from test/etags/html-src/algrthms.html
rename to test/manual/etags/html-src/algrthms.html
diff --git a/test/etags/html-src/index.shtml 
b/test/manual/etags/html-src/index.shtml
similarity index 100%
rename from test/etags/html-src/index.shtml
rename to test/manual/etags/html-src/index.shtml
diff --git a/test/etags/html-src/software.html 
b/test/manual/etags/html-src/software.html
similarity index 100%
rename from test/etags/html-src/software.html
rename to test/manual/etags/html-src/software.html
diff --git a/test/etags/html-src/softwarelibero.html 
b/test/manual/etags/html-src/softwarelibero.html
similarity index 100%
rename from test/etags/html-src/softwarelibero.html
rename to test/manual/etags/html-src/softwarelibero.html
diff --git a/test/etags/lua-src/allegro.lua 
b/test/manual/etags/lua-src/allegro.lua
similarity index 100%
rename from test/etags/lua-src/allegro.lua
rename to test/manual/etags/lua-src/allegro.lua
diff --git a/test/etags/make-src/Makefile b/test/manual/etags/make-src/Makefile
similarity index 100%
rename from test/etags/make-src/Makefile
rename to test/manual/etags/make-src/Makefile
diff --git a/test/etags/objc-src/PackInsp.h 
b/test/manual/etags/objc-src/PackInsp.h
similarity index 100%
rename from test/etags/objc-src/PackInsp.h
rename to test/manual/etags/objc-src/PackInsp.h
diff --git a/test/etags/objc-src/PackInsp.m 
b/test/manual/etags/objc-src/PackInsp.m
similarity index 100%
rename from test/etags/objc-src/PackInsp.m
rename to test/manual/etags/objc-src/PackInsp.m
diff --git a/test/etags/objc-src/Subprocess.h 
b/test/manual/etags/objc-src/Subprocess.h
similarity index 100%
rename from test/etags/objc-src/Subprocess.h
rename to test/manual/etags/objc-src/Subprocess.h
diff --git a/test/etags/objc-src/Subprocess.m 
b/test/manual/etags/objc-src/Subprocess.m
similarity index 100%
rename from test/etags/objc-src/Subprocess.m
rename to test/manual/etags/objc-src/Subprocess.m
diff --git a/test/etags/objcpp-src/SimpleCalc.H 
b/test/manual/etags/objcpp-src/SimpleCalc.H
similarity index 100%
rename from test/etags/objcpp-src/SimpleCalc.H
rename to test/manual/etags/objcpp-src/SimpleCalc.H
diff --git a/test/etags/objcpp-src/SimpleCalc.M 
b/test/manual/etags/objcpp-src/SimpleCalc.M
similarity index 100%
rename from test/etags/objcpp-src/SimpleCalc.M
rename to test/manual/etags/objcpp-src/SimpleCalc.M
diff --git a/test/etags/pas-src/common.pas 
b/test/manual/etags/pas-src/common.pas
similarity index 100%
rename from test/etags/pas-src/common.pas
rename to test/manual/etags/pas-src/common.pas
diff --git a/test/etags/perl-src/htlmify-cystic 
b/test/manual/etags/perl-src/htlmify-cystic
similarity index 100%
rename from test/etags/perl-src/htlmify-cystic
rename to test/manual/etags/perl-src/htlmify-cystic
diff --git a/test/etags/perl-src/kai-test.pl 
b/test/manual/etags/perl-src/kai-test.pl
similarity index 100%
rename from test/etags/perl-src/kai-test.pl
rename to test/manual/etags/perl-src/kai-test.pl
diff --git a/test/etags/perl-src/yagrip.pl 
b/test/manual/etags/perl-src/yagrip.pl
similarity index 100%
rename from test/etags/perl-src/yagrip.pl
rename to test/manual/etags/perl-src/yagrip.pl
diff --git a/test/etags/php-src/lce_functions.php 
b/test/manual/etags/php-src/lce_functions.php
similarity index 100%
rename from test/etags/php-src/lce_functions.php
rename to test/manual/etags/php-src/lce_functions.php
diff --git a/test/etags/php-src/ptest.php b/test/manual/etags/php-src/ptest.php
similarity index 100%
rename from test/etags/php-src/ptest.php
rename to test/manual/etags/php-src/ptest.php
diff --git a/test/etags/php-src/sendmail.php 
b/test/manual/etags/php-src/sendmail.php
similarity index 100%
rename from test/etags/php-src/sendmail.php
rename to test/manual/etags/php-src/sendmail.php
diff --git a/test/etags/prol-src/natded.prolog 
b/test/manual/etags/prol-src/natded.prolog
similarity index 100%
rename from test/etags/prol-src/natded.prolog
rename to test/manual/etags/prol-src/natded.prolog
diff --git a/test/etags/prol-src/ordsets.prolog 
b/test/manual/etags/prol-src/ordsets.prolog
similarity index 100%
rename from test/etags/prol-src/ordsets.prolog
rename to test/manual/etags/prol-src/ordsets.prolog
diff --git a/test/etags/ps-src/rfc1245.ps b/test/manual/etags/ps-src/rfc1245.ps
similarity index 100%
rename from test/etags/ps-src/rfc1245.ps
rename to test/manual/etags/ps-src/rfc1245.ps
diff --git a/test/etags/pyt-src/server.py b/test/manual/etags/pyt-src/server.py
similarity index 100%
rename from test/etags/pyt-src/server.py
rename to test/manual/etags/pyt-src/server.py
diff --git a/test/etags/tex-src/gzip.texi b/test/manual/etags/tex-src/gzip.texi
similarity index 100%
rename from test/etags/tex-src/gzip.texi
rename to test/manual/etags/tex-src/gzip.texi
diff --git a/test/etags/tex-src/nonewline.tex 
b/test/manual/etags/tex-src/nonewline.tex
similarity index 100%
rename from test/etags/tex-src/nonewline.tex
rename to test/manual/etags/tex-src/nonewline.tex
diff --git a/test/etags/tex-src/testenv.tex 
b/test/manual/etags/tex-src/testenv.tex
similarity index 100%
rename from test/etags/tex-src/testenv.tex
rename to test/manual/etags/tex-src/testenv.tex
diff --git a/test/etags/tex-src/texinfo.tex 
b/test/manual/etags/tex-src/texinfo.tex
similarity index 100%
rename from test/etags/tex-src/texinfo.tex
rename to test/manual/etags/tex-src/texinfo.tex
diff --git a/test/etags/y-src/atest.y b/test/manual/etags/y-src/atest.y
similarity index 100%
rename from test/etags/y-src/atest.y
rename to test/manual/etags/y-src/atest.y
diff --git a/test/etags/y-src/cccp.c b/test/manual/etags/y-src/cccp.c
similarity index 100%
rename from test/etags/y-src/cccp.c
rename to test/manual/etags/y-src/cccp.c
diff --git a/test/etags/y-src/cccp.y b/test/manual/etags/y-src/cccp.y
similarity index 100%
rename from test/etags/y-src/cccp.y
rename to test/manual/etags/y-src/cccp.y
diff --git a/test/etags/y-src/parse.c b/test/manual/etags/y-src/parse.c
similarity index 100%
rename from test/etags/y-src/parse.c
rename to test/manual/etags/y-src/parse.c
diff --git a/test/etags/y-src/parse.y b/test/manual/etags/y-src/parse.y
similarity index 100%
rename from test/etags/y-src/parse.y
rename to test/manual/etags/y-src/parse.y
diff --git a/test/indent/Makefile b/test/manual/indent/Makefile
similarity index 100%
rename from test/indent/Makefile
rename to test/manual/indent/Makefile
diff --git a/test/indent/css-mode.css b/test/manual/indent/css-mode.css
similarity index 100%
rename from test/indent/css-mode.css
rename to test/manual/indent/css-mode.css
diff --git a/test/indent/js-indent-init-dynamic.js 
b/test/manual/indent/js-indent-init-dynamic.js
similarity index 100%
rename from test/indent/js-indent-init-dynamic.js
rename to test/manual/indent/js-indent-init-dynamic.js
diff --git a/test/indent/js-indent-init-t.js 
b/test/manual/indent/js-indent-init-t.js
similarity index 100%
rename from test/indent/js-indent-init-t.js
rename to test/manual/indent/js-indent-init-t.js
diff --git a/test/indent/js-jsx.js b/test/manual/indent/js-jsx.js
similarity index 100%
rename from test/indent/js-jsx.js
rename to test/manual/indent/js-jsx.js
diff --git a/test/indent/js.js b/test/manual/indent/js.js
similarity index 100%
rename from test/indent/js.js
rename to test/manual/indent/js.js
diff --git a/test/indent/latex-mode.tex b/test/manual/indent/latex-mode.tex
similarity index 100%
rename from test/indent/latex-mode.tex
rename to test/manual/indent/latex-mode.tex
diff --git a/test/indent/modula2.mod b/test/manual/indent/modula2.mod
similarity index 100%
rename from test/indent/modula2.mod
rename to test/manual/indent/modula2.mod
diff --git a/test/indent/nxml.xml b/test/manual/indent/nxml.xml
similarity index 100%
rename from test/indent/nxml.xml
rename to test/manual/indent/nxml.xml
diff --git a/test/indent/octave.m b/test/manual/indent/octave.m
similarity index 100%
rename from test/indent/octave.m
rename to test/manual/indent/octave.m
diff --git a/test/indent/pascal.pas b/test/manual/indent/pascal.pas
similarity index 100%
rename from test/indent/pascal.pas
rename to test/manual/indent/pascal.pas
diff --git a/test/indent/perl.perl b/test/manual/indent/perl.perl
similarity index 100%
rename from test/indent/perl.perl
rename to test/manual/indent/perl.perl
diff --git a/test/indent/prolog.prolog b/test/manual/indent/prolog.prolog
similarity index 100%
rename from test/indent/prolog.prolog
rename to test/manual/indent/prolog.prolog
diff --git a/test/indent/ps-mode.ps b/test/manual/indent/ps-mode.ps
similarity index 100%
rename from test/indent/ps-mode.ps
rename to test/manual/indent/ps-mode.ps
diff --git a/test/indent/ruby.rb b/test/manual/indent/ruby.rb
similarity index 100%
rename from test/indent/ruby.rb
rename to test/manual/indent/ruby.rb
diff --git a/test/indent/scheme.scm b/test/manual/indent/scheme.scm
similarity index 100%
rename from test/indent/scheme.scm
rename to test/manual/indent/scheme.scm
diff --git a/test/indent/scss-mode.scss b/test/manual/indent/scss-mode.scss
similarity index 100%
rename from test/indent/scss-mode.scss
rename to test/manual/indent/scss-mode.scss
diff --git a/test/indent/sgml-mode-attribute.html 
b/test/manual/indent/sgml-mode-attribute.html
similarity index 100%
rename from test/indent/sgml-mode-attribute.html
rename to test/manual/indent/sgml-mode-attribute.html
diff --git a/test/indent/shell.rc b/test/manual/indent/shell.rc
similarity index 100%
rename from test/indent/shell.rc
rename to test/manual/indent/shell.rc
diff --git a/test/indent/shell.sh b/test/manual/indent/shell.sh
similarity index 100%
rename from test/indent/shell.sh
rename to test/manual/indent/shell.sh
diff --git a/test/redisplay-testsuite.el b/test/manual/redisplay-testsuite.el
similarity index 100%
rename from test/redisplay-testsuite.el
rename to test/manual/redisplay-testsuite.el
diff --git a/test/rmailmm.el b/test/manual/rmailmm.el
similarity index 100%
rename from test/rmailmm.el
rename to test/manual/rmailmm.el
diff --git a/test/automated/finalizer-tests.el b/test/src/alloc-tests.el
similarity index 93%
rename from test/automated/finalizer-tests.el
rename to test/src/alloc-tests.el
index 218df05..c0fe0f3 100644
--- a/test/automated/finalizer-tests.el
+++ b/test/src/alloc-tests.el
@@ -1,4 +1,4 @@
-;;; finalizer-tests.el --- Finalizer tests -*- lexical-binding: t -*-
+;;; alloc-tests.el --- alloc tests -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2015 Free Software Foundation, Inc.
 
diff --git a/test/automated/buffer-tests.el b/test/src/buffer-tests.el
similarity index 100%
rename from test/automated/buffer-tests.el
rename to test/src/buffer-tests.el
diff --git a/test/automated/cmds-tests.el b/test/src/cmds-tests.el
similarity index 100%
rename from test/automated/cmds-tests.el
rename to test/src/cmds-tests.el
diff --git a/test/automated/data-tests.el b/test/src/data-tests.el
similarity index 100%
rename from test/automated/data-tests.el
rename to test/src/data-tests.el
diff --git a/test/automated/zlib-tests.el b/test/src/decompress-tests.el
similarity index 92%
rename from test/automated/zlib-tests.el
rename to test/src/decompress-tests.el
index c6c084d..1eea673 100644
--- a/test/automated/zlib-tests.el
+++ b/test/src/decompress-tests.el
@@ -1,4 +1,4 @@
-;;; zlib-tests.el --- Test suite for zlib.
+;;; decompress-tests.el --- Test suite for decompress.
 
 ;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
 
@@ -40,6 +40,6 @@
               (buffer-string))
             "foo\n"))))
 
-(provide 'zlib-tests)
+(provide 'decompress-tests)
 
-;;; zlib-tests.el ends here.
+;;; decompress-tests.el ends here.
diff --git a/test/automated/fns-tests.el b/test/src/fns-tests.el
similarity index 100%
rename from test/automated/fns-tests.el
rename to test/src/fns-tests.el
diff --git a/test/automated/inotify-test.el b/test/src/inotify-tests.el
similarity index 100%
rename from test/automated/inotify-test.el
rename to test/src/inotify-tests.el
diff --git a/test/automated/keymap-tests.el b/test/src/keymap-tests.el
similarity index 100%
rename from test/automated/keymap-tests.el
rename to test/src/keymap-tests.el
diff --git a/test/automated/print-tests.el b/test/src/print-tests.el
similarity index 100%
rename from test/automated/print-tests.el
rename to test/src/print-tests.el
diff --git a/test/automated/libxml-tests.el b/test/src/xml-tests.el
similarity index 100%
rename from test/automated/libxml-tests.el
rename to test/src/xml-tests.el



reply via email to

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