emacs-diffs
[Top][All Lists]
Advanced

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

feature/native-comp a8b8d22: Merge remote-tracking branch 'savannah/mast


From: Andrea Corallo
Subject: feature/native-comp a8b8d22: Merge remote-tracking branch 'savannah/master' into native-comp
Date: Sat, 30 Jan 2021 08:17:20 -0500 (EST)

branch: feature/native-comp
commit a8b8d220b4fccaa812e85f9b2b3715593dc285ac
Merge: b8d3ae7 ed2f2cc
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    Merge remote-tracking branch 'savannah/master' into native-comp
---
 admin/notes/unicode                     |  10 +-
 admin/unidata/unidata-gen.el            |   6 +-
 doc/emacs/glossary.texi                 |   8 +-
 doc/emacs/kmacro.texi                   |   8 +
 doc/emacs/maintaining.texi              |  22 +-
 doc/lispref/frames.texi                 |  50 ++++-
 doc/lispref/text.texi                   |  17 +-
 doc/misc/org.texi                       |   6 +-
 doc/misc/tramp.texi                     |   3 +
 etc/NEWS                                |  29 +++
 leim/leim-ext.el                        |  12 +-
 lisp/auth-source.el                     |   2 +-
 lisp/autorevert.el                      | 105 ++++-----
 lisp/calc/calc-graph.el                 |   6 +-
 lisp/dired-aux.el                       |   2 +-
 lisp/dired.el                           |  21 +-
 lisp/emacs-lisp/bindat.el               | 112 +++++-----
 lisp/emacs-lisp/checkdoc.el             |   4 +-
 lisp/emacs-lisp/crm.el                  |   2 +-
 lisp/emacs-lisp/derived.el              |   2 +-
 lisp/emacs-lisp/eieio-opt.el            |   2 +-
 lisp/emacs-lisp/generic.el              |   9 +-
 lisp/emacs-lisp/helper.el               |  29 ++-
 lisp/emacs-lisp/lisp-mode.el            |  81 ++++---
 lisp/emacs-lisp/macroexp.el             |  39 +++-
 lisp/emacs-lisp/package-x.el            |   2 +-
 lisp/emacs-lisp/pcase.el                |  44 ++--
 lisp/emacs-lisp/regi.el                 |  55 ++---
 lisp/emacs-lisp/shadow.el               |  22 +-
 lisp/emacs-lisp/tcover-ses.el           |  28 +--
 lisp/emacs-lisp/unsafep.el              |   9 +-
 lisp/ezimage.el                         |   2 +-
 lisp/faces.el                           |  11 +-
 lisp/files.el                           |   2 +-
 lisp/find-cmd.el                        |   4 +-
 lisp/flow-ctrl.el                       |  13 +-
 lisp/generic-x.el                       | 109 ++++++---
 lisp/gnus/gnus-agent.el                 | 383 ++++++++++++++++++++++----------
 lisp/gnus/gnus-async.el                 |   9 +-
 lisp/gnus/gnus-cache.el                 | 126 ++++++++---
 lisp/gnus/gnus-cloud.el                 |  16 +-
 lisp/gnus/gnus-icalendar.el             |   1 +
 lisp/gnus/gnus-sum.el                   |  65 ++----
 lisp/gnus/gnus.el                       |   9 +-
 lisp/gnus/nnvirtual.el                  | 172 ++++++++++----
 lisp/image/gravatar.el                  |  15 +-
 lisp/international/isearch-x.el         |   5 +-
 lisp/international/iso-cvt.el           |  24 +-
 lisp/international/ja-dic-cnv.el        |  11 +-
 lisp/international/ja-dic-utl.el        |   2 +-
 lisp/international/kinsoku.el           |   2 +-
 lisp/international/kkc.el               |   2 +-
 lisp/international/latexenc.el          |   4 +-
 lisp/international/latin1-disp.el       |  19 +-
 lisp/international/mule-cmds.el         |   2 +-
 lisp/international/mule-diag.el         |  27 ++-
 lisp/international/ogonek.el            |   2 +-
 lisp/international/quail.el             |  18 +-
 lisp/international/robin.el             |   2 +-
 lisp/international/titdic-cnv.el        | 254 ++++++++++-----------
 lisp/international/utf-7.el             |   2 +-
 lisp/isearch.el                         |   3 +-
 lisp/kmacro.el                          |  11 +
 lisp/language/burmese.el                |   4 +-
 lisp/language/cham.el                   |   4 +-
 lisp/language/china-util.el             |   2 +-
 lisp/language/cyril-util.el             |   2 +-
 lisp/language/ethio-util.el             |  11 +-
 lisp/language/ethiopic.el               |   4 +-
 lisp/language/hanja-util.el             |   2 +-
 lisp/language/hebrew.el                 |   6 +-
 lisp/language/ind-util.el               |  14 +-
 lisp/language/indian.el                 |   2 +-
 lisp/language/japan-util.el             |   8 +-
 lisp/language/khmer.el                  |   2 +-
 lisp/language/korea-util.el             |   6 +-
 lisp/language/korean.el                 |   4 +-
 lisp/language/lao-util.el               |   8 +-
 lisp/language/lao.el                    |   2 +-
 lisp/language/misc-lang.el              |   8 +-
 lisp/language/sinhala.el                |   2 +-
 lisp/language/tai-viet.el               |   2 +-
 lisp/language/thai-util.el              |   8 +-
 lisp/language/thai-word.el              |   5 +-
 lisp/language/tibet-util.el             |  66 +++---
 lisp/language/tibetan.el                |   2 +-
 lisp/language/tv-util.el                |   4 +-
 lisp/language/viet-util.el              |   2 +-
 lisp/leim/quail/compose.el              |   2 +-
 lisp/leim/quail/viqr.el                 |   2 +-
 lisp/mail/rmail.el                      |   8 +
 lisp/mail/rmailsum.el                   |   5 +-
 lisp/mail/sendmail.el                   |  16 +-
 lisp/net/ange-ftp.el                    |   2 +-
 lisp/net/dbus.el                        |   1 +
 lisp/net/sasl-cram.el                   |   2 +-
 lisp/net/sasl-digest.el                 |   2 +-
 lisp/net/sasl-ntlm.el                   |   4 +-
 lisp/net/sasl.el                        |  19 +-
 lisp/net/sieve-mode.el                  |  18 +-
 lisp/net/tramp-adb.el                   |  10 +-
 lisp/net/tramp-sh.el                    |   6 +
 lisp/net/webjump.el                     |   3 -
 lisp/newcomment.el                      |  47 ++--
 lisp/nxml/rng-util.el                   |   2 +-
 lisp/obsolete/nnir.el                   |   1 +
 lisp/org/ol.el                          |   8 +-
 lisp/org/org.el                         |   2 +-
 lisp/play/handwrite.el                  |  86 +++----
 lisp/play/mpuz.el                       |  30 +--
 lisp/progmodes/asm-mode.el              |   3 +-
 lisp/progmodes/bat-mode.el              |   2 +-
 lisp/progmodes/compile.el               |   7 +-
 lisp/progmodes/flymake.el               |  16 +-
 lisp/progmodes/perl-mode.el             |   7 +-
 lisp/progmodes/project.el               |   4 +-
 lisp/progmodes/sh-script.el             |  14 +-
 lisp/progmodes/xref.el                  |   3 +-
 lisp/recentf.el                         |   9 +-
 lisp/replace.el                         |  80 ++++---
 lisp/simple.el                          |  23 +-
 lisp/startup.el                         |   2 +
 lisp/subr.el                            |  10 +-
 lisp/tab-line.el                        |   4 +-
 lisp/term/w32console.el                 |   2 +-
 lisp/textmodes/nroff-mode.el            |   9 +-
 lisp/textmodes/sgml-mode.el             |   4 +-
 lisp/textmodes/tex-mode.el              |   7 +-
 lisp/tmm.el                             |  14 +-
 lisp/url/url-about.el                   |  10 +-
 lisp/url/url-cache.el                   |   2 +-
 lisp/url/url-cid.el                     |   2 +-
 lisp/url/url-dav.el                     |  18 +-
 lisp/url/url-expand.el                  |   2 +-
 lisp/url/url-file.el                    |   2 +-
 lisp/url/url-gw.el                      |  15 +-
 lisp/url/url-http.el                    |  25 +--
 lisp/url/url-imap.el                    |   5 +-
 lisp/url/url-ldap.el                    |   2 +-
 lisp/url/url-mailto.el                  |  11 +-
 lisp/url/url-methods.el                 |   4 +-
 lisp/url/url-misc.el                    |   2 +-
 lisp/url/url-news.el                    |   4 +-
 lisp/url/url-nfs.el                     |   2 +-
 lisp/url/url-privacy.el                 |   4 +-
 lisp/url/url-proxy.el                   |   2 +-
 lisp/url/url-tramp.el                   |   2 +-
 lisp/url/url.el                         |  22 +-
 lisp/vc/vc-dir.el                       |  11 +-
 lisp/vc/vc-git.el                       |   3 +-
 lisp/vc/vc-hg.el                        |   3 +-
 lisp/wdired.el                          |  24 +-
 lisp/whitespace.el                      |   4 +-
 lisp/window.el                          |   9 +-
 src/cmds.c                              |   1 +
 src/dispextern.h                        |   1 +
 src/editfns.c                           |  11 +-
 src/emacs.c                             |  10 +-
 src/fns.c                               |  34 ++-
 src/frame.c                             |  12 +
 src/frame.h                             |  22 +-
 src/nsfns.m                             |  19 ++
 src/nsterm.m                            |  10 +-
 src/process.c                           |   2 +-
 src/w32common.h                         |   5 +
 src/w32fns.c                            |  71 +++++-
 src/w32term.c                           |  27 ++-
 src/xdisp.c                             |   3 +-
 src/xfaces.c                            |   3 +
 src/xfns.c                              |  46 ++++
 src/xterm.c                             |  47 +++-
 test/Makefile.in                        |   5 +-
 test/lisp/electric-tests.el             |  15 +-
 test/lisp/find-cmd-tests.el             |  45 ++++
 test/lisp/net/sasl-cram-tests.el        |  46 ++++
 test/lisp/net/sasl-tests.el             |  59 +++++
 test/lisp/net/tramp-tests.el            |   8 +-
 test/lisp/progmodes/asm-mode-tests.el   |  10 +
 test/lisp/progmodes/elisp-mode-tests.el |  11 +-
 test/manual/indent/shell.sh             |   7 +
 180 files changed, 2222 insertions(+), 1248 deletions(-)

diff --git a/admin/notes/unicode b/admin/notes/unicode
index 45455d8..bcede9c 100644
--- a/admin/notes/unicode
+++ b/admin/notes/unicode
@@ -256,15 +256,6 @@ nontrivial changes to the build process.
 
        etc/tutorials/TUTORIAL.ja
 
- * iso-2022-7bit
-
-     This file contains multiple Chinese charsets, and converting it
-     to UTF-8 would lose the charset property and would change the
-     code's behavior.  Although this could be worked around by
-     propertizing the strings, that hasn't been done.
-
-       lisp/international/titdic-cnv.el
-
  * utf-8-emacs
 
      These files contain characters that cannot be encoded in UTF-8.
@@ -276,6 +267,7 @@ nontrivial changes to the build process.
        lisp/language/tibetan.el
        lisp/leim/quail/ethiopic.el
        lisp/leim/quail/tibetan.el
+       lisp/international/titdic-cnv.el
 
  * binary files
 
diff --git a/admin/unidata/unidata-gen.el b/admin/unidata/unidata-gen.el
index 3918853..221c9b1 100644
--- a/admin/unidata/unidata-gen.el
+++ b/admin/unidata/unidata-gen.el
@@ -1416,7 +1416,8 @@ Property value is a symbol `o' (Open), `c' (Close), or 
`n' (None)."
       (or elt (user-error "Unknown output file: %s" basename))
       (or noninteractive (message "Generating %s..." file))
       (with-temp-file file
-        (insert ";; " copyright "
+        (insert ";;; " basename "  -*- lexical-binding:t -*-
+;; " copyright "
 ;; Generated from Unicode data files by unidata-gen.el.
 ;; The sources for this file are found in the admin/unidata/ directory in
 ;; the Emacs sources.  The Unicode data files are used under the
@@ -1451,7 +1452,8 @@ Property value is a symbol `o' (Open), `c' (Close), or 
`n' (None)."
 (defun unidata-gen-charprop (&optional charprop-file)
   (or charprop-file (setq charprop-file (pop command-line-args-left)))
   (with-temp-file charprop-file
-    (insert ";; Automatically generated by unidata-gen.el.\n"
+    (insert ";; Automatically generated by unidata-gen.el."
+            "  -*- lexical-binding: t -*-\n"
             ";; See the admin/unidata/ directory in the Emacs sources.\n")
     (dolist (elt unidata-file-alist)
       (dolist (proplist (cdr elt))
diff --git a/doc/emacs/glossary.texi b/doc/emacs/glossary.texi
index 35df065..4f971eb 100644
--- a/doc/emacs/glossary.texi
+++ b/doc/emacs/glossary.texi
@@ -1369,10 +1369,14 @@ configurations.  @xref{Tab Bars}.
 The tab line is a line of tabs at the top of an Emacs window.
 Clicking on one of these tabs switches window buffers.  @xref{Tab Line}.
 
+@item Tag
+A tag is an identifier in a program source.  @xref{Xref}.
+
 @anchor{Glossary---Tags Table}
 @item Tags Table
-A tags table is a file that serves as an index to the function
-definitions in one or more other files.  @xref{Tags Tables}.
+A tags table is a file that serves as an index to identifiers: definitions
+of functions, macros, data structures, etc., in one or more other files.
+@xref{Tags Tables}.
 
 @item Termscript File
 A termscript file contains a record of all characters sent by Emacs to
diff --git a/doc/emacs/kmacro.texi b/doc/emacs/kmacro.texi
index adb2ab8..e713c6e 100644
--- a/doc/emacs/kmacro.texi
+++ b/doc/emacs/kmacro.texi
@@ -179,6 +179,14 @@ itself counts as the first repetition, since it is 
executed as you
 define it, so @kbd{C-u 4 C-x )} executes the macro immediately 3
 additional times.
 
+@findex kdb-macro-redisplay
+@kindex C-x C-k Q
+  While executing a long-running keyboard macro, it can sometimes be
+useful to trigger a redisplay (to show how far we've gotten).  The
+@kbd{C-x C-k Q} can be used for this.  As a not very useful example,
+@kbd{C-x ( M-f C-x C-k Q C-x )} will create a macro that will
+redisplay once per iteration when saying @kbd{C-u 42 C-x e}.
+
 @node Keyboard Macro Ring
 @section The Keyboard Macro Ring
 
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 4158154..bc276c4 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -1994,19 +1994,21 @@ Of course, you should substitute the proper years and 
copyright holder.
 @section Find Identifier References
 @cindex xref
 
+@cindex tag
   An @dfn{identifier} is a name of a syntactical subunit of the
 program: a function, a subroutine, a method, a class, a data type, a
 macro, etc.  In a programming language, each identifier is a symbol in
-the language's syntax.  Program development and maintenance requires
-capabilities to quickly find where each identifier was defined and
-referenced, to rename identifiers across the entire project, etc.
-
-These capabilities are also useful for finding references in major
-modes other than those defined to support programming languages.  For
-example, chapters, sections, appendices, etc.@: of a text or a @TeX{}
-document can be treated as subunits as well, and their names can be
-used as identifiers.  In this chapter, we use the term ``identifiers''
-to collectively refer to the names of any kind of subunits, in program
+the language's syntax.  Identifiers are also known as @dfn{tags}.
+
+Program development and maintenance requires capabilities to quickly
+find where each identifier was defined and referenced, to rename
+identifiers across the entire project, etc.  These capabilities are
+also useful for finding references in major modes other than those
+defined to support programming languages.  For example, chapters,
+sections, appendices, etc.@: of a text or a @TeX{} document can be
+treated as subunits as well, and their names can be used as
+identifiers.  In this chapter, we use the term ``identifiers'' to
+collectively refer to the names of any kind of subunits, in program
 source and in other kinds of text alike.
 
 Emacs provides a unified interface to these capabilities, called
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 7f2a6f7..a15511d 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -694,9 +694,17 @@ parameter (@pxref{Management Parameters}).
 
 @item Internal Border
 The internal border is a border drawn by Emacs around the inner frame
-(see below).  Its width is specified by the @code{internal-border-width}
-frame parameter (@pxref{Layout Parameters}).  Its color is specified by
-the background of the @code{internal-border} face.
+(see below).  The specification of its appearance depends on whether
+or not the given frame is a child frame (@pxref{Child Frames}).
+
+For normal frames its width is specified by the @code{internal-border-width}
+frame parameter (@pxref{Layout Parameters}), and its color is specified by the
+background of the @code{internal-border} face.
+
+For child frames its width is specified by the @code{child-frame-border-width}
+frame parameter (but will use the @code{internal-border-width} parameter as
+fallback), and its color is specified by the background of the
+@code{child-frame-border} face.
 
 @item Inner Frame
 @cindex inner frame
@@ -1790,6 +1798,11 @@ The width in pixels of the frame's outer border 
(@pxref{Frame Geometry}).
 The width in pixels of the frame's internal border (@pxref{Frame
 Geometry}).
 
+@vindex child-frame-border-width@r{, a frame parameter}
+@item child-frame-border-width
+The width in pixels of the frame's internal border (@pxref{Frame
+Geometry}) if the given frame is a child frame (@pxref{Child Frames}).
+
 @vindex vertical-scroll-bars@r{, a frame parameter}
 @item vertical-scroll-bars
 Whether the frame has scroll bars (@pxref{Scroll Bars}) for vertical
@@ -2398,7 +2411,7 @@ attribute of the @code{default} face.
 
 @vindex foreground-color@r{, a frame parameter}
 @item foreground-color
-The color to use for the image of a character.  It is equivalent to
+The color to use for characters.  It is equivalent to
 the @code{:foreground} attribute of the @code{default} face.
 
 @vindex background-color@r{, a frame parameter}
@@ -3748,10 +3761,31 @@ for instance using the window manager, then this 
produces a quit and
   You can specify the mouse pointer style for particular text or
 images using the @code{pointer} text property, and for images with the
 @code{:pointer} and @code{:map} image properties.  The values you can
-use in these properties are @code{text} (or @code{nil}), @code{arrow},
-@code{hand}, @code{vdrag}, @code{hdrag}, @code{modeline}, and
-@code{hourglass}.  @code{text} stands for the usual mouse pointer
-style used over text.
+use in these properties are in the table below.  The actual shapes
+may vary between systems; the descriptions are examples.
+
+@table @code
+@item text
+@itemx nil
+The usual mouse pointer style used over text (an ``I''-like shape).
+
+@item arrow
+@itemx vdrag
+@itemx modeline
+An arrow that points north-west.
+
+@item hand
+A hand that points upwards.
+
+@item hdrag
+A right-left arrow.
+
+@item nhdrag
+An up-down arrow.
+
+@item hourglass
+A rotating ring.
+@end table
 
   Over void parts of the window (parts that do not correspond to any
 of the buffer contents), the mouse pointer usually uses the
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 14854a5..b367346 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -1441,6 +1441,11 @@ the @code{amalgamating-undo-limit} variable.  If this 
variable is 1,
 no changes are amalgamated.
 @end defun
 
+A Lisp program can amalgamate a series of changes into a single change
+group by calling @code{undo-amalgamate-change-group} (@pxref{Atomic
+Changes}).  Note that @code{amalgamating-undo-limit} has no effect on
+the groups produced by that function.
+
 @defvar undo-auto-current-boundary-timer
 Some buffers, such as process buffers, can change even when no
 commands are executing.  In these cases, @code{undo-boundary} is
@@ -5629,9 +5634,17 @@ This function cancels and undoes all the changes in the 
change group
 specified by @var{handle}.
 @end defun
 
+  You can cause some or all of the changes in a change group to be
+considered as a single unit for the purposes of the @code{undo}
+commands (@pxref{Undo}) by using @code{undo-amalgamate-change-group}.
+
 @defun undo-amalgamate-change-group
-Amalgamate changes in change-group since @var{handle}.  I.e., remove
-all undo boundaries between the state of @var{handle} and now.
+Amalgamate all the changes made in the change-group since the state
+identified by @var{handle}.  This function removes all undo boundaries
+between undo records of changes since the state described by
+@var{handle}.  Usually, @var{handle} is the handle returned by
+@code{prepare-change-group}, in which case all the changes since the
+beginning of the change-group are amalgamated into a single undo unit.
 @end defun
 
   Your code should use @code{unwind-protect} to make sure the group is
diff --git a/doc/misc/org.texi b/doc/misc/org.texi
index 5eeb098..8902d62 100644
--- a/doc/misc/org.texi
+++ b/doc/misc/org.texi
@@ -4071,7 +4071,7 @@ the link.  Such a function will be called with the tag as 
the only
 argument.
 
 With the above setting, you could link to a specific bug with
-@samp{[[bugzilla:129]]}, search the web for @samp{OrgMode} with 
@samp{[[google:OrgMode]]},
+@samp{[[bugzilla:129]]}, search the web for @samp{OrgMode} with 
@samp{[[duckduckgo:OrgMode]]},
 show the map location of the Free Software Foundation @samp{[[gmap:51
 Franklin Street, Boston]]} or of Carsten office @samp{[[omap:Science Park 904,
 Amsterdam, The Netherlands]]} and find out what the Org author is doing
@@ -4082,8 +4082,8 @@ can define them in the file with
 
 @cindex @samp{LINK}, keyword
 @example
-#+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
-#+LINK: google    http://www.google.com/search?q=%s
+#+LINK: bugzilla   http://10.1.2.9/bugzilla/show_bug.cgi?id=
+#+LINK: duckduckgo https://duckduckgo.com/?q=%s
 @end example
 
 In-buffer completion (see @ref{Completion}) can be used after @samp{[} to
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 5d89b06..efe8395 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -1286,6 +1286,9 @@ This method uses @command{sftp} in order to securely 
access remote
 hosts.  @command{sftp} is a more secure option for connecting to hosts
 that for security reasons refuse @command{ssh} connections.
 
+When there is a respective entry in your @command{ssh} configuration,
+do @emph{not} set the @option{RemoteCommand} option.
+
 @end table
 
 @defopt tramp-gvfs-methods
diff --git a/etc/NEWS b/etc/NEWS
index 6b1cdaa..9408642 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -504,6 +504,12 @@ time zones will use a form like "+0100" instead of "CET".
 
 ** Dired
 
+---
+*** Behaviour change on 'dired-clean-confirm-killing-deleted-buffers'.
+Previously, if 'dired-clean-up-buffers-too' was non-nil, and
+'dired-clean-confirm-killing-deleted-buffers' was nil, the buffers
+wouldn't be killed.  This combination will now kill the buffers.
+
 +++
 *** New user option 'dired-switches-in-mode-line'.
 This user option controls how 'ls' switches are displayed in the mode
@@ -1102,6 +1108,11 @@ If present in 'whitespace-style' (as it is by default), 
the final
 character in the buffer will be highlighted if the buffer doesn't end
 with a newline.
 
+---
+*** The default 'whitespace-enable-predicate' predicate has changed.
+It used to check elements in the list version of
+'whitespace-global-modes' with 'eq', but now uses 'derived-mode-p'.
+
 ** Texinfo
 
 ---
@@ -1131,6 +1142,11 @@ bindings, will be aborted, and Emacs will not ask you 
whether to
 enlarge 'max-specpdl-size' to complete the rendering.  The default is
 t, which preserves the original behavior.
 
+---
+*** New user option 'rmail-show-message-set-modified'.
+If set non-nil, showing an unseen message will set the Rmail buffer's
+modified flag.
+
 ** Apropos
 
 *** New commands 'apropos-next-symbol' and 'apropos-previous-symbol'.
@@ -1576,6 +1592,9 @@ This allows mode-specific alterations to how 
`thing-at-point' works.
 
 ** Miscellaneous
 
++++
+*** New command `C-x C-k Q' to force redisplay in keyboard macros.
+
 ---
 *** New user option 'remember-diary-regexp'.
 
@@ -2022,6 +2041,14 @@ hooks 'kill-buffer-hook', 'kill-buffer-query-functions', 
and
 'buffer-list-update-hook' for the temporary buffers they create.  This
 avoids slowing them down when a lot of these hooks are defined.
 
+** New face 'child-frame-border' and frame parameter 
'child-frame-border-width'.
+The face and width of child frames borders can now be determined
+separately from those of normal frames.  To minimize backward
+incompatibility, child frames without a 'child-frame-border-width'
+parameter will fall back to using 'internal-border-width'.  However,
+the new 'child-frame-border' face does constitute a breaking change
+since child frames' borders no longer use the 'internal-border' face.
+
 ---
 ** The obsolete function 'thread-alive-p' has been removed.
 
@@ -2137,6 +2164,8 @@ obsolete back in Emacs-23.1.  The affected functions are:
 make-obsolete, define-obsolete-function-alias, make-obsolete-variable,
 define-obsolete-variable-alias.
 
+** The variable 'keyboard-type' is obsolete and not dynamically scoped any more
+
 
 * Lisp Changes in Emacs 28.1
 
diff --git a/leim/leim-ext.el b/leim/leim-ext.el
index 2378f6f..687379d 100644
--- a/leim/leim-ext.el
+++ b/leim/leim-ext.el
@@ -1,4 +1,4 @@
-;; leim-ext.el -- extra leim configuration     -*- coding:utf-8; -*-
+;; leim-ext.el -- extra leim configuration     -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2004-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
@@ -39,13 +39,13 @@
 (eval-after-load "quail/Punct-b5"
   '(quail-defrule " " ?  nil t))
 
-(register-input-method "ucs" "UTF-8" 'ucs-input-activate "U+"
+(register-input-method "ucs" "UTF-8" #'ucs-input-activate "U+"
                       "Unicode input as hex in the form Uxxxx.")
 
 (register-input-method
  "korean-hangul"
  "UTF-8"
- 'hangul-input-method-activate
+ #'hangul-input-method-activate
  "한2"
  "Hangul 2-Bulsik Input"
  'hangul2-input-method
@@ -54,7 +54,7 @@
 (register-input-method
  "korean-hangul3f"
  "UTF-8"
- 'hangul-input-method-activate
+ #'hangul-input-method-activate
  "한3f"
  "Hangul 3-Bulsik final Input"
  'hangul3-input-method
@@ -63,7 +63,7 @@
 (register-input-method
  "korean-hangul390"
  "UTF-8"
- 'hangul-input-method-activate
+ #'hangul-input-method-activate
  "한390"
  "Hangul 3-Bulsik 390 Input"
  'hangul390-input-method
@@ -72,7 +72,7 @@
 (register-input-method
  "korean-hangul3"
  "UTF-8"
- 'hangul-input-method-activate
+ #'hangul-input-method-activate
  "한390"
  "Hangul 3-Bulsik 390 Input"
  'hangul390-input-method
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index ad3b690..2494040 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -588,7 +588,7 @@ Here's an example:
 \(let ((auth-source-creation-defaults \\='((user . \"defaultUser\")
                                         (A    . \"default A\")))
        (auth-source-creation-prompts
-        \\='((password . \"Enter IMAP password for %h:%p: \"))))
+        \\='((secret . \"Enter IMAP password for %h:%p: \"))))
   (auth-source-search :host \\='(\"nonesuch\" \"twosuch\") :type \\='netrc 
:max 1
                       :P \"pppp\" :Q \"qqqq\"
                       :create \\='(A B Q)))
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 1b2d689..57258f9 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -355,10 +355,9 @@ the list of old buffers.")
 (add-hook 'after-set-visited-file-name-hook
           #'auto-revert-set-visited-file-name)
 
-(defvar auto-revert--buffers-by-watch-descriptor
-  (make-hash-table :test 'equal)
-  "A hash table mapping notification descriptors to lists of buffers.
-The buffers use that descriptor for auto-revert notifications.
+(defvar auto-revert--buffer-by-watch-descriptor nil
+  "An association list mapping notification descriptors to buffers.
+The buffer uses that descriptor for auto-revert notifications.
 The key is equal to `auto-revert-notify-watch-descriptor' in each
 buffer.")
 
@@ -630,16 +629,12 @@ will use an up-to-date value of `auto-revert-interval'."
 
 (defun auto-revert-notify-rm-watch ()
   "Disable file notification for current buffer's associated file."
-  (let ((desc auto-revert-notify-watch-descriptor)
-        (table auto-revert--buffers-by-watch-descriptor))
-    (when desc
-      (let ((buffers (delq (current-buffer) (gethash desc table))))
-        (if buffers
-            (puthash desc buffers table)
-          (remhash desc table)))
-      (ignore-errors
-       (file-notify-rm-watch desc))
-      (remove-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch t)))
+  (when-let ((desc auto-revert-notify-watch-descriptor))
+    (setq auto-revert--buffer-by-watch-descriptor
+          (assoc-delete-all desc auto-revert--buffer-by-watch-descriptor))
+    (ignore-errors
+      (file-notify-rm-watch desc))
+    (remove-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch t))
   (setq auto-revert-notify-watch-descriptor nil
        auto-revert-notify-modified-p nil))
 
@@ -660,13 +655,10 @@ will use an up-to-date value of `auto-revert-interval'."
                (if buffer-file-name '(change attribute-change) '(change))
                'auto-revert-notify-handler))))
       (when auto-revert-notify-watch-descriptor
-        (setq auto-revert-notify-modified-p t)
-        (puthash
-         auto-revert-notify-watch-descriptor
-         (cons (current-buffer)
-              (gethash auto-revert-notify-watch-descriptor
-                       auto-revert--buffers-by-watch-descriptor))
-         auto-revert--buffers-by-watch-descriptor)
+        (setq auto-revert-notify-modified-p t
+              auto-revert--buffer-by-watch-descriptor
+              (cons (cons auto-revert-notify-watch-descriptor (current-buffer))
+                    auto-revert--buffer-by-watch-descriptor))
         (add-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch nil t))))
 
 ;; If we have file notifications, we want to update the auto-revert buffers
@@ -696,8 +688,8 @@ system.")
           (action (nth 1 event))
           (file (nth 2 event))
           (file1 (nth 3 event)) ;; Target of `renamed'.
-          (buffers (gethash descriptor
-                            auto-revert--buffers-by-watch-descriptor)))
+          (buffer (alist-get descriptor auto-revert--buffer-by-watch-descriptor
+                              nil nil #'equal)))
       ;; Check, that event is meant for us.
       (cl-assert descriptor)
       ;; Since we watch a directory, a file name must be returned.
@@ -706,9 +698,9 @@ system.")
       (when auto-revert-debug
         (message "auto-revert-notify-handler %S" event))
 
-      (if (eq action 'stopped)
-          ;; File notification has stopped.  Continue with polling.
-          (cl-dolist (buffer buffers)
+      (when (buffer-live-p buffer)
+        (if (eq action 'stopped)
+            ;; File notification has stopped.  Continue with polling.
             (with-current-buffer buffer
               (when (or
                      ;; A buffer associated with a file.
@@ -721,38 +713,35 @@ system.")
                 (auto-revert-notify-rm-watch)
                 ;; Restart the timer if it wasn't running.
                 (unless auto-revert-timer
-                  (auto-revert-set-timer)))))
-
-        ;; Loop over all buffers, in order to find the intended one.
-        (cl-dolist (buffer buffers)
-          (when (buffer-live-p buffer)
-            (with-current-buffer buffer
-              (when (or
-                     ;; A buffer associated with a file.
-                     (and (stringp buffer-file-name)
-                          (or
-                           (and (memq
-                                 action '(attribute-changed changed created))
-                                (string-equal
-                                 (file-name-nondirectory file)
-                                 (file-name-nondirectory buffer-file-name)))
-                           (and (eq action 'renamed)
-                                (string-equal
-                                 (file-name-nondirectory file1)
-                                 (file-name-nondirectory buffer-file-name)))))
-                     ;; A buffer w/o a file, like dired.
-                     (and (null buffer-file-name)
-                          (memq action '(created renamed deleted))))
-                ;; Mark buffer modified.
-                (setq auto-revert-notify-modified-p t)
-
-                ;; Revert the buffer now if we're not locked out.
-                (unless auto-revert--lockout-timer
-                  (auto-revert-handler)
-                  (setq auto-revert--lockout-timer
-                        (run-with-timer
-                         auto-revert--lockout-interval nil
-                         #'auto-revert--end-lockout buffer)))))))))))
+                  (auto-revert-set-timer))))
+
+          (with-current-buffer buffer
+            (when (or
+                   ;; A buffer associated with a file.
+                   (and (stringp buffer-file-name)
+                        (or
+                         (and (memq
+                               action '(attribute-changed changed created))
+                              (string-equal
+                               (file-name-nondirectory file)
+                               (file-name-nondirectory buffer-file-name)))
+                         (and (eq action 'renamed)
+                              (string-equal
+                               (file-name-nondirectory file1)
+                               (file-name-nondirectory buffer-file-name)))))
+                   ;; A buffer w/o a file, like dired.
+                   (and (null buffer-file-name)
+                        (memq action '(created renamed deleted))))
+              ;; Mark buffer modified.
+              (setq auto-revert-notify-modified-p t)
+
+              ;; Revert the buffer now if we're not locked out.
+              (unless auto-revert--lockout-timer
+                (auto-revert-handler)
+                (setq auto-revert--lockout-timer
+                      (run-with-timer
+                       auto-revert--lockout-interval nil
+                       #'auto-revert--end-lockout buffer))))))))))
 
 (defun auto-revert--end-lockout (buffer)
   "End the lockout period after a notification.
diff --git a/lisp/calc/calc-graph.el b/lisp/calc/calc-graph.el
index 4785fb7..423d1e6 100644
--- a/lisp/calc/calc-graph.el
+++ b/lisp/calc/calc-graph.el
@@ -1136,11 +1136,11 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
                       (if penbl "linespoints" "lines")
                     (if penbl "points" "dots"))))
         (if (and pstyle (> pstyle 0))
-            (insert " "
+            (insert " ls "
                     (if (and lstyle (> lstyle 0)) (int-to-string lstyle) "1")
-                    " " (int-to-string pstyle))
+                    " ps " (int-to-string pstyle))
           (if (and lstyle (> lstyle 0))
-              (insert " " (int-to-string lstyle)))))))
+              (insert " ls " (int-to-string lstyle)))))))
   (calc-graph-view-commands))
 
 (defun calc-graph-zero-x (flag)
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index c765e4b..ec864d5 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1179,7 +1179,7 @@ archive to which you want to compress, and CMD is the
 corresponding command.
 
 Within CMD, %i denotes the input file(s), and %o denotes the
-output file. %i path(s) are relative, while %o is absolute.")
+output file.  %i path(s) are relative, while %o is absolute.")
 
 ;;;###autoload
 (defun dired-do-compress-to ()
diff --git a/lisp/dired.el b/lisp/dired.el
index 3f11936..fe6ac1e 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3532,18 +3532,21 @@ confirmation.  To disable the confirmation, see
   (when (and (featurep 'dired-x) dired-clean-up-buffers-too)
     (let ((buf (get-file-buffer fn)))
       (and buf
-           (and dired-clean-confirm-killing-deleted-buffers
-                (funcall #'y-or-n-p
-                         (format "Kill buffer of %s, too? "
-                                 (file-name-nondirectory fn))))
+           (or (and dired-clean-confirm-killing-deleted-buffers
+                    (funcall #'y-or-n-p
+                             (format "Kill buffer of %s, too? "
+                                     (file-name-nondirectory fn))))
+               (not dired-clean-confirm-killing-deleted-buffers))
            (kill-buffer buf)))
     (let ((buf-list (dired-buffers-for-dir (expand-file-name fn))))
       (and buf-list
-           (and dired-clean-confirm-killing-deleted-buffers
-                (y-or-n-p (format (ngettext "Kill Dired buffer of %s, too? "
-                                           "Kill Dired buffers of %s, too? "
-                                           (length buf-list))
-                                  (file-name-nondirectory fn))))
+           (or (and dired-clean-confirm-killing-deleted-buffers
+                    (y-or-n-p (format
+                               (ngettext "Kill Dired buffer of %s, too? "
+                                         "Kill Dired buffers of %s, too? "
+                                         (length buf-list))
+                               (file-name-nondirectory fn))))
+               (not dired-clean-confirm-killing-deleted-buffers))
            (dolist (buf buf-list)
              (kill-buffer buf))))))
 
diff --git a/lisp/emacs-lisp/bindat.el b/lisp/emacs-lisp/bindat.el
index 5f432b8..0d9ba57 100644
--- a/lisp/emacs-lisp/bindat.el
+++ b/lisp/emacs-lisp/bindat.el
@@ -1,4 +1,4 @@
-;;; bindat.el --- binary data structure packing and unpacking.
+;;; bindat.el --- binary data structure packing and unpacking.  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 2002-2021 Free Software Foundation, Inc.
 
@@ -198,7 +198,7 @@
 
 (defun bindat--unpack-u8 ()
   (prog1
-    (aref bindat-raw bindat-idx)
+      (aref bindat-raw bindat-idx)
     (setq bindat-idx (1+ bindat-idx))))
 
 (defun bindat--unpack-u16 ()
@@ -276,6 +276,8 @@
    (t nil)))
 
 (defun bindat--unpack-group (spec)
+  (with-suppressed-warnings ((lexical last))
+    (defvar last))
   (let (struct last)
     (while spec
       (let* ((item (car spec))
@@ -287,11 +289,11 @@
             data)
        (setq spec (cdr spec))
        (if (and (consp field) (eq (car field) 'eval))
-           (setq field (eval (car (cdr field)))))
+           (setq field (eval (car (cdr field)) t)))
        (if (and type (consp type) (eq (car type) 'eval))
-           (setq type (eval (car (cdr type)))))
+           (setq type (eval (car (cdr type)) t)))
        (if (and len (consp len) (eq (car len) 'eval))
-           (setq len (eval (car (cdr len)))))
+           (setq len (eval (car (cdr len)) t)))
        (if (memq field '(eval fill align struct union))
            (setq tail 2
                  len type
@@ -304,48 +306,51 @@
        (cond
         ((eq type 'eval)
          (if field
-             (setq data (eval len))
-           (eval len)))
+             (setq data (eval len t))
+           (eval len t)))
         ((eq type 'fill)
          (setq bindat-idx (+ bindat-idx len)))
         ((eq type 'align)
          (while (/= (% bindat-idx len) 0)
            (setq bindat-idx (1+ bindat-idx))))
         ((eq type 'struct)
-         (setq data (bindat--unpack-group (eval len))))
+         (setq data (bindat--unpack-group (eval len t))))
         ((eq type 'repeat)
          (let ((index 0) (count len))
            (while (< index count)
-             (setq data (cons (bindat--unpack-group (nthcdr tail item)) data))
+             (push (bindat--unpack-group (nthcdr tail item)) data)
              (setq index (1+ index)))
            (setq data (nreverse data))))
         ((eq type 'union)
+         (with-suppressed-warnings ((lexical tag))
+           (defvar tag))
          (let ((tag len) (cases (nthcdr tail item)) case cc)
            (while cases
              (setq case (car cases)
                    cases (cdr cases)
                    cc (car case))
              (if (or (equal cc tag) (equal cc t)
-                     (and (consp cc) (eval cc)))
+                     (and (consp cc) (eval cc t)))
                  (setq data (bindat--unpack-group (cdr case))
                        cases nil)))))
         (t
          (setq data (bindat--unpack-item type len vectype)
                last data)))
        (if data
-           (if field
-               (setq struct (cons (cons field data) struct))
-             (setq struct (append data struct))))))
+           (setq struct (if field
+                            (cons (cons field data) struct)
+                          (append data struct))))))
     struct))
 
-(defun bindat-unpack (spec bindat-raw &optional bindat-idx)
-  "Return structured data according to SPEC for binary data in BINDAT-RAW.
-BINDAT-RAW is a unibyte string or vector.
-Optional third arg BINDAT-IDX specifies the starting offset in BINDAT-RAW."
-  (when (multibyte-string-p bindat-raw)
+(defun bindat-unpack (spec raw &optional idx)
+  "Return structured data according to SPEC for binary data in RAW.
+RAW is a unibyte string or vector.
+Optional third arg IDX specifies the starting offset in RAW."
+  (when (multibyte-string-p raw)
     (error "String is multibyte"))
-  (unless bindat-idx (setq bindat-idx 0))
-  (bindat--unpack-group spec))
+  (let ((bindat-idx (or idx 0))
+        (bindat-raw raw))
+    (bindat--unpack-group spec)))
 
 (defun bindat-get-field (struct &rest field)
   "In structured data STRUCT, return value of field named FIELD.
@@ -373,6 +378,8 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
     (ip . 4)))
 
 (defun bindat--length-group (struct spec)
+  (with-suppressed-warnings ((lexical last))
+    (defvar last))
   (let (last)
     (while spec
       (let* ((item (car spec))
@@ -383,32 +390,31 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
             (tail 3))
        (setq spec (cdr spec))
        (if (and (consp field) (eq (car field) 'eval))
-           (setq field (eval (car (cdr field)))))
+           (setq field (eval (car (cdr field)) t)))
        (if (and type (consp type) (eq (car type) 'eval))
-           (setq type (eval (car (cdr type)))))
+           (setq type (eval (car (cdr type)) t)))
        (if (and len (consp len) (eq (car len) 'eval))
-           (setq len (eval (car (cdr len)))))
+           (setq len (eval (car (cdr len)) t)))
        (if (memq field '(eval fill align struct union))
            (setq tail 2
                  len type
                  type field
                  field nil))
        (if (and (consp len) (not (eq type 'eval)))
-           (setq len (apply 'bindat-get-field struct len)))
+           (setq len (apply #'bindat-get-field struct len)))
        (if (not len)
            (setq len 1))
        (while (eq type 'vec)
-         (let ((vlen 1))
-           (if (consp vectype)
-               (setq len (* len (nth 1 vectype))
-                     type (nth 2 vectype))
-             (setq type (or vectype 'u8)
-                   vectype nil))))
+         (if (consp vectype)
+             (setq len (* len (nth 1 vectype))
+                   type (nth 2 vectype))
+           (setq type (or vectype 'u8)
+                 vectype nil)))
        (cond
         ((eq type 'eval)
          (if field
-             (setq struct (cons (cons field (eval len)) struct))
-           (eval len)))
+             (setq struct (cons (cons field (eval len t)) struct))
+           (eval len t)))
         ((eq type 'fill)
          (setq bindat-idx (+ bindat-idx len)))
         ((eq type 'align)
@@ -416,7 +422,7 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
            (setq bindat-idx (1+ bindat-idx))))
         ((eq type 'struct)
          (bindat--length-group
-          (if field (bindat-get-field struct field) struct) (eval len)))
+          (if field (bindat-get-field struct field) struct) (eval len t)))
         ((eq type 'repeat)
          (let ((index 0) (count len))
            (while (< index count)
@@ -425,13 +431,15 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
                (nthcdr tail item))
              (setq index (1+ index)))))
         ((eq type 'union)
+         (with-suppressed-warnings ((lexical tag))
+           (defvar tag))
          (let ((tag len) (cases (nthcdr tail item)) case cc)
            (while cases
              (setq case (car cases)
                    cases (cdr cases)
                    cc (car case))
              (if (or (equal cc tag) (equal cc t)
-                     (and (consp cc) (eval cc)))
+                     (and (consp cc) (eval cc t)))
                  (progn
                    (bindat--length-group struct (cdr case))
                    (setq cases nil))))))
@@ -536,6 +544,8 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
     (setq bindat-idx (+ bindat-idx len)))))
 
 (defun bindat--pack-group (struct spec)
+  (with-suppressed-warnings ((lexical last))
+    (defvar last))
   (let (last)
     (while spec
       (let* ((item (car spec))
@@ -546,11 +556,11 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
             (tail 3))
        (setq spec (cdr spec))
        (if (and (consp field) (eq (car field) 'eval))
-           (setq field (eval (car (cdr field)))))
+           (setq field (eval (car (cdr field)) t)))
        (if (and type (consp type) (eq (car type) 'eval))
-           (setq type (eval (car (cdr type)))))
+           (setq type (eval (car (cdr type)) t)))
        (if (and len (consp len) (eq (car len) 'eval))
-           (setq len (eval (car (cdr len)))))
+           (setq len (eval (car (cdr len)) t)))
        (if (memq field '(eval fill align struct union))
            (setq tail 2
                  len type
@@ -563,8 +573,8 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
        (cond
         ((eq type 'eval)
          (if field
-             (setq struct (cons (cons field (eval len)) struct))
-           (eval len)))
+             (setq struct (cons (cons field (eval len t)) struct))
+           (eval len t)))
         ((eq type 'fill)
          (setq bindat-idx (+ bindat-idx len)))
         ((eq type 'align)
@@ -572,7 +582,7 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
            (setq bindat-idx (1+ bindat-idx))))
         ((eq type 'struct)
          (bindat--pack-group
-          (if field (bindat-get-field struct field) struct) (eval len)))
+          (if field (bindat-get-field struct field) struct) (eval len t)))
         ((eq type 'repeat)
          (let ((index 0) (count len))
            (while (< index count)
@@ -581,13 +591,15 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
                (nthcdr tail item))
              (setq index (1+ index)))))
         ((eq type 'union)
+         (with-suppressed-warnings ((lexical tag))
+           (defvar tag))
          (let ((tag len) (cases (nthcdr tail item)) case cc)
            (while cases
              (setq case (car cases)
                    cases (cdr cases)
                    cc (car case))
              (if (or (equal cc tag) (equal cc t)
-                     (and (consp cc) (eval cc)))
+                     (and (consp cc) (eval cc t)))
                  (progn
                    (bindat--pack-group struct (cdr case))
                    (setq cases nil))))))
@@ -596,19 +608,19 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
          (bindat--pack-item last type len vectype)
          ))))))
 
-(defun bindat-pack (spec struct &optional bindat-raw bindat-idx)
+(defun bindat-pack (spec struct &optional raw idx)
   "Return binary data packed according to SPEC for structured data STRUCT.
-Optional third arg BINDAT-RAW is a pre-allocated unibyte string or vector to
+Optional third arg RAW is a pre-allocated unibyte string or vector to
 pack into.
-Optional fourth arg BINDAT-IDX is the starting offset into BINDAT-RAW."
-  (when (multibyte-string-p bindat-raw)
+Optional fourth arg IDX is the starting offset into RAW."
+  (when (multibyte-string-p raw)
     (error "Pre-allocated string is multibyte"))
-  (let ((no-return bindat-raw))
-    (unless bindat-idx (setq bindat-idx 0))
-    (unless bindat-raw
-      (setq bindat-raw (make-string (+ bindat-idx (bindat-length spec struct)) 
0)))
+  (let* ((bindat-idx (or idx 0))
+         (bindat-raw
+          (or raw
+              (make-string (+ bindat-idx (bindat-length spec struct)) 0))))
     (bindat--pack-group struct spec)
-    (if no-return nil bindat-raw)))
+    (if raw nil bindat-raw)))
 
 
 ;; Misc. format conversions
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 76638ec..9722792 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -2362,7 +2362,9 @@ Code:, and others referenced in the style guide."
                (checkdoc-create-error
                 (format "The footer should be: (provide '%s)\\n;;; %s%s ends 
here"
                         fn fn fe)
-                (1- (point-max)) (point-max)))))
+                 ;; The buffer may be empty.
+                (max (point-min) (1- (point-max)))
+                 (point-max)))))
        err))
       ;; The below checks will not return errors if the user says NO
 
diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el
index eb3193c..e106815 100644
--- a/lisp/emacs-lisp/crm.el
+++ b/lisp/emacs-lisp/crm.el
@@ -1,4 +1,4 @@
-;;; crm.el --- read multiple strings with completion
+;;; crm.el --- read multiple strings with completion  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 1985-1986, 1993-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/emacs-lisp/derived.el b/lisp/emacs-lisp/derived.el
index 4252842..54528b2 100644
--- a/lisp/emacs-lisp/derived.el
+++ b/lisp/emacs-lisp/derived.el
@@ -1,4 +1,4 @@
-;;; derived.el --- allow inheritance of major modes
+;;; derived.el --- allow inheritance of major modes  -*- lexical-binding: t; 
-*-
 ;; (formerly mode-clone.el)
 
 ;; Copyright (C) 1993-1994, 1999, 2001-2021 Free Software Foundation,
diff --git a/lisp/emacs-lisp/eieio-opt.el b/lisp/emacs-lisp/eieio-opt.el
index edf4d34..e65f424 100644
--- a/lisp/emacs-lisp/eieio-opt.el
+++ b/lisp/emacs-lisp/eieio-opt.el
@@ -1,4 +1,4 @@
-;;; eieio-opt.el -- eieio optional functions (debug, printing, speedbar)
+;;; eieio-opt.el -- eieio optional functions (debug, printing, speedbar)  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1996, 1998-2003, 2005, 2008-2021 Free Software
 ;; Foundation, Inc.
diff --git a/lisp/emacs-lisp/generic.el b/lisp/emacs-lisp/generic.el
index 93f780e..6db1bbb 100644
--- a/lisp/emacs-lisp/generic.el
+++ b/lisp/emacs-lisp/generic.el
@@ -1,4 +1,4 @@
-;;; generic.el --- defining simple major modes with comment and font-lock
+;;; generic.el --- defining simple major modes with comment and font-lock  -*- 
lexical-binding: t; -*-
 ;;
 ;; Copyright (C) 1997, 1999, 2001-2021 Free Software Foundation, Inc.
 ;;
@@ -245,7 +245,6 @@ Some generic modes are defined in `generic-x.el'."
   "Set up comment functionality for generic mode."
   (let ((chars nil)
        (comstyles)
-        (comstyle "")
         (comment-start nil))
 
     ;; Go through all the comments.
@@ -269,14 +268,16 @@ Some generic modes are defined in `generic-x.el'."
            ;; Store the relevant info but don't update yet.
            (push (cons c0 (concat (cdr (assoc c0 chars)) "1")) chars)
            (push (cons c1 (concat (cdr (assoc c1 chars))
-                                  (concat "2" comstyle))) chars)))
+                                  (concat "2" comstyle)))
+                 chars)))
        (if (= (length end) 1)
            (modify-syntax-entry (aref end 0)
                                 (concat ">" comstyle) st)
          (let ((c0 (aref end 0)) (c1 (aref end 1)))
            ;; Store the relevant info but don't update yet.
            (push (cons c0 (concat (cdr (assoc c0 chars))
-                                  (concat "3" comstyle))) chars)
+                                  (concat "3" comstyle)))
+                 chars)
            (push (cons c1 (concat (cdr (assoc c1 chars)) "4")) chars)))))
 
     ;; Process the chars that were part of a 2-char comment marker
diff --git a/lisp/emacs-lisp/helper.el b/lisp/emacs-lisp/helper.el
index 737f3ec..a5f21a5 100644
--- a/lisp/emacs-lisp/helper.el
+++ b/lisp/emacs-lisp/helper.el
@@ -1,4 +1,4 @@
-;;; helper.el --- utility help package supporting help in electric modes
+;;; helper.el --- utility help package supporting help in electric modes  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1985, 2001-2021 Free Software Foundation, Inc.
 
@@ -39,20 +39,19 @@
 ;; keymap either.
 
 
-(defvar Helper-help-map nil)
-(if Helper-help-map
-    nil
-  (setq Helper-help-map (make-keymap))
-  ;(fillarray Helper-help-map 'undefined)
-  (define-key Helper-help-map "m" 'Helper-describe-mode)
-  (define-key Helper-help-map "b" 'Helper-describe-bindings)
-  (define-key Helper-help-map "c" 'Helper-describe-key-briefly)
-  (define-key Helper-help-map "k" 'Helper-describe-key)
-  ;(define-key Helper-help-map "f" 'Helper-describe-function)
-  ;(define-key Helper-help-map "v" 'Helper-describe-variable)
-  (define-key Helper-help-map "?" 'Helper-help-options)
-  (define-key Helper-help-map (char-to-string help-char) 'Helper-help-options)
-  (fset 'Helper-help-map Helper-help-map))
+(defvar Helper-help-map
+  (let ((map (make-sparse-keymap)))
+  ;(fillarray map 'undefined)
+  (define-key map "m" 'Helper-describe-mode)
+  (define-key map "b" 'Helper-describe-bindings)
+  (define-key map "c" 'Helper-describe-key-briefly)
+  (define-key map "k" 'Helper-describe-key)
+  ;(define-key map "f" 'Helper-describe-function)
+  ;(define-key map "v" 'Helper-describe-variable)
+  (define-key map "?" 'Helper-help-options)
+  (define-key map (char-to-string help-char) 'Helper-help-options)
+  (fset 'Helper-help-map map)
+  map))
 
 (defun Helper-help-scroller ()
   (let ((blurb (or (and (boundp 'Helper-return-blurb)
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 8780c5d..3918fa0 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -201,41 +201,53 @@
 
 (defun lisp--el-non-funcall-position-p (pos)
   "Heuristically determine whether POS is an evaluated position."
+  (declare (obsolete lisp--el-funcall-position-p "28.1"))
+  (not (lisp--el-funcall-position-p pos)))
+
+(defun lisp--el-funcall-position-p (pos)
+  "Heuristically determine whether POS is an evaluated position."
   (save-match-data
     (save-excursion
       (ignore-errors
         (goto-char pos)
         ;; '(lambda ..) is not a funcall position, but #'(lambda ...) is.
-        (or (and (eql (char-before) ?\')
-                 (not (eql (char-before (1- (point))) ?#)))
-            (let* ((ppss (syntax-ppss))
-                   (paren-posns (nth 9 ppss))
-                   (parent
-                    (when paren-posns
-                      (goto-char (car (last paren-posns))) ;(up-list -1)
-                      (cond
-                       ((ignore-errors
-                          (and (eql (char-after) ?\()
-                               (when (cdr paren-posns)
-                                 (goto-char (car (last paren-posns 2)))
-                                 (looking-at "(\\_<let\\*?\\_>"))))
-                        (goto-char (match-end 0))
-                        'let)
-                       ((looking-at
-                         (rx "("
-                             (group-n 1 (+ (or (syntax w) (syntax _))))
-                             symbol-end))
-                        (prog1 (intern-soft (match-string-no-properties 1))
-                          (goto-char (match-end 1))))))))
-              (or (eq parent 'declare)
-                  (and (eq parent 'let)
-                       (progn
-                         (forward-sexp 1)
-                         (< pos (point))))
-                  (and (eq parent 'condition-case)
-                       (progn
-                         (forward-sexp 2)
-                         (< (point) pos))))))))))
+        (if (eql (char-before) ?\')
+            (eql (char-before (1- (point))) ?#)
+          (let* ((ppss (syntax-ppss))
+                 (paren-posns (nth 9 ppss))
+                 (parent
+                  (when paren-posns
+                    (goto-char (car (last paren-posns))) ;(up-list -1)
+                    (cond
+                     ((ignore-errors
+                        (and (eql (char-after) ?\()
+                             (when (cdr paren-posns)
+                               (goto-char (car (last paren-posns 2)))
+                               (looking-at "(\\_<let\\*?\\_>"))))
+                      (goto-char (match-end 0))
+                      'let)
+                     ((looking-at
+                       (rx "("
+                           (group-n 1 (+ (or (syntax w) (syntax _))))
+                           symbol-end))
+                      (prog1 (intern-soft (match-string-no-properties 1))
+                        (goto-char (match-end 1))))))))
+            (pcase parent
+              ('declare nil)
+              ('let
+                (forward-sexp 1)
+                (>= pos (point)))
+              ('condition-case
+                  ;; If (cdr paren-posns), then we're in the BODY
+                  ;; of HANDLERS.
+                  (or (cdr paren-posns)
+                      (progn
+                        (forward-sexp 1)
+                        ;; If we're in the second form, then we're in
+                        ;; a funcall position.
+                        (< (point) pos (progn (forward-sexp 1)
+                                              (point))))))
+              (_ t))))))))
 
 (defun lisp--el-match-keyword (limit)
   ;; FIXME: Move to elisp-mode.el.
@@ -245,11 +257,9 @@
               (concat "(\\(" lisp-mode-symbol-regexp "\\)\\_>"))
             limit t)
       (let ((sym (intern-soft (match-string 1))))
-       (when (or (special-form-p sym)
-                 (and (macrop sym)
-                       (not (get sym 'no-font-lock-keyword))
-                       (not (lisp--el-non-funcall-position-p
-                             (match-beginning 0)))))
+       (when (and (or (special-form-p sym) (macrop sym))
+                   (not (get sym 'no-font-lock-keyword))
+                   (lisp--el-funcall-position-p (match-beginning 0)))
          (throw 'found t))))))
 
 (defmacro let-when-compile (bindings &rest body)
@@ -765,6 +775,7 @@ or to switch back to an existing one."
   (setq-local find-tag-default-function 'lisp-find-tag-default)
   (setq-local comment-start-skip
              "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
+  (setq-local comment-end "|#")
   (setq imenu-case-fold-search t))
 
 (defun lisp-find-tag-default ()
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index aa49bcc..e842222 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -241,9 +241,22 @@ Assumes the caller has bound 
`macroexpand-all-environment'."
                        form))
       (`(,(and fun `(lambda . ,_)) . ,args)
        ;; Embedded lambda in function position.
-       (macroexp--cons (macroexp--all-forms fun 2)
-                       (macroexp--all-forms args)
-                       form))
+       ;; If the byte-optimizer is loaded, try to unfold this,
+       ;; i.e. rewrite it to (let (<args>) <body>).  We'd do it in the 
optimizer
+       ;; anyway, but doing it here (i.e. earlier) can sometimes avoid the
+       ;; creation of a closure, thus resulting in much better code.
+       (let ((newform (if (not (fboundp 'byte-compile-unfold-lambda))
+                         'macroexp--not-unfolded
+                       ;; Don't unfold if byte-opt is not yet loaded.
+                       (byte-compile-unfold-lambda form))))
+        (if (or (eq newform 'macroexp--not-unfolded)
+                (eq newform form))
+            ;; Unfolding failed for some reason, avoid infinite recursion.
+            (macroexp--cons (macroexp--all-forms fun 2)
+                             (macroexp--all-forms args)
+                             form)
+          (macroexp--expand-all newform))))
+
       ;; The following few cases are for normal function calls that
       ;; are known to funcall one of their arguments.  The byte
       ;; compiler has traditionally handled these functions specially
@@ -257,17 +270,21 @@ Assumes the caller has bound 
`macroexpand-all-environment'."
        (macroexp--warn-and-return
         (format "%s quoted with ' rather than with #'"
                 (list 'lambda (nth 1 f) '...))
-        (macroexp--expand-all `(,fun ,f . ,args))))
+        (macroexp--expand-all `(,fun #',f . ,args))))
       ;; Second arg is a function:
       (`(,(and fun (or 'sort)) ,arg1 ',(and f `(lambda . ,_)) . ,args)
        (macroexp--warn-and-return
         (format "%s quoted with ' rather than with #'"
                 (list 'lambda (nth 1 f) '...))
-        (macroexp--expand-all `(,fun ,arg1 ,f . ,args))))
-      (`(funcall #',(and f (pred symbolp)) . ,args)
-       ;; Rewrite (funcall #'foo bar) to (foo bar), in case `foo'
-       ;; has a compiler-macro.
-       (macroexp--expand-all `(,f . ,args)))
+        (macroexp--expand-all `(,fun ,arg1 #',f . ,args))))
+      (`(funcall ,exp . ,args)
+       (let ((eexp (macroexp--expand-all exp))
+             (eargs (macroexp--all-forms args)))
+         ;; Rewrite (funcall #'foo bar) to (foo bar), in case `foo'
+         ;; has a compiler-macro, or to unfold it.
+         (pcase eexp
+           (`#',f (macroexp--expand-all `(,f . ,eargs)))
+           (_ `(funcall ,eexp . ,eargs)))))
       (`(,func . ,_)
        ;; Macro expand compiler macros.  This cannot be delayed to
        ;; byte-optimize-form because the output of the compiler-macro can
@@ -360,12 +377,12 @@ Never returns an empty list."
      (t
       `(cond (,test ,@(macroexp-unprogn then))
              (,(nth 1 else) ,@(macroexp-unprogn (nth 2 else)))
-             (t ,@(nthcdr 3 else))))))
+             ,@(let ((def (nthcdr 3 else))) (if def `((t ,@def))))))))
    ((eq (car-safe else) 'cond)
     `(cond (,test ,@(macroexp-unprogn then)) ,@(cdr else)))
    ;; Invert the test if that lets us reduce the depth of the tree.
    ((memq (car-safe then) '(if cond)) (macroexp-if `(not ,test) else then))
-   (t `(if ,test ,then ,@(macroexp-unprogn else)))))
+   (t `(if ,test ,then ,@(if else (macroexp-unprogn else))))))
 
 (defmacro macroexp-let2 (test sym exp &rest body)
   "Evaluate BODY with SYM bound to an expression for EXP's value.
diff --git a/lisp/emacs-lisp/package-x.el b/lisp/emacs-lisp/package-x.el
index 8a0853c..b723643 100644
--- a/lisp/emacs-lisp/package-x.el
+++ b/lisp/emacs-lisp/package-x.el
@@ -1,4 +1,4 @@
-;;; package-x.el --- Package extras
+;;; package-x.el --- Package extras  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2007-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index bfd577c..cf129c4 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -683,11 +683,6 @@ A and B can be one of:
                ;; and catch at least the easy cases such as (bug#14773).
                (not (macroexp--fgrep (mapcar #'car vars) (cadr upat)))))
       '(:pcase--succeed . :pcase--fail))
-     ;; In case UPAT is of the form (pred (not PRED))
-     ((and (eq 'pred (car upat)) (eq 'not (car-safe (cadr upat))))
-      (let* ((test (cadr (cadr upat)))
-             (res (pcase--split-pred vars `(pred ,test) pat)))
-        (cons (cdr res) (car res))))
      ;; In case PAT is of the form (pred (not PRED))
      ((and (eq 'pred (car-safe pat)) (eq 'not (car-safe (cadr pat))))
       (let* ((test (cadr (cadr pat)))
@@ -696,19 +691,34 @@ A and B can be one of:
                                    ((eq x :pcase--fail) :pcase--succeed)))))
         (cons (funcall reverse (car res))
               (funcall reverse (cdr res)))))
-     ((and (eq 'pred (car upat))
-           (let ((otherpred
-                  (cond ((eq 'pred (car-safe pat)) (cadr pat))
-                        ((not (eq 'quote (car-safe pat))) nil)
-                        ((consp (cadr pat)) #'consp)
-                        ((stringp (cadr pat)) #'stringp)
-                        ((vectorp (cadr pat)) #'vectorp)
-                        ((byte-code-function-p (cadr pat))
-                         #'byte-code-function-p))))
-             (pcase--mutually-exclusive-p (cadr upat) otherpred)))
+     ;; All the rest below presumes UPAT is of the form (pred ...).
+     ((not (eq 'pred (car upat))) nil)
+     ;; In case UPAT is of the form (pred (not PRED))
+     ((eq 'not (car-safe (cadr upat)))
+      (let* ((test (cadr (cadr upat)))
+             (res (pcase--split-pred vars `(pred ,test) pat)))
+        (cons (cdr res) (car res))))
+     ((let ((otherpred
+             (cond ((eq 'pred (car-safe pat)) (cadr pat))
+                   ((not (eq 'quote (car-safe pat))) nil)
+                   ((consp (cadr pat)) #'consp)
+                   ((stringp (cadr pat)) #'stringp)
+                   ((vectorp (cadr pat)) #'vectorp)
+                   ((byte-code-function-p (cadr pat))
+                    #'byte-code-function-p))))
+        (pcase--mutually-exclusive-p (cadr upat) otherpred))
       '(:pcase--fail . nil))
-     ((and (eq 'pred (car upat))
-           (eq 'quote (car-safe pat))
+     ;; Since we turn (or 'a 'b 'c) into (pred (pcase--flip (memq '(a b c))))
+     ;; try and preserve the info we get from that memq test.
+     ((and (eq 'pcase--flip (car-safe (cadr upat)))
+           (memq (cadr (cadr upat)) '(memq member memql))
+           (eq 'quote (car-safe (nth 2 (cadr upat))))
+           (eq 'quote (car-safe pat)))
+      (let ((set (cadr (nth 2 (cadr upat)))))
+        (if (member (cadr pat) set)
+            '(nil . :pcase--fail)
+          '(:pcase--fail . nil))))
+     ((and (eq 'quote (car-safe pat))
            (symbolp (cadr upat))
            (or (symbolp (cadr pat)) (stringp (cadr pat)) (numberp (cadr pat)))
            (get (cadr upat) 'side-effect-free)
diff --git a/lisp/emacs-lisp/regi.el b/lisp/emacs-lisp/regi.el
index 38b202f..527af1d 100644
--- a/lisp/emacs-lisp/regi.el
+++ b/lisp/emacs-lisp/regi.el
@@ -1,4 +1,4 @@
-;;; regi.el --- REGular expression Interpreting engine
+;;; regi.el --- REGular expression Interpreting engine  -*- lexical-binding: 
t; -*-
 
 ;; Copyright (C) 1993, 2001-2021 Free Software Foundation, Inc.
 
@@ -153,7 +153,7 @@ useful information:
        ;; set up the narrowed region
        (and start
             end
-            (let* ((tstart start)
+            (let* (;; (tstart start)
                    (start (min start end))
                    (end   (max start end)))
               (narrow-to-region
@@ -206,30 +206,33 @@ useful information:
              ;; if the line matched, package up the argument list and
              ;; funcall the FUNC
              (if match-p
-                  (let* ((curline (buffer-substring
-                                   (regi-pos 'bol)
-                                   (regi-pos 'eol)))
-                         (curframe current-frame)
-                         (curentry entry)
-                         (result (eval func))
-                         (step (or (cdr (assq 'step result)) 1))
-                         )
-                    ;; changing frame on the fly?
-                    (if (assq 'frame result)
-                        (setq working-frame (cdr (assq 'frame result))))
-
-                    ;; continue processing current frame?
-                    (if (memq 'continue result)
-                        (setq current-frame (cdr current-frame))
-                      (forward-line step)
-                      (setq current-frame working-frame))
-
-                    ;; abort current frame?
-                    (if (memq 'abort result)
-                        (progn
-                          (setq donep t)
-                          (throw 'regi-throw-top t)))
-                    ) ; end-let
+                 (with-suppressed-warnings
+                     ((lexical curframe curentry curline))
+                   (defvar curframe) (defvar curentry) (defvar curline)
+                   (let* ((curline (buffer-substring
+                                    (regi-pos 'bol)
+                                    (regi-pos 'eol)))
+                          (curframe current-frame)
+                          (curentry entry)
+                          (result (eval func))
+                          (step (or (cdr (assq 'step result)) 1))
+                          )
+                     ;; changing frame on the fly?
+                     (if (assq 'frame result)
+                         (setq working-frame (cdr (assq 'frame result))))
+
+                     ;; continue processing current frame?
+                     (if (memq 'continue result)
+                         (setq current-frame (cdr current-frame))
+                       (forward-line step)
+                       (setq current-frame working-frame))
+
+                     ;; abort current frame?
+                     (if (memq 'abort result)
+                         (progn
+                           (setq donep t)
+                           (throw 'regi-throw-top t)))
+                     ))                   ; end-let
 
                ;; else if no match occurred, then process the next
                ;; frame-entry on the current line
diff --git a/lisp/emacs-lisp/shadow.el b/lisp/emacs-lisp/shadow.el
index 168e5e4..c1d0594 100644
--- a/lisp/emacs-lisp/shadow.el
+++ b/lisp/emacs-lisp/shadow.el
@@ -1,4 +1,4 @@
-;;; shadow.el --- locate Emacs Lisp file shadowings
+;;; shadow.el --- locate Emacs Lisp file shadowings  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 1995, 2001-2021 Free Software Foundation, Inc.
 
@@ -58,8 +58,7 @@
 (defcustom load-path-shadows-compare-text nil
   "If non-nil, then shadowing files are reported only if their text differs.
 This is slower, but filters out some innocuous shadowing."
-  :type 'boolean
-  :group 'lisp-shadow)
+  :type 'boolean)
 
 (defun load-path-shadows-find (&optional path)
   "Return a list of Emacs Lisp files that create shadows.
@@ -78,8 +77,7 @@ See the documentation for `list-load-path-shadows' for 
further information."
         dir-case-insensitive            ; `file-name-case-insensitive-p' of 
dir.
        curr-files                      ; This dir's Emacs Lisp files.
        orig-dir                        ; Where the file was first seen.
-       files-seen-this-dir             ; Files seen so far in this dir.
-       file)                           ; The current file.
+       files-seen-this-dir)            ; Files seen so far in this dir.
     (dolist (pp (or path load-path))
       (setq dir (directory-file-name (file-truename (or pp "."))))
       (if (member dir true-names)
@@ -109,7 +107,7 @@ See the documentation for `list-load-path-shadows' for 
further information."
 
        (dolist (file curr-files)
 
-         (if (string-match "\\.gz$" file)
+         (if (string-match "\\.gz\\'" file)
              (setq file (substring file 0 -3)))
          (setq file (substring
                      file 0 (if (string= (substring file -1) "c") -4 -3)))
@@ -125,9 +123,13 @@ See the documentation for `list-load-path-shadows' for 
further information."
            ;; XXX.elc (or vice-versa) when they are in the same directory.
            (setq files-seen-this-dir (cons file files-seen-this-dir))
 
-            (if (setq orig-dir (assoc file files
-                                      (when dir-case-insensitive
-                                        (lambda (f1 f2) (eq (compare-strings 
f1 nil nil f2 nil nil t) t)))))
+            (if (setq orig-dir
+                      (assoc file files
+                             (when dir-case-insensitive
+                               (lambda (f1 f2)
+                                 (eq (compare-strings f1 nil nil
+                                                      f2 nil nil t)
+                                     t)))))
                ;; This file was seen before, we have a shadowing.
                ;; Report it unless the files are identical.
                 (let ((base1 (concat (cdr orig-dir) "/" (car orig-dir)))
@@ -142,7 +144,7 @@ See the documentation for `list-load-path-shadows' for 
further information."
                            (append shadows (list base1 base2)))))
 
              ;; Not seen before, add it to the list of seen files.
-             (setq files (cons (cons file dir) files)))))))
+             (push (cons file dir) files))))))
     ;; Return the list of shadowings.
     shadows))
 
diff --git a/lisp/emacs-lisp/tcover-ses.el b/lisp/emacs-lisp/tcover-ses.el
index 7de9d54..fb9cd8f 100644
--- a/lisp/emacs-lisp/tcover-ses.el
+++ b/lisp/emacs-lisp/tcover-ses.el
@@ -1,4 +1,4 @@
-;;;; testcover-ses.el -- Example use of `testcover' to test "SES"
+;;;; testcover-ses.el -- Example use of `testcover' to test "SES"  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 2002-2021 Free Software Foundation, Inc.
 
@@ -19,21 +19,14 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
 
-(require 'testcover)
+;;; Commentary:
 
-(defvar ses-initial-global-parameters)
-(defvar ses-mode-map)
+;; FIXME: Convert to ERT and move to `test/'?
 
-(declare-function ses-set-curcell "ses")
-(declare-function ses-update-cells "ses")
-(declare-function ses-load "ses")
-(declare-function ses-vector-delete "ses")
-(declare-function ses-create-header-string "ses")
-(declare-function ses-read-cell "ses")
-(declare-function ses-read-symbol "ses")
-(declare-function ses-command-hook "ses")
-(declare-function ses-jump "ses")
+;;; Code:
 
+(require 'testcover)
+(require 'ses)
 
 ;;;Here are some macros that exercise SES.  Set `pause' to t if you want the
 ;;;macros to pause after each step.
@@ -652,6 +645,7 @@ spreadsheet files with invalid formatting."
     (testcover-start "ses.el" t))
   (require 'unsafep)) ;In case user has safe-functions = t!
 
+(defvar ses--curcell-overlay)
 
 ;;;#########################################################################
 (defun ses-exercise ()
@@ -674,8 +668,8 @@ spreadsheet files with invalid formatting."
       (ses-load))
     ;;ses-vector-delete is always called from buffer-undo-list with the same
     ;;symbol as argument.  We'll give it a different one here.
-    (let ((x [1 2 3]))
-      (ses-vector-delete 'x 0 0))
+    (dlet ((tcover-ses--x [1 2 3]))
+      (ses-vector-delete 'tcover-ses--x 0 0))
     ;;ses-create-header-string behaves differently in a non-window environment
     ;;but we always test under windows.
     (let ((window-system (not window-system)))
@@ -704,7 +698,7 @@ spreadsheet files with invalid formatting."
          (ses-mode)))))
   ;;Test error-handling in command hook, outside a macro.
   ;;This will ring the bell.
-  (let (curcell-overlay)
+  (let (ses--curcell-overlay)
     (ses-command-hook))
   ;;Due to use of run-with-timer, ses-command-hook sometimes gets called
   ;;after we switch to another buffer.
@@ -720,4 +714,4 @@ spreadsheet files with invalid formatting."
   ;;Could do this here: (testcover-end "ses.el")
   (message "Done"))
 
-;; testcover-ses.el ends here.
+;;; testcover-ses.el ends here.
diff --git a/lisp/emacs-lisp/unsafep.el b/lisp/emacs-lisp/unsafep.el
index f46d9c7..d52a6c7 100644
--- a/lisp/emacs-lisp/unsafep.el
+++ b/lisp/emacs-lisp/unsafep.el
@@ -1,4 +1,4 @@
-;;;; unsafep.el -- Determine whether a Lisp form is safe to evaluate
+;;;; unsafep.el -- Determine whether a Lisp form is safe to evaluate  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 2002-2021 Free Software Foundation, Inc.
 
@@ -129,15 +129,16 @@ in the parse.")
   (put x 'safe-function t))
 
 ;;;###autoload
-(defun unsafep (form &optional unsafep-vars)
+(defun unsafep (form &optional vars)
   "Return nil if evaluating FORM couldn't possibly do any harm.
 Otherwise result is a reason why FORM is unsafe.
-UNSAFEP-VARS is a list of symbols with local bindings."
+VARS is a list of symbols with local bindings like `unsafep-vars'."
   (catch 'unsafep
     (if (or (eq safe-functions t)          ;User turned off safety-checking
            (atom form))                    ;Atoms are never unsafe
        (throw 'unsafep nil))
-    (let* ((fun    (car form))
+    (let* ((unsafep-vars vars)
+          (fun    (car form))
           (reason (unsafep-function fun))
           arg)
       (cond
diff --git a/lisp/ezimage.el b/lisp/ezimage.el
index 9c1d859..13f5c03 100644
--- a/lisp/ezimage.el
+++ b/lisp/ezimage.el
@@ -1,4 +1,4 @@
-;;; ezimage --- Generalized Image management
+;;; ezimage.el --- Generalized Image management  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 1999-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/faces.el b/lisp/faces.el
index d654b1f..90f11bb 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2683,11 +2683,20 @@ the same as `window-divider' face."
 
 (defface internal-border
     '((t nil))
-  "Basic face for the internal border."
+  "Basic face for the internal border.
+For the internal border of child frames see `child-frame-border'."
   :version "26.1"
   :group 'frames
   :group 'basic-faces)
 
+(defface child-frame-border
+  '((t nil))
+  "Basic face for the internal border of child frames.
+For the internal border of non-child frames see `internal-border'."
+  :version "28.1"
+  :group 'frames
+  :group 'basic-faces)
+
 (defface minibuffer-prompt
   '((((background dark)) :foreground "cyan")
     ;; Don't use blue because many users of the MS-DOS port customize
diff --git a/lisp/files.el b/lisp/files.el
index e9be7c7..5adbb43 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4073,7 +4073,7 @@ Return the new variables list."
                         ;; integer values for subdir, where N means
                         ;; variables apply to this directory and N levels
                         ;; below it (0 == nil).
-                        (equal root default-directory))
+                        (equal root (expand-file-name default-directory)))
                     (setq variables (dir-locals-collect-mode-variables
                                      alist variables))))))))
       (error
diff --git a/lisp/find-cmd.el b/lisp/find-cmd.el
index 5866b30..bb2e97d 100644
--- a/lisp/find-cmd.el
+++ b/lisp/find-cmd.el
@@ -1,4 +1,4 @@
-;;; find-cmd.el --- Build a valid find(1) command with sexps
+;;; find-cmd.el --- Build a valid find(1) command with sexps  -*- 
lexical-binding: t -*-
 
 ;; Copyright (C) 2008-2021 Free Software Foundation, Inc.
 
@@ -28,7 +28,7 @@
 ;; (find-cmd '(prune (name ".svn" ".git" ".CVS"))
 ;;           '(and (or (name "*.pl" "*.pm" "*.t")
 ;;                     (mtime "+1"))
-;;                 (fstype "nfs" "ufs"))))
+;;                 (fstype "nfs" "ufs")))
 
 ;; will become (un-wrapped):
 
diff --git a/lisp/flow-ctrl.el b/lisp/flow-ctrl.el
index 656edf2..adb52d7 100644
--- a/lisp/flow-ctrl.el
+++ b/lisp/flow-ctrl.el
@@ -1,4 +1,4 @@
-;;; flow-ctrl.el --- help for lusers on cu(1) or ttys with wired-in ^S/^Q flow 
control
+;;; flow-ctrl.el --- help for lusers on cu(1) or ttys with wired-in ^S/^Q flow 
control  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 1990-1991, 1994, 2001-2021 Free Software Foundation,
 ;; Inc.
@@ -64,12 +64,11 @@ With arg, enable flow control mode if arg is positive, 
otherwise disable."
       (progn
        ;; Turn flow control off, and stop exchanging chars.
        (set-input-mode t nil (nth 2 (current-input-mode)))
-       (if keyboard-translate-table
-           (progn
-             (aset keyboard-translate-table flow-control-c-s-replacement nil)
-             (aset keyboard-translate-table ?\^s nil)
-             (aset keyboard-translate-table flow-control-c-q-replacement nil)
-             (aset keyboard-translate-table ?\^q nil))))
+        (when keyboard-translate-table
+          (aset keyboard-translate-table flow-control-c-s-replacement nil)
+          (aset keyboard-translate-table ?\^s nil)
+          (aset keyboard-translate-table flow-control-c-q-replacement nil)
+          (aset keyboard-translate-table ?\^q nil)))
     ;; Turn flow control on.
     ;; Tell emacs to pass C-s and C-q to OS.
     (set-input-mode nil t (nth 2 (current-input-mode)))
diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index f3ea22a..4c6e118 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -1,4 +1,4 @@
-;;; generic-x.el --- A collection of generic modes
+;;; generic-x.el --- A collection of generic modes  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 1997-1998, 2001-2021 Free Software Foundation, Inc.
 
@@ -121,14 +121,12 @@
   "If non-nil, add a hook to enter `default-generic-mode' automatically.
 This is done if the first few lines of a file in fundamental mode
 start with a hash comment character."
-  :group 'generic-x
   :type  'boolean)
 
 (defcustom generic-lines-to-scan 3
   "Number of lines that `generic-mode-find-file-hook' looks at.
 Relevant when deciding whether to enter Default-Generic mode automatically.
 This variable should be set to a small positive number."
-  :group 'generic-x
   :type  'integer)
 
 (defcustom generic-find-file-regexp "^#"
@@ -137,7 +135,6 @@ Files in fundamental mode whose first few lines contain a 
match
 for this regexp, should be put into Default-Generic mode instead.
 The number of lines tested for the matches is specified by the
 value of the variable `generic-lines-to-scan', which see."
-  :group 'generic-x
   :type  'regexp)
 
 (defcustom generic-ignore-files-regexp "[Tt][Aa][Gg][Ss]\\'"
@@ -146,7 +143,6 @@ Files whose names match this regular expression should not 
be put
 into Default-Generic mode, even if they have lines which match
 the regexp in `generic-find-file-regexp'.  If the value is nil,
 `generic-mode-find-file-hook' does not check the file names."
-  :group 'generic-x
   :type  '(choice (const :tag "Don't check file names" nil) regexp))
 
 ;; This generic mode is always defined
@@ -249,7 +245,6 @@ This hook will be installed if the variable
 Each entry in the list should be a symbol.  If you set this variable
 directly, without using customize, you must reload generic-x to put
 your changes into effect."
-  :group 'generic-x
   :type (let (list)
          (dolist (mode
                   (sort (append generic-default-modes
@@ -365,7 +360,8 @@ your changes into effect."
 (define-generic-mode hosts-generic-mode
   '(?#)
   '("localhost")
-  '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face))
+  '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face)
+    ("\\<\\([0-9A-Fa-f:]+\\)\\>" 1 font-lock-constant-face))
   '("[hH][oO][sS][tT][sS]\\'")
   nil
   "Generic mode for HOSTS files."))
@@ -415,7 +411,8 @@ like an INI file.  You can add this hook to 
`find-file-hook'."
         (goto-char (point-min))
         (and (looking-at "^\\s-*\\[.*\\]")
              (ini-generic-mode)))))
-(defalias 'generic-mode-ini-file-find-file-hook 
'ini-generic-mode-find-file-hook))
+(define-obsolete-function-alias 'generic-mode-ini-file-find-file-hook
+  'ini-generic-mode-find-file-hook "28.1"))
 
 ;;; Windows REG files
 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
@@ -1296,19 +1293,16 @@ like an INI file.  You can add this hook to 
`find-file-hook'."
 
 ;; here manually instead
 (defun generic-rul-mode-setup-function ()
-  (make-local-variable 'parse-sexp-ignore-comments)
-  (make-local-variable 'comment-start)
   (make-local-variable 'comment-start-skip)
-  (make-local-variable 'comment-end)
   (setq imenu-generic-expression
-       '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
-       parse-sexp-ignore-comments t
-       comment-end               "*/"
-       comment-start        "/*"
-;;;    comment-end               ""
-;;;    comment-start        "//"
-;;;    comment-start-skip           ""
-       )
+        '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)))
+  (setq-local parse-sexp-ignore-comments t
+              comment-end        "*/"
+              comment-start      "/*"
+;;;           comment-end        ""
+;;;           comment-start      "//"
+;;;           comment-start-skip ""
+              )
   ;; (set-syntax-table rul-generic-mode-syntax-table)
   (setq-local font-lock-syntax-table rul-generic-mode-syntax-table))
 
@@ -1458,7 +1452,7 @@ like an INI file.  You can add this hook to 
`find-file-hook'."
        ":"
        ;; Password, UID and GID
        (mapconcat
-       'identity
+        #'identity
        (make-list 3 "\\([^:]+\\)")
        ":")
        ":"
@@ -1490,41 +1484,104 @@ like an INI file.  You can add this hook to 
`find-file-hook'."
 (define-generic-mode etc-fstab-generic-mode
   '(?#)
   '("adfs"
+    "ados"
     "affs"
+    "anon_inodefs"
+    "atfs"
+    "audiofs"
     "autofs"
+    "bdev"
+    "befs"
+    "bfs"
+    "binfmt_misc"
+    "btrfs"
+    "cd9660"
+    "cfs"
+    "cgroup"
+    "cifs"
     "coda"
     "coherent"
+    "configfs"
+    "cpuset"
     "cramfs"
+    "devfs"
     "devpts"
+    "devtmpfs"
+    "e2compr"
     "efs"
     "ext2"
+    "ext2fs"
     "ext3"
     "ext4"
+    "fdesc"
+    "ffs"
+    "filecore"
+    "fuse"
+    "fuseblk"
+    "fusectl"
     "hfs"
     "hpfs"
+    "hugetlbfs"
     "iso9660"
+    "jffs"
+    "jffs2"
     "jfs"
+    "kernfs"
+    "lfs"
+    "linprocfs"
+    "mfs"
     "minix"
+    "mqueue"
     "msdos"
     "ncpfs"
     "nfs"
+    "nfsd"
+    "nilfs2"
+    "none"
     "ntfs"
+    "null"
+    "nwfs"
+    "overlay"
+    "ovlfs"
+    "pipefs"
+    "portal"
     "proc"
+    "procfs"
+    "pstore"
+    "ptyfs"
     "qnx4"
+    "ramfs"
     "reiserfs"
     "romfs"
+    "securityfs"
+    "shm"
     "smbfs"
-    "cifs"
-    "usbdevfs"
-    "sysv"
+    "sockfs"
+    "squashfs"
+    "sshfs"
+    "std"
+    "subfs"
     "sysfs"
+    "sysv"
+    "tcfs"
     "tmpfs"
     "udf"
     "ufs"
+    "umap"
     "umsdos"
+    "union"
+    "usbdevfs"
+    "usbfs"
+    "userfs"
     "vfat"
+    "vs3fs"
+    "vxfs"
+    "wrapfs"
+    "wvfs"
+    "xenfs"
     "xenix"
     "xfs"
+    "zisofs"
     "swap"
     "auto"
     "ignore")
@@ -1575,8 +1632,7 @@ like an INI file.  You can add this hook to 
`find-file-hook'."
     (((class color)     (min-colors 88))    (:background "red1"))
     (((class color))                        (:background "red"))
     (t (:weight bold)))
-  "Font Lock mode face used to highlight TABs."
-  :group 'generic-x)
+  "Font Lock mode face used to highlight TABs.")
 
 (defface show-tabs-space
   '((((class grayscale) (background light)) (:background "DimGray"   :weight 
bold))
@@ -1584,8 +1640,7 @@ like an INI file.  You can add this hook to 
`find-file-hook'."
     (((class color)     (min-colors 88))    (:background "yellow1"))
     (((class color))                        (:background "yellow"))
     (t (:weight bold)))
-  "Font Lock mode face used to highlight spaces."
-  :group 'generic-x)
+  "Font Lock mode face used to highlight spaces.")
 
 (define-generic-mode show-tabs-generic-mode
   nil ;; no comment char
diff --git a/lisp/gnus/gnus-agent.el b/lisp/gnus/gnus-agent.el
index 6866230..56640ea 100644
--- a/lisp/gnus/gnus-agent.el
+++ b/lisp/gnus/gnus-agent.el
@@ -1789,7 +1789,6 @@ variables.  Returns the first non-nil value found."
                  . gnus-agent-enable-expiration)
                 (agent-predicate . gnus-agent-predicate)))))))
 
-;; FIXME: This looks an awful lot like `gnus-agent-retrieve-headers'.
 (defun gnus-agent-fetch-headers (group)
   "Fetch interesting headers into the agent.  The group's overview
 file will be updated to include the headers while a list of available
@@ -1811,9 +1810,10 @@ article numbers will be returned."
                                    (cdr active))))
                         (gnus-uncompress-range (gnus-active group)))
                      (gnus-list-of-unread-articles group)))
+         (gnus-decode-encoded-word-function 'identity)
+        (gnus-decode-encoded-address-function 'identity)
          (file (gnus-agent-article-name ".overview" group))
-        (file-name-coding-system nnmail-pathname-coding-system)
-        headers fetched-headers)
+        (file-name-coding-system nnmail-pathname-coding-system))
 
     (unless fetch-all
       ;; Add articles with marks to the list of article headers we want to
@@ -1824,7 +1824,7 @@ article numbers will be returned."
       (dolist (arts (gnus-info-marks (gnus-get-info group)))
         (unless (memq (car arts) '(seen recent killed cache))
           (setq articles (gnus-range-add articles (cdr arts)))))
-      (setq articles (sort (gnus-uncompress-range articles) '<)))
+      (setq articles (sort (gnus-uncompress-sequence articles) '<)))
 
     ;; At this point, I have the list of articles to consider for
     ;; fetching.  This is the list that I'll return to my caller. Some
@@ -1867,52 +1867,38 @@ article numbers will be returned."
         10 "gnus-agent-fetch-headers: undownloaded articles are `%s'"
         (gnus-compress-sequence articles t)))
 
-      ;; Parse known headers from FILE.
-      (if (file-exists-p file)
-         (with-current-buffer gnus-agent-overview-buffer
-           (erase-buffer)
-           (let ((nnheader-file-coding-system
-                  gnus-agent-file-coding-system))
-             (nnheader-insert-nov-file file (car articles))
-             (with-current-buffer nntp-server-buffer
-               (erase-buffer)
-               (insert-buffer-substring gnus-agent-overview-buffer)
-               (setq headers
-                     (gnus-get-newsgroup-headers-xover
-                      articles nil (buffer-local-value
-                                    'gnus-newsgroup-dependencies
-                                    gnus-summary-buffer)
-                      gnus-newsgroup-name)))))
-       (gnus-make-directory (nnheader-translate-file-chars
-                              (file-name-directory file) t)))
-
-      ;; Fetch our new headers.
-      (gnus-message 8 "Fetching headers for %s..." group)
-      (if articles
-         (setq fetched-headers (gnus-fetch-headers articles)))
-
-      ;; Merge two sets of headers.
-      (setq headers
-           (if (and headers fetched-headers)
-               (delete-dups
-                (sort (append headers (copy-sequence fetched-headers))
-                      (lambda (l r)
-                        (< (mail-header-number l)
-                           (mail-header-number r)))))
-             (or headers fetched-headers)))
-
-      ;; Save the new set of headers to FILE.
-      (let ((coding-system-for-write
-             gnus-agent-file-coding-system))
-       (with-current-buffer gnus-agent-overview-buffer
-         (goto-char (point-max))
-         (mapc #'nnheader-insert-nov fetched-headers)
-         (sort-numeric-fields 1 (point-min) (point-max))
-          (gnus-agent-check-overview-buffer)
-         (write-region (point-min) (point-max) file nil 'silent))
-       (gnus-agent-update-view-total-fetched-for group t)
-       (gnus-agent-save-alist group articles nil)))
-    headers))
+      (with-current-buffer nntp-server-buffer
+        (if articles
+            (progn
+             (gnus-message 8 "Fetching headers for %s..." group)
+
+              ;; Fetch them.
+              (gnus-make-directory (nnheader-translate-file-chars
+                                    (file-name-directory file) t))
+
+              (unless (eq 'nov (gnus-retrieve-headers articles group))
+                (nnvirtual-convert-headers))
+              (gnus-agent-check-overview-buffer)
+              ;; Move these headers to the overview buffer so that
+              ;; gnus-agent-braid-nov can merge them with the contents
+              ;; of FILE.
+              (copy-to-buffer
+              gnus-agent-overview-buffer (point-min) (point-max))
+             ;; NOTE: Call g-a-brand-nov even when the file does not
+             ;; exist.  As a minimum, it will validate the article
+             ;; numbers already in the buffer.
+             (gnus-agent-braid-nov articles file)
+              (let ((coding-system-for-write
+                     gnus-agent-file-coding-system))
+                (gnus-agent-check-overview-buffer)
+                (write-region (point-min) (point-max) file nil 'silent))
+             (gnus-agent-update-view-total-fetched-for group t)
+              (gnus-agent-save-alist group articles nil)
+              articles)
+          (ignore-errors
+            (erase-buffer)
+            (nnheader-insert-file-contents file)))))
+    articles))
 
 (defsubst gnus-agent-read-article-number ()
   "Read the article number at point.
@@ -1938,6 +1924,96 @@ Return nil when a valid article number can not be read."
       (set-buffer nntp-server-buffer)
       (insert-buffer-substring gnus-agent-overview-buffer b e))))
 
+(defun gnus-agent-braid-nov (articles file)
+  "Merge agent overview data with given file.
+Takes unvalidated headers for ARTICLES from
+`gnus-agent-overview-buffer' and validated headers from the given
+FILE and places the combined valid headers into
+`nntp-server-buffer'.  This function can be used, when file
+doesn't exist, to valid the overview buffer."
+  (let (start last)
+    (set-buffer gnus-agent-overview-buffer)
+    (goto-char (point-min))
+    (set-buffer nntp-server-buffer)
+    (erase-buffer)
+    (when (file-exists-p file)
+      (nnheader-insert-file-contents file))
+    (goto-char (point-max))
+    (forward-line -1)
+
+    (unless (or (= (point-min) (point-max))
+               (< (setq last (read (current-buffer))) (car articles)))
+      ;; Old and new overlap -- We do it the hard way.
+      (when (nnheader-find-nov-line (car articles))
+        ;; Replacing existing NOV entry
+        (delete-region (point) (progn (forward-line 1) (point))))
+      (gnus-agent-copy-nov-line (pop articles))
+
+      (ignore-errors
+       (while articles
+         (while (let ((art (read (current-buffer))))
+                  (cond ((< art (car articles))
+                         (forward-line 1)
+                         t)
+                        ((= art (car articles))
+                         (beginning-of-line)
+                         (delete-region
+                          (point) (progn (forward-line 1) (point)))
+                         nil)
+                        (t
+                         (beginning-of-line)
+                         nil))))
+
+         (gnus-agent-copy-nov-line (pop articles)))))
+
+    (goto-char (point-max))
+
+    ;; Append the remaining lines
+    (when articles
+      (when last
+       (set-buffer gnus-agent-overview-buffer)
+       (setq start (point))
+       (set-buffer nntp-server-buffer))
+
+      (let ((p (point)))
+       (insert-buffer-substring gnus-agent-overview-buffer start)
+       (goto-char p))
+
+      (setq last (or last -134217728))
+      (while (catch 'problems
+              (let (sort art)
+                (while (not (eobp))
+                  (setq art (gnus-agent-read-article-number))
+                  (cond ((not art)
+                         ;; Bad art num - delete this line
+                         (beginning-of-line)
+                         (delete-region (point) (progn (forward-line 1) 
(point))))
+                        ((< art last)
+                         ;; Art num out of order - enable sort
+                         (setq sort t)
+                         (forward-line 1))
+                        ((= art last)
+                         ;; Bad repeat of art number - delete this line
+                         (beginning-of-line)
+                         (delete-region (point) (progn (forward-line 1) 
(point))))
+                        (t
+                         ;; Good art num
+                         (setq last art)
+                         (forward-line 1))))
+                (when sort
+                  ;; something is seriously wrong as we simply shouldn't see 
out-of-order data.
+                  ;; First, we'll fix the sort.
+                  (sort-numeric-fields 1 (point-min) (point-max))
+
+                  ;; but now we have to consider that we may have duplicate 
rows...
+                  ;; so reset to beginning of file
+                  (goto-char (point-min))
+                  (setq last -134217728)
+
+                  ;; and throw a code that restarts this scan
+                  (throw 'problems t))
+                nil))))))
+
 ;; Keeps the compiler from warning about the free variable in
 ;; gnus-agent-read-agentview.
 (defvar gnus-agent-read-agentview)
@@ -2310,9 +2386,10 @@ modified) original contents, they are first saved to 
their own file."
        (gnus-orphan-score gnus-orphan-score)
        ;; Maybe some other gnus-summary local variables should also
        ;; be put here.
-       fetched-headers
+
         gnus-headers
         gnus-score
+        articles
         predicate info marks
        )
     (unless (gnus-check-group group)
@@ -2333,35 +2410,38 @@ modified) original contents, they are first saved to 
their own file."
                                          (setq info (gnus-get-info group)))))))
               (when arts
                 (setq marked-articles (nconc (gnus-uncompress-range arts)
-                                             marked-articles))))))
+                                             marked-articles))
+                ))))
         (setq marked-articles (sort marked-articles '<))
 
-       (setq gnus-newsgroup-dependencies
-              (or gnus-newsgroup-dependencies
-                  (gnus-make-hashtable)))
+        ;; Fetch any new articles from the server
+        (setq articles (gnus-agent-fetch-headers group))
 
-        ;; Fetch headers for any new articles from the server.
-        (setq fetched-headers (gnus-agent-fetch-headers group))
+        ;; Merge new articles with marked
+        (setq articles (sort (append marked-articles articles) '<))
 
-        (when fetched-headers
+        (when articles
+          ;; Parse them and see which articles we want to fetch.
+          (setq gnus-newsgroup-dependencies
+                (or gnus-newsgroup-dependencies
+                    (gnus-make-hashtable (length articles))))
           (setq gnus-newsgroup-headers
-               (or gnus-newsgroup-headers
-                    fetched-headers)))
-       (when marked-articles
-          ;; `gnus-agent-overview-buffer' may be killed for timeout
-          ;; reason.  If so, recreate it.
+                (or gnus-newsgroup-headers
+                    (gnus-get-newsgroup-headers-xover articles nil nil
+                                                      group)))
+          ;; `gnus-agent-overview-buffer' may be killed for
+          ;; timeout reason.  If so, recreate it.
           (gnus-agent-create-buffer)
 
           (setq predicate
-               (gnus-get-predicate
-                (gnus-agent-find-parameter group 'agent-predicate)))
-
-          ;; If the selection predicate requires scoring, score each header.
+                (gnus-get-predicate
+                 (gnus-agent-find-parameter group 'agent-predicate)))
 
+          ;; If the selection predicate requires scoring, score each header
           (unless (memq predicate '(gnus-agent-true gnus-agent-false))
             (let ((score-param
                    (gnus-agent-find-parameter group 'agent-score-file)))
-              ;; Translate score-param into real one.
+              ;; Translate score-param into real one
               (cond
                ((not score-param))
                ((eq score-param 'file)
@@ -3581,9 +3661,11 @@ has been fetched."
 (defun gnus-agent-retrieve-headers (articles group &optional fetch-old)
   (save-excursion
     (gnus-agent-create-buffer)
-    (let ((file (gnus-agent-article-name ".overview" group))
-         (file-name-coding-system nnmail-pathname-coding-system)
-         uncached-articles headers fetched-headers)
+    (let ((gnus-decode-encoded-word-function 'identity)
+         (gnus-decode-encoded-address-function 'identity)
+         (file (gnus-agent-article-name ".overview" group))
+          uncached-articles
+         (file-name-coding-system nnmail-pathname-coding-system))
       (gnus-make-directory (nnheader-translate-file-chars
                            (file-name-directory file) t))
 
@@ -3594,63 +3676,122 @@ has been fetched."
                                1)
                              (car (last articles))))))
 
-      ;; See if we've got cached headers for ARTICLES and put them in
-      ;; HEADERS.  Articles with no cached headers go in
-      ;; UNCACHED-ARTICLES to be fetched from the server.
+      ;; Populate temp buffer with known headers
       (when (file-exists-p file)
        (with-current-buffer gnus-agent-overview-buffer
          (erase-buffer)
          (let ((nnheader-file-coding-system
                 gnus-agent-file-coding-system))
-           (nnheader-insert-nov-file file (car articles))
-           (with-current-buffer nntp-server-buffer
-             (erase-buffer)
-             (insert-buffer-substring gnus-agent-overview-buffer)
-             (setq headers
-                   (gnus-get-newsgroup-headers-xover
-                    articles nil (buffer-local-value
-                                  'gnus-newsgroup-dependencies
-                                  gnus-summary-buffer)
-                    gnus-newsgroup-name))))))
-
-      (setq uncached-articles
-           (gnus-agent-uncached-articles articles group t))
-
-      (when uncached-articles
-       (let ((gnus-newsgroup-name group)
-             gnus-agent)               ; Prevent loop.
-          ;; Fetch additional headers for the uncached articles.
-         (setq fetched-headers (gnus-fetch-headers uncached-articles))
-         ;; Merge headers we got from the overview file with our
-         ;; newly-fetched headers.
-         (when fetched-headers
-           (setq headers
-                 (delete-dups
-                  (sort (append headers (copy-sequence fetched-headers))
-                        (lambda (l r)
-                          (< (mail-header-number l)
-                             (mail-header-number r))))))
-
-           ;; Add the new set of known headers to the overview file.
+           (nnheader-insert-nov-file file (car articles)))))
+
+      (if (setq uncached-articles (gnus-agent-uncached-articles articles group
+                                                                t))
+         (progn
+            ;; Populate nntp-server-buffer with uncached headers
+           (set-buffer nntp-server-buffer)
+           (erase-buffer)
+            (cond ((not (eq 'nov (let (gnus-agent) ; Turn off agent
+                                   (gnus-retrieve-headers
+                                    uncached-articles group))))
+                   (nnvirtual-convert-headers))
+                  ((eq 'nntp (car gnus-current-select-method))
+                   ;; The author of gnus-get-newsgroup-headers-xover
+                   ;; reports that the XOVER command is commonly
+                   ;; unreliable. The problem is that recently
+                   ;; posted articles may not be entered into the
+                   ;; NOV database in time to respond to my XOVER
+                   ;; query.
+                   ;;
+                   ;; I'm going to use his assumption that the NOV
+                   ;; database is updated in order of ascending
+                   ;; article ID.  Therefore, a response containing
+                   ;; article ID N implies that all articles from 1
+                   ;; to N-1 are up-to-date.  Therefore, missing
+                   ;; articles in that range have expired.
+
+                   (set-buffer nntp-server-buffer)
+                   (let* ((fetched-articles (list nil))
+                          (tail-fetched-articles fetched-articles)
+                          (min (car articles))
+                          (max (car (last articles))))
+
+                     ;; Get the list of articles that were fetched
+                     (goto-char (point-min))
+                     (let ((pm (point-max))
+                          art)
+                       (while (< (point) pm)
+                        (when (setq art (gnus-agent-read-article-number))
+                           (gnus-agent-append-to-list tail-fetched-articles 
art))
+                         (forward-line 1)))
+
+                     ;; Clip this list to the headers that will
+                     ;; actually be returned
+                     (setq fetched-articles (gnus-list-range-intersection
+                                             (cdr fetched-articles)
+                                             (cons min max)))
+
+                     ;; Clip the uncached articles list to exclude
+                     ;; IDs after the last FETCHED header.  The
+                     ;; excluded IDs may be fetchable using HEAD.
+                     (if (car tail-fetched-articles)
+                         (setq uncached-articles
+                               (gnus-list-range-intersection
+                                uncached-articles
+                                (cons (car uncached-articles)
+                                      (car tail-fetched-articles)))))
+
+                     ;; Create the list of articles that were
+                     ;; "successfully" fetched.  Success, in this
+                     ;; case, means that the ID should not be
+                     ;; fetched again.  In the case of an expired
+                     ;; article, the header will not be fetched.
+                     (setq uncached-articles
+                           (gnus-sorted-nunion fetched-articles
+                                               uncached-articles))
+                     )))
+
+            ;; Erase the temp buffer
+           (set-buffer gnus-agent-overview-buffer)
+           (erase-buffer)
+
+            ;; Copy the nntp-server-buffer to the temp buffer
+           (set-buffer nntp-server-buffer)
+           (copy-to-buffer gnus-agent-overview-buffer (point-min) (point-max))
+
+           ;; Merge the temp buffer with the known headers (found on
+           ;; disk in FILE) into the nntp-server-buffer
+           (when uncached-articles
+             (gnus-agent-braid-nov uncached-articles file))
+
+           ;; Save the new set of known headers to FILE
+           (set-buffer nntp-server-buffer)
            (let ((coding-system-for-write
                   gnus-agent-file-coding-system))
-             (with-current-buffer gnus-agent-overview-buffer
-               ;; We stick the new headers in at the end, then
-               ;; re-sort the whole buffer with
-               ;; `sort-numeric-fields'.  If this turns out to be
-               ;; slow, we could consider a loop to add the headers
-               ;; in sorted order to begin with.
-               (goto-char (point-max))
-               (mapc #'nnheader-insert-nov fetched-headers)
-               (sort-numeric-fields 1 (point-min) (point-max))
-               (gnus-agent-check-overview-buffer)
-               (write-region (point-min) (point-max) file nil 'silent)
-               (gnus-agent-update-view-total-fetched-for group t)
-               ;; Update the group's article alist to include the
-               ;; newly fetched articles.
-               (gnus-agent-load-alist group)
-               (gnus-agent-save-alist group uncached-articles nil))))))
-      headers)))
+             (gnus-agent-check-overview-buffer)
+             (write-region (point-min) (point-max) file nil 'silent))
+
+           (gnus-agent-update-view-total-fetched-for group t)
+
+            ;; Update the group's article alist to include the newly
+            ;; fetched articles.
+           (gnus-agent-load-alist group)
+           (gnus-agent-save-alist group uncached-articles nil)
+            )
+
+        ;; Copy the temp buffer to the nntp-server-buffer
+        (set-buffer nntp-server-buffer)
+       (erase-buffer)
+       (insert-buffer-substring gnus-agent-overview-buffer)))
+
+    (if (and fetch-old
+            (not (numberp fetch-old)))
+       t                               ; Don't remove anything.
+      (nnheader-nov-delete-outside-range
+       (car articles)
+       (car (last articles)))
+      t)
+
+    'nov))
 
 (defun gnus-agent-request-article (article group)
   "Retrieve ARTICLE in GROUP from the agent cache."
diff --git a/lisp/gnus/gnus-async.el b/lisp/gnus/gnus-async.el
index ed948a2..fefd02c 100644
--- a/lisp/gnus/gnus-async.el
+++ b/lisp/gnus/gnus-async.el
@@ -357,13 +357,8 @@ that was fetched."
        (let ((nntp-server-buffer (current-buffer))
              (nnheader-callback-function
               (lambda (_arg)
-                (setq gnus-async-header-prefetched
-                      (cons group unread)))))
-         ;; FIXME: If header prefetch is ever put into use, we'll
-         ;; have to handle the possibility that
-         ;; `gnus-retrieve-headers' might return a list of header
-         ;; vectors directly, rather than writing them into the
-         ;; current buffer.
+                 (setq gnus-async-header-prefetched
+                       (cons group unread)))))
          (gnus-retrieve-headers unread group gnus-fetch-old-headers))))))
 
 (defun gnus-async-retrieve-fetched-headers (articles group)
diff --git a/lisp/gnus/gnus-cache.el b/lisp/gnus/gnus-cache.el
index 9423d9f..36657e4 100644
--- a/lisp/gnus/gnus-cache.el
+++ b/lisp/gnus/gnus-cache.el
@@ -294,47 +294,49 @@ it's not cached."
 (defun gnus-cache-retrieve-headers (articles group &optional fetch-old)
   "Retrieve the headers for ARTICLES in GROUP."
   (let ((cached
-        (setq gnus-newsgroup-cached (gnus-cache-articles-in-group group)))
-       (gnus-newsgroup-name group)
-       (gnus-fetch-old-headers fetch-old))
+        (setq gnus-newsgroup-cached (gnus-cache-articles-in-group group))))
     (if (not cached)
        ;; No cached articles here, so we just retrieve them
        ;; the normal way.
        (let ((gnus-use-cache nil))
-         (gnus-retrieve-headers articles group))
+         (gnus-retrieve-headers articles group fetch-old))
       (let ((uncached-articles (gnus-sorted-difference articles cached))
            (cache-file (gnus-cache-file-name group ".overview"))
-           (file-name-coding-system nnmail-pathname-coding-system)
-           headers)
+           type
+           (file-name-coding-system nnmail-pathname-coding-system))
        ;; We first retrieve all the headers that we don't have in
        ;; the cache.
        (let ((gnus-use-cache nil))
          (when uncached-articles
-           (setq headers (and articles
-                              (gnus-fetch-headers uncached-articles)))))
+           (setq type (and articles
+                           (gnus-retrieve-headers
+                            uncached-articles group fetch-old)))))
        (gnus-cache-save-buffers)
-       ;; Then we include the cached headers.
-       (when (file-exists-p cache-file)
-         (setq headers
-               (delete-dups
-                (sort
-                 (append headers
-                         (let ((coding-system-for-read
-                                gnus-cache-overview-coding-system))
-                           (with-current-buffer nntp-server-buffer
-                             (erase-buffer)
-                             (insert-file-contents cache-file)
-                             (gnus-get-newsgroup-headers-xover
-                              (gnus-sorted-difference
-                               cached uncached-articles)
-                              nil (buffer-local-value
-                                   'gnus-newsgroup-dependencies
-                                   gnus-summary-buffer)
-                              group))))
-                 (lambda (l r)
-                   (< (mail-header-number l)
-                      (mail-header-number r)))))))
-       headers))))
+       ;; Then we insert the cached headers.
+       (save-excursion
+         (cond
+          ((not (file-exists-p cache-file))
+           ;; There are no cached headers.
+           type)
+          ((null type)
+           ;; There were no uncached headers (or retrieval was
+           ;; unsuccessful), so we use the cached headers exclusively.
+           (set-buffer nntp-server-buffer)
+           (erase-buffer)
+           (let ((coding-system-for-read
+                  gnus-cache-overview-coding-system))
+             (insert-file-contents cache-file))
+           'nov)
+          ((eq type 'nov)
+           ;; We have both cached and uncached NOV headers, so we
+           ;; braid them.
+           (gnus-cache-braid-nov group cached)
+           type)
+          (t
+           ;; We braid HEADs.
+           (gnus-cache-braid-heads group (gnus-sorted-intersection
+                                          cached articles))
+           type)))))))
 
 (defun gnus-cache-enter-article (&optional n)
   "Enter the next N articles into the cache.
@@ -527,6 +529,70 @@ Returns the list of articles removed."
          (setq gnus-cache-active-altered t)))
       articles)))
 
+(defun gnus-cache-braid-nov (group cached &optional file)
+  (let ((cache-buf (gnus-get-buffer-create " *gnus-cache*"))
+       beg end)
+    (gnus-cache-save-buffers)
+    (with-current-buffer cache-buf
+      (erase-buffer)
+      (let ((coding-system-for-read gnus-cache-overview-coding-system)
+           (file-name-coding-system nnmail-pathname-coding-system))
+       (insert-file-contents
+        (or file (gnus-cache-file-name group ".overview"))))
+      (goto-char (point-min))
+      (insert "\n")
+      (goto-char (point-min)))
+    (set-buffer nntp-server-buffer)
+    (goto-char (point-min))
+    (while cached
+      (while (and (not (eobp))
+                 (< (read (current-buffer)) (car cached)))
+       (forward-line 1))
+      (beginning-of-line)
+      (set-buffer cache-buf)
+      (if (search-forward (concat "\n" (int-to-string (car cached)) "\t")
+                         nil t)
+         (setq beg (point-at-bol)
+               end (progn (end-of-line) (point)))
+       (setq beg nil))
+      (set-buffer nntp-server-buffer)
+      (when beg
+       (insert-buffer-substring cache-buf beg end)
+       (insert "\n"))
+      (setq cached (cdr cached)))
+    (kill-buffer cache-buf)))
+
+(defun gnus-cache-braid-heads (group cached)
+  (let ((cache-buf (gnus-get-buffer-create " *gnus-cache*")))
+    (with-current-buffer cache-buf
+      (erase-buffer))
+    (set-buffer nntp-server-buffer)
+    (goto-char (point-min))
+    (dolist (entry cached)
+      (while (and (not (eobp))
+                 (looking-at "2.. +\\([0-9]+\\) ")
+                 (< (progn (goto-char (match-beginning 1))
+                           (read (current-buffer)))
+                    entry))
+       (search-forward "\n.\n" nil 'move))
+      (beginning-of-line)
+      (set-buffer cache-buf)
+      (erase-buffer)
+      (let ((coding-system-for-read gnus-cache-coding-system)
+           (file-name-coding-system nnmail-pathname-coding-system))
+       (insert-file-contents (gnus-cache-file-name group entry)))
+      (goto-char (point-min))
+      (insert "220 ")
+      (princ (pop cached) (current-buffer))
+      (insert " Article retrieved.\n")
+      (search-forward "\n\n" nil 'move)
+      (delete-region (point) (point-max))
+      (forward-char -1)
+      (insert ".")
+      (set-buffer nntp-server-buffer)
+      (insert-buffer-substring cache-buf))
+    (kill-buffer cache-buf)))
+
 ;;;###autoload
 (defun gnus-jog-cache ()
   "Go through all groups and put the articles into the cache.
diff --git a/lisp/gnus/gnus-cloud.el b/lisp/gnus/gnus-cloud.el
index 00b85f5..f7c71f4 100644
--- a/lisp/gnus/gnus-cloud.el
+++ b/lisp/gnus/gnus-cloud.el
@@ -30,8 +30,6 @@
 
 (require 'parse-time)
 (require 'nnimap)
-(declare-function gnus-fetch-headers "gnus-sum")
-(defvar gnus-alter-header-function)
 
 (eval-when-compile (require 'epg)) ;; setf-method for `epg-context-armor'
 (autoload 'epg-make-context "epg")
@@ -393,6 +391,8 @@ When FULL is t, upload everything, not just a difference 
from the last full."
             (gnus-group-refresh-group group))
         (gnus-error 2 "Failed to upload Gnus Cloud data to %s" group)))))
 
+(defvar gnus-alter-header-function)
+
 (defun gnus-cloud-add-timestamps (elems)
   (dolist (elem elems)
     (let* ((file-name (plist-get elem :file-name))
@@ -407,10 +407,14 @@ When FULL is t, upload everything, not just a difference 
from the last full."
   (gnus-activate-group gnus-cloud-group-name nil nil gnus-cloud-method)
   (let* ((group (gnus-group-full-name gnus-cloud-group-name gnus-cloud-method))
          (active (gnus-active group))
-        (gnus-newsgroup-name group)
-         (headers (gnus-fetch-headers (gnus-uncompress-range active))))
-    (when gnus-alter-header-function
-      (mapc gnus-alter-header-function headers))
+         headers head)
+    (when (gnus-retrieve-headers (gnus-uncompress-range active) group)
+      (with-current-buffer nntp-server-buffer
+        (goto-char (point-min))
+       (while (setq head (nnheader-parse-head))
+          (when gnus-alter-header-function
+            (funcall gnus-alter-header-function head))
+          (push head headers))))
     (sort (nreverse headers)
           (lambda (h1 h2)
             (> (gnus-cloud-chunk-sequence (mail-header-subject h1))
diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el
index 1e0e207..9811e8b 100644
--- a/lisp/gnus/gnus-icalendar.el
+++ b/lisp/gnus/gnus-icalendar.el
@@ -835,6 +835,7 @@ These will be used to retrieve the RSVP information from 
ical events."
        keymap ,gnus-mime-button-map
        face ,gnus-article-button-face
        follow-link t
+       category t
        button t
        gnus-data ,data))))
 
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 5bd58b6..b0f9ed4 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -5658,21 +5658,10 @@ or a straight list of headers."
          (setf (mail-header-subject header) subject))))))
 
 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
-  "Fetch headers of ARTICLES.
-This calls the `gnus-retrieve-headers' function of the current
-group's backend server.  The server can do one of two things:
-
-1. Write the headers for ARTICLES into the
-   `nntp-server-buffer' (the current buffer) in a parseable format, or
-2. Return the headers directly as a list of vectors.
-
-In the first case, `gnus-retrieve-headers' returns a symbol
-value, either `nov' or `headers'.  This value determines which
-parsing function is used to read the headers.  It is also stored
-into the variable `gnus-headers-retrieved-by', which is consulted
-later when possibly building full threads."
+  "Fetch headers of ARTICLES."
   (gnus-message 7 "Fetching headers for %s..." gnus-newsgroup-name)
-  (let ((res (setq gnus-headers-retrieved-by
+  (prog1
+      (pcase (setq gnus-headers-retrieved-by
                   (gnus-retrieve-headers
                    articles gnus-newsgroup-name
                    (or limit
@@ -5682,34 +5671,22 @@ later when possibly building full threads."
                                  (not (eq gnus-fetch-old-headers 'some))
                                  (not (numberp gnus-fetch-old-headers)))
                                 (> (length articles) 1))
-                            gnus-fetch-old-headers))))))
-    (prog1
-       (pcase res
-         ('nov
-          (gnus-get-newsgroup-headers-xover
-           articles force-new dependencies gnus-newsgroup-name t))
-         ;; For now, assume that any backend returning its own
-         ;; headers takes some effort to do so, so return `headers'.
-         ((pred listp)
-          (setq gnus-headers-retrieved-by 'headers)
-          (let ((dependencies
-                 (or dependencies
-                     (buffer-local-value
-                      'gnus-newsgroup-dependencies gnus-summary-buffer))))
-            (when (functionp gnus-alter-header-function)
-              (mapc gnus-alter-header-function res))
-            (mapc (lambda (header)
-                    ;; The agent or the cache may have already
-                    ;; registered this header in the dependency
-                    ;; table.
-                    (unless (gethash (mail-header-id header) dependencies)
-                      (gnus-dependencies-add-header
-                       header dependencies force-new)))
-                  res)
-            res))
-         (_ (gnus-get-newsgroup-headers dependencies force-new)))
-      (gnus-message 7 "Fetching headers for %s...done"
-                   gnus-newsgroup-name))))
+                            gnus-fetch-old-headers))))
+    ('nov
+     (gnus-get-newsgroup-headers-xover
+      articles force-new dependencies gnus-newsgroup-name t))
+    ('headers
+     (gnus-get-newsgroup-headers dependencies force-new))
+    ((pred listp)
+     (let ((dependencies
+           (or dependencies
+               (with-current-buffer gnus-summary-buffer
+                 gnus-newsgroup-dependencies))))
+     (delq nil (mapcar   #'(lambda (header)
+                            (gnus-dependencies-add-header
+                             header dependencies force-new))
+                        gnus-headers-retrieved-by)))))
+  (gnus-message 7 "Fetching headers for %s...done" gnus-newsgroup-name)))
 
 (defun gnus-select-newsgroup (group &optional read-all select-articles)
   "Select newsgroup GROUP.
@@ -6466,10 +6443,6 @@ The resulting hash table is returned, or nil if no Xrefs 
were found."
        (unless (gnus-ephemeral-group-p group)
          (gnus-group-update-group group t))))))
 
-;; FIXME: Refactor this with `gnus-get-newsgroup-headers-xover' and
-;; extract the necessary bits for the direct-header-return case.  Also
-;; look at this and see how similar it is to
-;; `nnheader-parse-naked-head'.
 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
   (let ((dependencies
         (or dependencies
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index 4241f30..91ab878 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -2388,14 +2388,7 @@ Typical marks are those that make no sense in a 
standalone back end,
 such as a mark that says whether an article is stored in the cache
 \(which doesn't make sense in a standalone back end).")
 
-(defvar gnus-headers-retrieved-by nil
-  "Holds the return value of `gnus-retrieve-headers'.
-This is either the symbol `nov' or the symbol `headers'.  This
-value is checked during the summary creation process, when
-building threads.  A value of `nov' indicates that header
-retrieval is relatively cheap and threading is encouraged to
-include more old articles.  A value of `headers' indicates that
-retrieval is expensive and should be minimized.")
+(defvar gnus-headers-retrieved-by nil)
 (defvar gnus-article-reply nil)
 (defvar gnus-override-method nil)
 (defvar gnus-opened-servers nil)
diff --git a/lisp/gnus/nnvirtual.el b/lisp/gnus/nnvirtual.el
index ba29343..1e2feda 100644
--- a/lisp/gnus/nnvirtual.el
+++ b/lisp/gnus/nnvirtual.el
@@ -101,10 +101,15 @@ It is computed from the marks of individual component 
groups.")
       (erase-buffer)
       (if (stringp (car articles))
          'headers
-       (let ((carticles (nnvirtual-partition-sequence articles))
+       (let ((vbuf (nnheader-set-temp-buffer
+                    (gnus-get-buffer-create " *virtual headers*")))
+             (carticles (nnvirtual-partition-sequence articles))
              (sysname (system-name))
-             cgroup headers all-headers article prefix)
-         (pcase-dolist (`(,cgroup . ,articles) carticles)
+             cgroup carticle article result prefix)
+         (while carticles
+           (setq cgroup (caar carticles))
+           (setq articles (cdar carticles))
+           (pop carticles)
            (when (and articles
                       (gnus-check-server
                        (gnus-find-method-for-group cgroup) t)
@@ -114,37 +119,69 @@ It is computed from the marks of individual component 
groups.")
                       ;; This is probably evil if people have set
                       ;; gnus-use-cache to nil themselves, but I
                       ;; have no way of finding the true value of it.
-                      (let ((gnus-use-cache t)
-                            (gnus-newsgroup-name cgroup)
-                            (gnus-fetch-old-headers nil))
-                        (setq headers (gnus-fetch-headers articles))))
-             (erase-buffer)
-             ;; Remove all header article numbers from `articles'.
-             ;; If there's anything left, those are expired or
-             ;; canceled articles, so we update the component group
-             ;; below.
-             (dolist (h headers)
-               (setq articles (delq (mail-header-number h) articles)
-                     article (nnvirtual-reverse-map-article
-                              cgroup (mail-header-number h)))
-               ;; Update all the header numbers according to their
-               ;; reverse mapping, and drop any with no such mapping.
-               (when article
-                 ;; Do this first, before we re-set the header's
-                 ;; article number.
-                 (nnvirtual-update-xref-header
-                  h cgroup prefix sysname)
-                 (setf (mail-header-number h) article)
-                 (push h all-headers)))
-             ;; Anything left in articles is expired or canceled.
-             ;; Could be smart and not tell it about articles already
-             ;; known?
-             (when articles
-               (gnus-group-make-articles-read cgroup articles))))
-
-         (sort all-headers (lambda (h1 h2)
-                             (< (mail-header-number h1)
-                                (mail-header-number h2)))))))))
+                      (let ((gnus-use-cache t))
+                        (setq result (gnus-retrieve-headers
+                                      articles cgroup nil))))
+             (set-buffer nntp-server-buffer)
+             ;; If we got HEAD headers, we convert them into NOV
+             ;; headers.  This is slow, inefficient and, come to think
+             ;; of it, downright evil.  So sue me.  I couldn't be
+             ;; bothered to write a header parse routine that could
+             ;; parse a mixed HEAD/NOV buffer.
+             (when (eq result 'headers)
+               (nnvirtual-convert-headers))
+             (goto-char (point-min))
+             (while (not (eobp))
+               (delete-region (point)
+                              (progn
+                                (setq carticle (read nntp-server-buffer))
+                                (point)))
+
+               ;; We remove this article from the articles list, if
+               ;; anything is left in the articles list after going through
+               ;; the entire buffer, then those articles have been
+               ;; expired or canceled, so we appropriately update the
+               ;; component group below.  They should be coming up
+               ;; generally in order, so this shouldn't be slow.
+               (setq articles (delq carticle articles))
+
+               (setq article (nnvirtual-reverse-map-article cgroup carticle))
+               (if (null article)
+                   ;; This line has no reverse mapping, that means it
+                   ;; was an extra article reference returned by nntp.
+                   (progn
+                     (beginning-of-line)
+                     (delete-region (point) (progn (forward-line 1) (point))))
+                 ;; Otherwise insert the virtual article number,
+                 ;; and clean up the xrefs.
+                 (princ article nntp-server-buffer)
+                 (nnvirtual-update-xref-header cgroup carticle
+                                               prefix sysname)
+                 (forward-line 1))
+               )
+
+             (set-buffer vbuf)
+             (goto-char (point-max))
+             (insert-buffer-substring nntp-server-buffer))
+           ;; Anything left in articles is expired or canceled.
+           ;; Could be smart and not tell it about articles already known?
+           (when articles
+             (gnus-group-make-articles-read cgroup articles))
+           )
+
+         ;; The headers are ready for reading, so they are inserted into
+         ;; the nntp-server-buffer, which is where Gnus expects to find
+         ;; them.
+         (prog1
+             (with-current-buffer nntp-server-buffer
+               (erase-buffer)
+               (insert-buffer-substring vbuf)
+               ;; FIX FIX FIX, we should be able to sort faster than
+               ;; this if needed, since each cgroup is sorted, we just
+               ;; need to merge
+               (sort-numeric-fields 1 (point-min) (point-max))
+               'nov)
+           (kill-buffer vbuf)))))))
 
 
 (defvoo nnvirtual-last-accessed-component-group nil)
@@ -335,18 +372,61 @@ It is computed from the marks of individual component 
groups.")
 
 ;;; Internal functions.
 
-(defun nnvirtual-update-xref-header (header group prefix sysname)
-  "Add xref to component GROUP to HEADER.
-Also add a server PREFIX any existing xref lines."
-  (let ((bits (split-string (mail-header-xref header)
-                           nil t "[[:blank:]]"))
-       (art-no (mail-header-number header)))
-    (setf (mail-header-xref header)
-         (concat
-          (format "%s %s:%d " sysname group art-no)
-          (mapconcat (lambda (bit)
-                       (concat prefix bit))
-                     bits " ")))))
+(defun nnvirtual-convert-headers ()
+  "Convert HEAD headers into NOV headers."
+  (with-current-buffer nntp-server-buffer
+    (let* ((dependencies (make-hash-table :test #'equal))
+          (headers (gnus-get-newsgroup-headers dependencies)))
+      (erase-buffer)
+      (mapc 'nnheader-insert-nov headers))))
+
+
+(defun nnvirtual-update-xref-header (group article prefix sysname)
+  "Edit current NOV header in current buffer to have an xref to the component 
group, and also server prefix any existing xref lines."
+  ;; Move to beginning of Xref field, creating a slot if needed.
+  (beginning-of-line)
+  (looking-at
+   "[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t")
+  (goto-char (match-end 0))
+  (unless (search-forward "\t" (point-at-eol) 'move)
+    (insert "\t"))
+
+  ;; Remove any spaces at the beginning of the Xref field.
+  (while (eq (char-after (1- (point))) ? )
+    (forward-char -1)
+    (delete-char 1))
+
+  (insert "Xref: " sysname " " group ":")
+  (princ article (current-buffer))
+  (insert " ")
+
+  ;; If there were existing xref lines, clean them up to have the correct
+  ;; component server prefix.
+  (save-restriction
+    (narrow-to-region (point)
+                     (or (search-forward "\t" (point-at-eol) t)
+                         (point-at-eol)))
+    (goto-char (point-min))
+    (when (re-search-forward "Xref: *[^\n:0-9 ]+ *" nil t)
+      (replace-match "" t t))
+    (goto-char (point-min))
+    (when (re-search-forward
+          (concat (regexp-quote (gnus-group-real-name group)) ":[0-9]+")
+          nil t)
+      (replace-match "" t t))
+    (unless (eobp)
+      (insert " ")
+      (when (not (string= "" prefix))
+       (while (re-search-forward "[^ ]+:[0-9]+" nil t)
+         (save-excursion
+           (goto-char (match-beginning 0))
+           (insert prefix))))))
+
+  ;; Ensure a trailing \t.
+  (end-of-line)
+  (or (eq (char-after (1- (point))) ?\t)
+      (insert ?\t)))
+
 
 (defun nnvirtual-possibly-change-server (server)
   (or (not server)
diff --git a/lisp/image/gravatar.el b/lisp/image/gravatar.el
index 4f37834..f6f056a 100644
--- a/lisp/image/gravatar.el
+++ b/lisp/image/gravatar.el
@@ -160,16 +160,19 @@ to track whether you're reading a specific mail."
                 (cond
                  ((and
                    result               ;there is a result
-                   (let* ((data (mapcar (lambda (record)
+                   (let* ((answers (dns-get 'answers result))
+                          (data (mapcar (lambda (record)
                                           (dns-get 'data (cdr record)))
-                                        (dns-get 'answers result)))
+                                        ;; We may get junk data back (or CNAME;
+                                        ;; ignore).
+                                        (and (eq (dns-get 'type answers) 'SRV)
+                                             answers)))
                           (priorities (mapcar (lambda (r)
                                                 (dns-get 'priority r))
                                               data))
-                          (max-priority (if priorities
-                                            (apply #'max priorities)
-                                          0))
-                          (sum 0) top)
+                          (max-priority (apply #'max 0 priorities))
+                          (sum 0)
+                          top)
                      ;; Attempt to find all records with the same maximal
                      ;; priority, and calculate the sum of their weights.
                      (dolist (ent data)
diff --git a/lisp/international/isearch-x.el b/lisp/international/isearch-x.el
index 400421d..b890bde 100644
--- a/lisp/international/isearch-x.el
+++ b/lisp/international/isearch-x.el
@@ -1,4 +1,4 @@
-;;; isearch-x.el --- extended isearch handling commands
+;;; isearch-x.el --- extended isearch handling commands  -*- lexical-binding: 
t; -*-
 
 ;; Copyright (C) 1997, 2001-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
@@ -67,7 +67,7 @@
 
 ;; Exit from recursive edit safely.  Set in `after-change-functions'
 ;; by isearch-with-keyboard-coding.
-(defun isearch-exit-recursive-edit (start end length)
+(defun isearch-exit-recursive-edit (_start _end _length)
   (interactive)
   (throw 'exit nil))
 
@@ -102,6 +102,7 @@
 
 ;;;###autoload
 (defun isearch-process-search-multibyte-characters (last-char &optional count)
+  (defvar junk-hist)
   (if (eq this-command 'isearch-printing-char)
       (let ((overriding-terminal-local-map nil)
            (prompt (isearch-message-prefix))
diff --git a/lisp/international/iso-cvt.el b/lisp/international/iso-cvt.el
index 3f3843e..ead7c8a 100644
--- a/lisp/international/iso-cvt.el
+++ b/lisp/international/iso-cvt.el
@@ -1,4 +1,4 @@
-;;; iso-cvt.el --- translate ISO 8859-1 from/to various encodings -*- coding: 
utf-8 -*-
+;;; iso-cvt.el --- translate ISO 8859-1 from/to various encodings -*- 
lexical-binding: t; -*-
 ;; This file was formerly called gm-lingo.el.
 
 ;; Copyright (C) 1993-1998, 2000-2021 Free Software Foundation, Inc.
@@ -79,7 +79,7 @@
       (point-max))))
 
 ;;;###autoload
-(defun iso-spanish (from to &optional buffer)
+(defun iso-spanish (from to &optional _buffer)
   "Translate net conventions for Spanish to ISO 8859-1.
 Translate the region between FROM and TO using the table
 `iso-spanish-trans-tab'.
@@ -121,7 +121,7 @@ and may translate too little.")
   "Currently active translation table for German.")
 
 ;;;###autoload
-(defun iso-german (from to &optional buffer)
+(defun iso-german (from to &optional _buffer)
  "Translate net conventions for German to ISO 8859-1.
 Translate the region FROM and TO using the table
 `iso-german-trans-tab'.
@@ -194,7 +194,7 @@ Optional arg BUFFER is ignored (for use in `format-alist')."
   "Translation table for translating ISO 8859-1 characters to TeX sequences.")
 
 ;;;###autoload
-(defun iso-iso2tex (from to &optional buffer)
+(defun iso-iso2tex (from to &optional _buffer)
  "Translate ISO 8859-1 characters to TeX sequences.
 Translate the region between FROM and TO using the table
 `iso-iso2tex-trans-tab'.
@@ -387,7 +387,7 @@ This table is not exhaustive (and due to TeX's power can 
never be).
 It only contains commonly used sequences.")
 
 ;;;###autoload
-(defun iso-tex2iso (from to &optional buffer)
+(defun iso-tex2iso (from to &optional _buffer)
  "Translate TeX sequences to ISO 8859-1 characters.
 Translate the region between FROM and TO using the table
 `iso-tex2iso-trans-tab'.
@@ -646,7 +646,7 @@ It only contains commonly used sequences.")
   "Translation table for translating ISO 8859-1 characters to German TeX.")
 
 ;;;###autoload
-(defun iso-gtex2iso (from to &optional buffer)
+(defun iso-gtex2iso (from to &optional _buffer)
  "Translate German TeX sequences to ISO 8859-1 characters.
 Translate the region between FROM and TO using the table
 `iso-gtex2iso-trans-tab'.
@@ -655,7 +655,7 @@ Optional arg BUFFER is ignored (for use in `format-alist')."
  (iso-translate-conventions from to iso-gtex2iso-trans-tab))
 
 ;;;###autoload
-(defun iso-iso2gtex (from to &optional buffer)
+(defun iso-iso2gtex (from to &optional _buffer)
  "Translate ISO 8859-1 characters to German TeX sequences.
 Translate the region between FROM and TO using the table
 `iso-iso2gtex-trans-tab'.
@@ -674,7 +674,7 @@ Optional arg BUFFER is ignored (for use in `format-alist')."
     "Translation table for translating ISO 8859-1 characters to Duden 
sequences.")
 
 ;;;###autoload
-(defun iso-iso2duden (from to &optional buffer)
+(defun iso-iso2duden (from to &optional _buffer)
  "Translate ISO 8859-1 characters to Duden sequences.
 Translate the region between FROM and TO using the table
 `iso-iso2duden-trans-tab'.
@@ -812,7 +812,7 @@ Optional arg BUFFER is ignored (for use in `format-alist')."
     ("&yuml;" "ÿ")))
 
 ;;;###autoload
-(defun iso-iso2sgml (from to &optional buffer)
+(defun iso-iso2sgml (from to &optional _buffer)
  "Translate ISO 8859-1 characters in the region to SGML entities.
 Use entities from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
 Optional arg BUFFER is ignored (for use in `format-alist')."
@@ -820,7 +820,7 @@ Optional arg BUFFER is ignored (for use in `format-alist')."
  (iso-translate-conventions from to iso-iso2sgml-trans-tab))
 
 ;;;###autoload
-(defun iso-sgml2iso (from to &optional buffer)
+(defun iso-sgml2iso (from to &optional _buffer)
  "Translate SGML entities in the region to ISO 8859-1 characters.
 Use entities from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
 Optional arg BUFFER is ignored (for use in `format-alist')."
@@ -828,13 +828,13 @@ Optional arg BUFFER is ignored (for use in 
`format-alist')."
  (iso-translate-conventions from to iso-sgml2iso-trans-tab))
 
 ;;;###autoload
-(defun iso-cvt-read-only (&rest ignore)
+(defun iso-cvt-read-only (&rest _ignore)
   "Warn that format is read-only."
   (interactive)
   (error "This format is read-only; specify another format for writing"))
 
 ;;;###autoload
-(defun iso-cvt-write-only (&rest ignore)
+(defun iso-cvt-write-only (&rest _ignore)
   "Warn that format is write-only."
   (interactive)
   (error "This format is write-only"))
diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-cnv.el
index b805904..3be7849 100644
--- a/lisp/international/ja-dic-cnv.el
+++ b/lisp/international/ja-dic-cnv.el
@@ -1,4 +1,4 @@
-;;; ja-dic-cnv.el --- convert a Japanese dictionary (SKK-JISYO.L) to Emacs Lisp
+;;; ja-dic-cnv.el --- convert a Japanese dictionary (SKK-JISYO.L) to Emacs 
Lisp  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2001-2021 Free Software Foundation, Inc.
 
@@ -96,7 +96,7 @@
     ("もく" "目")
     ("ゆき" "行")))
 
-(defun skkdic-convert-postfix (skkbuf buf)
+(defun skkdic-convert-postfix (_skkbuf buf)
   (byte-compile-info "Processing POSTFIX entries" t)
   (goto-char (point-min))
   (with-current-buffer buf
@@ -150,7 +150,7 @@
 
 (defconst skkdic-prefix-list '(skkdic-prefix-list))
 
-(defun skkdic-convert-prefix (skkbuf buf)
+(defun skkdic-convert-prefix (_skkbuf buf)
   (byte-compile-info "Processing PREFIX entries" t)
   (goto-char (point-min))
   (with-current-buffer buf
@@ -209,7 +209,7 @@
                                    (substring str from idx)
                                    skkdic-word-list)))
                   (if (or (and (consp kana2-list)
-                               (let ((kana-len (length kana))
+                               (let (;; (kana-len (length kana))
                                      kana2)
                                  (catch 'skkdic-tag
                                    (while kana2-list
@@ -342,7 +342,8 @@ The name of generated file is specified by the variable 
`ja-dic-filename'."
     (with-current-buffer buf
       (erase-buffer)
       (buffer-disable-undo)
-      (insert ";;; ja-dic.el --- dictionary for Japanese input method\n"
+      (insert ";;; ja-dic.el --- dictionary for Japanese input method"
+             "  -*- lexical-binding:t -*-\n"
              ";;\tGenerated by the command `skkdic-convert'\n"
              ";;\tOriginal SKK dictionary file: "
              (file-relative-name (expand-file-name filename) dirname)
diff --git a/lisp/international/ja-dic-utl.el b/lisp/international/ja-dic-utl.el
index 498fb23..cc63698 100644
--- a/lisp/international/ja-dic-utl.el
+++ b/lisp/international/ja-dic-utl.el
@@ -1,4 +1,4 @@
-;;; ja-dic-utl.el --- utilities for handling Japanese dictionary (SKK-JISYO.L)
+;;; ja-dic-utl.el --- utilities for handling Japanese dictionary (SKK-JISYO.L) 
 -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
diff --git a/lisp/international/kinsoku.el b/lisp/international/kinsoku.el
index cd740ac..05179a9 100644
--- a/lisp/international/kinsoku.el
+++ b/lisp/international/kinsoku.el
@@ -1,4 +1,4 @@
-;;; kinsoku.el --- `Kinsoku' processing funcs
+;;; kinsoku.el --- `Kinsoku' processing funcs  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1997, 2001-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
diff --git a/lisp/international/kkc.el b/lisp/international/kkc.el
index 290f4fa..87f7389 100644
--- a/lisp/international/kkc.el
+++ b/lisp/international/kkc.el
@@ -1,4 +1,4 @@
-;;; kkc.el --- Kana Kanji converter
+;;; kkc.el --- Kana Kanji converter  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-1998, 2001-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
diff --git a/lisp/international/latexenc.el b/lisp/international/latexenc.el
index e2ee3fb..ff7cddc 100644
--- a/lisp/international/latexenc.el
+++ b/lisp/international/latexenc.el
@@ -1,4 +1,4 @@
-;;; latexenc.el --- guess correct coding system in LaTeX files -*-coding: 
utf-8 -*-
+;;; latexenc.el --- guess correct coding system in LaTeX files -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 2005-2021 Free Software Foundation, Inc.
 
@@ -109,6 +109,8 @@ Return nil if no matching input encoding can be found."
 (defvar latexenc-dont-use-tex-guess-main-file-flag nil
   "Non-nil means don't use tex-guessmain-file to find the coding system.")
 
+(defvar tex-start-of-header)
+
 ;;;###autoload
 (defun latexenc-find-file-coding-system (arg-list)
   "Determine the coding system of a LaTeX file if it uses \"inputenc.sty\".
diff --git a/lisp/international/latin1-disp.el 
b/lisp/international/latin1-disp.el
index bda2c51..4b6ef98 100644
--- a/lisp/international/latin1-disp.el
+++ b/lisp/international/latin1-disp.el
@@ -1,4 +1,4 @@
-;;; latin1-disp.el --- display tables for other ISO 8859 on Latin-1 terminals 
-*-coding: utf-8;-*-
+;;; latin1-disp.el --- display tables for other ISO 8859 on Latin-1 terminals 
-*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2000-2021 Free Software Foundation, Inc.
 
@@ -86,8 +86,8 @@ use either \\[customize] or the function `latin1-display'."
   :group 'latin1-display
   :type 'boolean
   :require 'latin1-disp
-  :initialize 'custom-initialize-default
-  :set (lambda (symbol value)
+  :initialize #'custom-initialize-default
+  :set (lambda (_symbol value)
         (if value
             (apply #'latin1-display latin1-display-sets)
           (latin1-display))))
@@ -186,7 +186,7 @@ character set."
                     'arabic-iso8859-6
                   (car (remq 'ascii (get-language-info language
                                                        'charset))))))
-    (map-charset-chars #'(lambda (range arg)
+    (map-charset-chars #'(lambda (range _arg)
                           (standard-display-default (car range) (cdr range)))
                       charset))
   (sit-for 0))
@@ -201,11 +201,10 @@ character set: `latin-2', `hebrew' etc."
         (char (and info (decode-char (car (remq 'ascii info)) ?\ ))))
     (and char (char-displayable-p char))))
 
-(defun latin1-display-setup (set &optional force)
+(defun latin1-display-setup (set &optional _force)
   "Set up Latin-1 display for characters in the given SET.
 SET must be a member of `latin1-display-sets'.  Normally, check
-whether a font for SET is available and don't set the display if it
-is.  If FORCE is non-nil, set up the display regardless."
+whether a font for SET is available and don't set the display if it is."
   (cond
    ((eq set 'latin-2)
     (latin1-display-identities set)
@@ -735,7 +734,7 @@ is.  If FORCE is non-nil, set up the display regardless."
   (sit-for 0))
 
 ;;;###autoload
-(defcustom latin1-display-ucs-per-lynx nil
+(defcustom latin1-display-ucs-per-lynx nil ;FIXME: Isn't this a minor mode?
   "Set up Latin-1/ASCII display for Unicode characters.
 This uses the transliterations of the Lynx browser.  The display isn't
 changed if the display can render Unicode characters.
@@ -745,8 +744,8 @@ use either \\[customize] or the function `latin1-display'."
   :group 'latin1-display
   :type 'boolean
   :require 'latin1-disp
-  :initialize 'custom-initialize-default
-  :set (lambda (symbol value)
+  :initialize #'custom-initialize-default
+  :set (lambda (_symbol value)
         (if value
             (latin1-display-ucs-per-lynx 1)
           (latin1-display-ucs-per-lynx -1))))
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 347e678..8202c3e 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -1279,7 +1279,7 @@ in the format of Lisp expression for registering each 
input method.
 Emacs loads this file at startup time.")
 
 (defconst leim-list-header (format-message
-";;; %s -- list of LEIM (Library of Emacs Input Method) -*-coding: utf-8;-*-
+";;; %s --- list of LEIM (Library of Emacs Input Method)  -*- 
lexical-binding:t -*-
 ;;
 ;; This file is automatically generated.
 ;;
diff --git a/lisp/international/mule-diag.el b/lisp/international/mule-diag.el
index d622268..d97d090 100644
--- a/lisp/international/mule-diag.el
+++ b/lisp/international/mule-diag.el
@@ -1,4 +1,4 @@
-;;; mule-diag.el --- show diagnosis of multilingual environment (Mule)
+;;; mule-diag.el --- show diagnosis of multilingual environment (Mule)  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-1998, 2000-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
@@ -86,8 +86,7 @@ but still shows the full information."
        (indent-to 48)
        (insert "| +--CHARS\n")
        (let ((columns '(("CHARSET-NAME" . name) "\t\t\t\t\t"
-                        ("D CH  FINAL-BYTE" . iso-spec)))
-             pos)
+                        ("D CH  FINAL-BYTE" . iso-spec))))
          (while columns
            (if (stringp (car columns))
                (insert (car columns))
@@ -117,8 +116,8 @@ but still shows the full information."
 SORT-KEY should be `name' or `iso-spec' (default `name')."
   (or sort-key
       (setq sort-key 'name))
-  (let ((tail charset-list)
-       charset-info-list supplementary-list charset sort-func)
+  (let (;; (tail charset-list)
+       charset-info-list supplementary-list sort-func)
     (dolist (charset charset-list)
       ;; Generate a list that contains all information to display.
       (let ((elt (list charset
@@ -273,9 +272,9 @@ meanings of these arguments."
       (setq tab-width 4)
       (set-buffer-multibyte t)
       (let ((dim (charset-dimension charset))
-           (chars (charset-chars charset))
-           ;;  (plane (charset-iso-graphic-plane charset))
-           (plane 1)
+           ;; (chars (charset-chars charset))
+           ;; (plane (charset-iso-graphic-plane charset))
+           ;; (plane 1)
            (range (plist-get (charset-plist charset) :code-space))
            min max min2 max2)
        (if (> dim 2)
@@ -415,7 +414,8 @@ or provided just for backward compatibility." nil)))
       (print-coding-system-briefly coding-system 'doc-string)
       (let ((type (coding-system-type coding-system))
            ;; Fixme: use this
-           (extra-spec (coding-system-plist coding-system)))
+           ;; (extra-spec (coding-system-plist coding-system))
+           )
        (princ "Type: ")
        (princ type)
        (cond ((eq type 'undecided)
@@ -858,6 +858,8 @@ The IGNORED argument is ignored."
       (with-output-to-temp-buffer "*Help*"
        (describe-font-internal font-info)))))
 
+(defvar mule--print-opened)
+
 (defun print-fontset-element (val)
   ;; VAL has this format:
   ;;  ((REQUESTED-FONT-NAME OPENED-FONT-NAME ...) ...)
@@ -915,7 +917,7 @@ The IGNORED argument is ignored."
                             (or adstyle "*") registry)))))
 
        ;; Insert opened font names (if any).
-       (if (and (boundp 'print-opened) (symbol-value 'print-opened))
+       (if (bound-and-true-p mule--print-opened)
            (dolist (opened (cdr elt))
              (insert "\n\t[" opened "]")))))))
 
@@ -943,8 +945,9 @@ the current buffer."
          " and [" (propertize "OPENED" 'face 'underline) "])")
   (let* ((info (fontset-info fontset))
         (default-info (char-table-extra-slot info 0))
+        (mule--print-opened print-opened)
         start1 end1 start2 end2)
-    (describe-vector info 'print-fontset-element)
+    (describe-vector info #'print-fontset-element)
     (when (char-table-range info nil)
       ;; The default of FONTSET is described.
       (setq start1 (re-search-backward "^default"))
@@ -956,7 +959,7 @@ the current buffer."
     (when default-info
       (insert "\n  ---<fallback to the default fontset>---")
       (put-text-property (line-beginning-position) (point) 'face 'highlight)
-      (describe-vector default-info 'print-fontset-element)
+      (describe-vector default-info #'print-fontset-element)
       (when (char-table-range default-info nil)
        ;; The default of the default fontset is described.
        (setq end2 (re-search-backward "^default"))
diff --git a/lisp/international/ogonek.el b/lisp/international/ogonek.el
index 79e4468..e049832 100644
--- a/lisp/international/ogonek.el
+++ b/lisp/international/ogonek.el
@@ -1,4 +1,4 @@
-;;; ogonek.el --- change the encoding of Polish diacritics
+;;; ogonek.el --- change the encoding of Polish diacritics  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-1998, 2001-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/international/quail.el b/lisp/international/quail.el
index f2ac44a..0901115 100644
--- a/lisp/international/quail.el
+++ b/lisp/international/quail.el
@@ -1,4 +1,4 @@
-;;; quail.el --- provides simple input method for multilingual text
+;;; quail.el --- provides simple input method for multilingual text  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-1998, 2000-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
@@ -1046,7 +1046,7 @@ the following annotation types are supported.
           (quail-install-decode-map ',decode-map))))))
 
 ;;;###autoload
-(defun quail-install-map (map &optional name)
+(defun quail-install-map (map &optional _name)
   "Install the Quail map MAP in the current Quail package.
 
 Optional 2nd arg NAME, if non-nil, is a name of Quail package for
@@ -1060,7 +1060,7 @@ The installed map can be referred by the function 
`quail-map'."
   (setcar (cdr (cdr quail-current-package)) map))
 
 ;;;###autoload
-(defun quail-install-decode-map (decode-map &optional name)
+(defun quail-install-decode-map (decode-map &optional _name)
   "Install the Quail decode map DECODE-MAP in the current Quail package.
 
 Optional 2nd arg NAME, if non-nil, is a name of Quail package for
@@ -1390,7 +1390,7 @@ Return the input string."
       (let* ((echo-keystrokes 0)
             (help-char nil)
             (overriding-terminal-local-map (quail-translation-keymap))
-            (generated-events nil)     ;FIXME: What is this?
+            ;; (generated-events nil)     ;FIXME: What is this?
             (input-method-function nil)
             (modified-p (buffer-modified-p))
             last-command-event last-command this-command inhibit-record)
@@ -1455,7 +1455,7 @@ Return the input string."
       (let* ((echo-keystrokes 0)
             (help-char nil)
             (overriding-terminal-local-map (quail-conversion-keymap))
-            (generated-events nil)     ;FIXME: What is this?
+            ;; (generated-events nil)     ;FIXME: What is this?
             (input-method-function nil)
             (modified-p (buffer-modified-p))
             last-command-event last-command this-command inhibit-record)
@@ -2452,7 +2452,7 @@ should be made by `quail-build-decode-map' (which see)."
               (insert-char ?- single-trans-width)
               (forward-line 1)
               ;; Insert the key-tran pairs.
-              (dotimes (row rows)
+              (dotimes (_ rows)
                 (let ((elt (pop single-list)))
                   (when elt
                     (move-to-column col)
@@ -2625,12 +2625,14 @@ KEY BINDINGS FOR CONVERSION
        (run-hooks 'temp-buffer-show-hook)))))
 
 (defun quail-help-insert-keymap-description (keymap &optional header)
+  (defvar the-keymap)
   (let ((pos1 (point))
+        (the-keymap keymap)
         pos2)
     (if header
        (insert header))
     (save-excursion
-      (insert (substitute-command-keys "\\{keymap}")))
+      (insert (substitute-command-keys "\\{the-keymap}")))
     ;; Skip headers "key bindings", etc.
     (forward-line 3)
     (setq pos2 (point))
@@ -3011,7 +3013,7 @@ of each directory."
 
     ;; At first, clean up the file.
     (with-current-buffer list-buf
-      (goto-char 1)
+      (goto-char (point-min))
 
       ;; Insert the correct header.
       (if (looking-at (regexp-quote leim-list-header))
diff --git a/lisp/international/robin.el b/lisp/international/robin.el
index 16cac07..55390df 100644
--- a/lisp/international/robin.el
+++ b/lisp/international/robin.el
@@ -1,4 +1,4 @@
-;;; robin.el --- yet another input method (smaller than quail)
+;;; robin.el --- yet another input method (smaller than quail)  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/international/titdic-cnv.el b/lisp/international/titdic-cnv.el
index 58c81bf..64d6644 100644
--- a/lisp/international/titdic-cnv.el
+++ b/lisp/international/titdic-cnv.el
@@ -1,4 +1,4 @@
-;;; titdic-cnv.el --- convert cxterm dictionary (TIT format) to Quail package 
-*- coding:iso-2022-7bit; lexical-binding:t -*-
+;;; titdic-cnv.el --- convert cxterm dictionary (TIT format) to Quail package 
-*- coding: utf-8-emacs; lexical-binding:t -*-
 
 ;; Copyright (C) 1997-1998, 2000-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
@@ -83,9 +83,9 @@
 ;; how to select a translation from a list of candidates.
 
 (defvar quail-cxterm-package-ext-info
-  '(("chinese-4corner" "$(0(?-F(B")
-    ("chinese-array30" "$(0#R#O(B")
-    ("chinese-ccdospy" "$AKuF4(B"
+  '(("chinese-4corner" "四角")
+    ("chinese-array30" "30")
+    ("chinese-ccdospy" "缩拼"
      "Pinyin base input method for Chinese charset GB2312 (`chinese-gb2312').
 
 Pinyin is the standard Roman transliteration method for Chinese.
@@ -94,10 +94,10 @@ method `chinese-py'.
 
 This input method works almost the same way as `chinese-py'.  The
 difference is that you type a single key for these Pinyin spelling.
-    Pinyin:  zh  en  eng ang ch  an  ao  ai  ong sh  ing  yu($A(9(B)
+    Pinyin:  zh  en  eng ang ch  an  ao  ai  ong sh  ing  yu(ü)
     keyseq:   a   f   g   h   i   j   k   l   s   u   y   v
 For example:
-    Chinese:  $A0!(B    $A9{(B    $AVP(B    $AND(B    $A9b(B    
$ASq(B    $AH+(B
+    Chinese:  啊    果    中    文    光    玉    全
     Pinyin:   a    guo   zhong  wen  guang  yu   quan
     Keyseq:   a1   guo4   as1   wf4  guh1  yu..6 qvj6
 
@@ -106,14 +106,14 @@ For example:
 For double-width GB2312 characters corresponding to ASCII, use the
 input method `chinese-qj'.")
 
-    ("chinese-ecdict" "$(05CKH(B"
+    ("chinese-ecdict" "英漢"
 "In this input method, you enter a Chinese (Big5) character or word
 by typing the corresponding English word.  For example, if you type
-\"computer\", \"$(0IZH+(B\" is input.
+\"computer\", \"電腦\" is input.
 
 \\<quail-translation-docstring>")
 
-    ("chinese-etzy" "$(06/0D(B"
+    ("chinese-etzy" "倚注"
 "Zhuyin base input method for Chinese Big5 characters (`chinese-big5-1',
 `chinese-big5-2').
 
@@ -122,20 +122,20 @@ compose one Chinese character.
 
 In this input method, you enter a Chinese character by first typing
 keys corresponding to Zhuyin symbols (see the above table) followed by
-SPC, 1, 2, 3, or 4 specifying a tone (SPC:$(0?v(N(B, 1:$(0M=Vy(B, 
2:$(0Dm(N(B, 3: $(0&9Vy(B,
-4:$(0(+Vy(B).
+SPC, 1, 2, 3, or 4 specifying a tone (SPC:陰平, 1:輕聲, 2:陽平, 3: 上聲,
+4:去聲).
 
 \\<quail-translation-docstring>")
 
-    ("chinese-punct-b5" "$(0O:(BB"
+    ("chinese-punct-b5" "標B"
      "Input method for Chinese punctuation and symbols of Big5
 \(`chinese-big5-1' and `chinese-big5-2').")
 
-    ("chinese-punct" "$A1j(BG"
+    ("chinese-punct" "标G"
      "Input method for Chinese punctuation and symbols of GB2312
 \(`chinese-gb2312').")
 
-    ("chinese-py-b5" "$(03<(BB"
+    ("chinese-py-b5" "拼B"
      "Pinyin base input method for Chinese Big5 characters
 \(`chinese-big5-1', `chinese-big5-2').
 
@@ -153,28 +153,28 @@ method `chinese-qj-b5'.
 The input method `chinese-py' and `chinese-tonepy' are also Pinyin
 based, but for the character set GB2312 (`chinese-gb2312').")
 
-    ("chinese-qj-b5" "$(0)A(BB")
+    ("chinese-qj-b5" "全B")
 
-    ("chinese-qj" "$AH+(BG")
+    ("chinese-qj" "全G")
 
-    ("chinese-sw" "$AJWN2(B"
+    ("chinese-sw" "首尾"
 "Radical base input method for Chinese charset GB2312 (`chinese-gb2312').
 
 In this input method, you enter a Chinese character by typing two
-keys.  The first key corresponds to the first ($AJW(B) radical, the second
-key corresponds to the last ($AN2(B) radical.  The correspondence of keys
+keys.  The first key corresponds to the first (首) radical, the second
+key corresponds to the last (尾) radical.  The correspondence of keys
 and radicals is as below:
 
  first radical:
  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z
- $APD(B $AZ"(B $AJ,(B $AX<(B $A;p(B $A?Z(B $A^P(B $Ac_(B 
$AZ%(B $A\3(B $AXi(B $AD>(B $Alj(B $Ab;(B $ATB(B $Afy(B 
$AJ/(B $AMu(B $A0K(B $AX/(B $AHU(B $AeA(B $Aak(B $AVq(B 
$AR;(B $AHK(B
+ 心 冖 尸 丶 火 口 扌 氵 讠 艹 亻 木 礻 饣 月 纟 石 王 八 丿 日 辶 犭 竹 一 人
  last radical:
  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z
- $ASV(B $AI=(B $AMA(B $A56(B $AZb(B $A?Z(B $ARB(B $Aqb(B 
$A4s(B $A6!(B $A[L(B $Ala(B $AJ.(B $A4u(B $AXg(B $ACE(B 
$A=q(B $AX-(B $AE.(B $ARR(B $A`m(B $AP!(B $A3'(B $A3f(B 
$A_.(B $A27(B
+ 又 山 土 刀 阝 口 衣 疋 大 丁 厶 灬 十 歹 冂 门 今 丨 女 乙 囗 小 厂 虫 弋 卜
 
 \\<quail-translation-docstring>")
 
-    ("chinese-tonepy" "$A5wF4(B"
+    ("chinese-tonepy" "调拼"
      "Pinyin base input method for Chinese charset GB2312 (`chinese-gb2312').
 
 Pinyin is the standard roman transliteration method for Chinese.
@@ -183,18 +183,18 @@ method `chinese-py'.
 
 This input method works almost the same way as `chinese-py'.  The
 difference is that you must type 1..5 after each Pinyin spelling to
-specify a tone (1:$ARuF=(B, 2:$AQtF=(B, 3:$AIOIy(B, 4$AOBIy(B, 
5:$AGaIy(B).
+specify a tone (1:阴平, 2:阳平, 3:上声, 4下声, 5:轻声).
 
 \\<quail-translation-docstring>
 
-For instance, to input $ADc(B, you type \"n i 3 3\", the first \"n i\" is
+For instance, to input 你, you type \"n i 3 3\", the first \"n i\" is
 a Pinyin, the next \"3\" specifies tone, and the last \"3\" selects
 the third character from the candidate list.
 
 For double-width GB2312 characters corresponding to ASCII, use the
 input method `chinese-qj'.")
 
-    ("chinese-zozy" "$(0I\0D(B"
+    ("chinese-zozy" "零注"
 "Zhuyin base input method for Chinese Big5 characters (`chinese-big5-1',
 `chinese-big5-2').
 
@@ -203,8 +203,8 @@ compose a Chinese character.
 
 In this input method, you enter a Chinese character by first typing
 keys corresponding to Zhuyin symbols (see the above table) followed by
-SPC, 6, 3, 4, or 7 specifying a tone (SPC:$(0?v(N(B, 6:$(0Dm(N(B, 
3:$(0&9Vy(B, 4:$(0(+Vy(B,
-7:$(0M=Vy(B).
+SPC, 6, 3, 4, or 7 specifying a tone (SPC:陰平, 6:陽平, 3:上聲, 4:去聲,
+7:輕聲).
 
 \\<quail-translation-docstring>")))
 
@@ -269,6 +269,8 @@ SPC, 6, 3, 4, or 7 specifying a tone (SPC:$(0?v(N(B, 
6:$(0Dm(N(B, 3:$(0&9Vy
        (tit-moveleft ",<")
        (tit-keyprompt nil))
 
+    (princ (format ";;; %s  -*- lexical-binding:t -*-\n"
+                   (file-name-nondirectory filename)))
     (princ ";; Quail package `")
     (princ package)
     (princ "\n")
@@ -354,7 +356,7 @@ SPC, 6, 3, 4, or 7 specifying a tone (SPC:$(0?v(N(B, 
6:$(0Dm(N(B, 3:$(0&9Vy
       (princ (nth 2 (assoc tit-encode tit-encode-list)))
       (princ "\" \"")
       (princ (or title
-                (if (string-match 
"[:$A!K$(0!(!J(B]+\\([^:$A!K$(0!(!K(B]+\\)" tit-prompt)
+                (if (string-match "[:∷:【]+\\([^:∷:】]+\\)" tit-prompt)
                     (substring tit-prompt (match-beginning 1) (match-end 1))
                   tit-prompt)))
       (princ "\"\n"))
@@ -375,7 +377,7 @@ SPC, 6, 3, 4, or 7 specifying a tone (SPC:$(0?v(N(B, 
6:$(0Dm(N(B, 3:$(0&9Vy
     ;; Arg DOCSTRING
     (let ((doc (concat tit-prompt "\n"))
          (comments (if tit-comments
-                       (mapconcat 'identity (nreverse tit-comments) "\n")))
+                       (mapconcat #'identity (nreverse tit-comments) "\n")))
          (doc-ext (nth 2 (assoc package quail-cxterm-package-ext-info))))
       (if comments
          (setq doc (concat doc "\n" comments "\n")))
@@ -580,7 +582,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;;    )
 
 (defvar quail-misc-package-ext-info
-  '(("chinese-b5-tsangchi" "$(06A(BB"
+  '(("chinese-b5-tsangchi" "倉B"
      "cangjie-table.b5" big5 "tsang-b5.el"
      tsang-b5-converter
      "\
@@ -590,7 +592,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; # unmodified versions is granted without royalty provided
 ;; # this notice is preserved.")
 
-    ("chinese-b5-quick" "$(0X|(BB"
+    ("chinese-b5-quick" "簡B"
      "cangjie-table.b5" big5 "quick-b5.el"
      quick-b5-converter
      "\
@@ -600,7 +602,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; # unmodified versions is granted without royalty provided
 ;; # this notice is preserved.")
 
-    ("chinese-cns-tsangchi" "$(GT?(BC"
+    ("chinese-cns-tsangchi" "倉C"
      "cangjie-table.cns" iso-2022-cn-ext "tsang-cns.el"
      tsang-cns-converter
      "\
@@ -610,7 +612,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; # unmodified versions is granted without royalty provided
 ;; # this notice is preserved.")
 
-    ("chinese-cns-quick" "$(Gv|(BC"
+    ("chinese-cns-quick" "簡C"
      "cangjie-table.cns" iso-2022-cn-ext "quick-cns.el"
      quick-cns-converter
      "\
@@ -620,7 +622,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; # unmodified versions is granted without royalty provided
 ;; # this notice is preserved.")
 
-    ("chinese-py" "$AF4(BG"
+    ("chinese-py" "拼G"
      "pinyin.map" cn-gb-2312 "PY.el"
      py-converter
      "\
@@ -648,7 +650,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; You should have received a copy of the GNU General Public License along with
 ;; CCE.  If not, see <https://www.gnu.org/licenses/>.")
 
-    ("chinese-ziranma" "$AWTH;(B"
+    ("chinese-ziranma" "自然"
      "ziranma.cin" cn-gb-2312 "ZIRANMA.el"
      ziranma-converter
      "\
@@ -676,7 +678,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; You should have received a copy of the GNU General Public License along with
 ;; CCE.  If not, see <https://www.gnu.org/licenses/>.")
 
-    ("chinese-ctlau" "$AAuTA(B"
+    ("chinese-ctlau" "刘粤"
      "CTLau.html" cn-gb-2312 "CTLau.el"
      ctlau-gb-converter
      "\
@@ -701,7 +703,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; # You should have received a copy of the GNU General Public License
 ;; # along with this program.  If not, see <https://www.gnu.org/licenses/>.")
 
-    ("chinese-ctlaub" "$(0N,Gn(B"
+    ("chinese-ctlaub" "劉粵"
      "CTLau-b5.html" big5 "CTLau-b5.el"
      ctlau-b5-converter
      "\
@@ -731,41 +733,27 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; dictionary in the buffer DICBUF.  The input method name of the
 ;; Quail package is NAME, and the title string is TITLE.
 
-;; TSANG-P is non-nil, generate $(06AQo(B input method.  Otherwise
-;; generate $(0X|/y(B (simple version of $(06AQo(B).  If BIG5-P is 
non-nil, the
+;; TSANG-P is non-nil, generate 倉頡 input method.  Otherwise
+;; generate 簡易 (simple version of 倉頡).  If BIG5-P is non-nil, the
 ;; input method is for inputting Big5 characters.  Otherwise the input
 ;; method is for inputting CNS characters.
 
 (defun tsang-quick-converter (dicbuf tsang-p big5-p)
-  (let ((fulltitle (if tsang-p (if big5-p "$(06AQo(B" "$(GT?on(B")
-                    (if big5-p "$(0X|/y(B" "$(Gv|Mx(B")))
+  (let ((fulltitle (if tsang-p "倉頡" "簡易"))
        dic)
     (goto-char (point-max))
-    (if big5-p
-       (insert (format "\"$(0&d'GTT&,!J(B%s$(0!K(BBIG5
+    (insert (format "\"中文輸入【%s】%s
 
-       $(0KHM$(B%s$(0TT&,WoOu(B
+       漢語%s輸入鍵盤
 
-   [Q $(0'D(B] [W $(0(q(B] [E $(0'V(B] [R $(0&H(B] [T $(0'>(B] [Y 
$(0&4(B] [U $(0&U(B] [I $(0'B(B] [O $(0&*(B] [P $(0'A(B]
+   [Q 手] [W 田] [E 水] [R 口] [T 廿] [Y 卜] [U 山] [I 戈] [O 人] [P 心]
 
-    [A $(0'K(B] [S $(0&T(B] [D $(0'N(B] [F $(0'W(B] [G $(0&I(B] [H 
$(0*M(B] [J $(0&3(B] [L $(0&d(B]
+    [A 日] [S 尸] [D 木] [F 火] [G 土] [H 竹] [J 十] [L 中]
 
-      [Z  ] [X $(0[E(B] [C $(01[(B] [V $(0&M(B] [B $(0'M(B] [N 
$(0&_(B] [M $(0&"(B]
+      [Z  ] [X 難] [C 金] [V 女] [B 月] [N 弓] [M 一]
 
 \\\\<quail-translation-docstring>\"\n"
-                       fulltitle fulltitle))
-      (insert (format "\"$(GDcEFrSD+!J(B%s$(G!K(BCNS
-
-       $(GiGk#(B%s$(GrSD+uomu(B
-
-   [Q $(GEC(B] [W $(GFp(B] [E $(GEU(B] [R $(GDG(B] [T $(GE=(B] [Y 
$(GD3(B] [U $(GDT(B] [I $(GEA(B] [O $(GD)(B] [P $(GE@(B]
-
-    [A $(GEJ(B] [S $(GDS(B] [D $(GEM(B] [F $(GEV(B] [G $(GDH(B] [H 
$(GHL(B] [J $(GD2(B] [L $(GDc(B]
-
-      [Z  ] [X $(GyE(B] [C $(GOZ(B] [V $(GDL(B] [B $(GEL(B] [N 
$(GD^(B] [M $(GD!(B]
-
-\\\\<quail-translation-docstring>\"\n"
-                     fulltitle fulltitle)))
+                   fulltitle (if big5-p "BIG5" "CNS") fulltitle))
     (insert "  '((\".\" . quail-next-translation-block)
    (\",\" . quail-prev-translation-block))
   nil nil)\n\n")
@@ -798,35 +786,35 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
     (setq dic (sort dic (lambda (x y) (string< (car x ) (car y)))))
     (dolist (elt dic)
       (insert (format "(%S\t%S)\n" (car elt) (cdr elt))))
-    (let ((punctuation '((";" "$(0!'!2!"!#!.!/(B" "$(G!'!2!"!#!.!/(B")
-                        (":" "$(0!(!+!3!%!$!&!0!1(B" 
"$(G!(!+!3!%!$!&!0!1(B")
-                        ("'" "$(0!e!d(B" "$(G!e!d(B")
-                        ("\"" "$(0!g!f!h!i!q(B" "$(G!g!f!h!i!q(B")
-                        ("\\" "$(0"`"b#M(B" "$(G"`"b#M(B")
-                        ("|" "$(0!6!8!:"^(B" "$(G!6!8!:"^(B")
-                        ("/" "$(0"_"a#L(B" "$(G"_"a#L(B")
-                        ("?" "$(0!)!4(B" "$(G!)!4(B")
-                        ("<" "$(0!R"6"A!T"H(B" "$(G!R"6"A!T"H(B")
-                        (">" "$(0!S"7"B!U(B" "$(G!S"7"B!U(B")
-                        ("[" "$(0!F!J!b!H!L!V!Z!X!\(B" 
"$(G!F!J!b!H!L!V!Z!X!\(B")
-                        ("]" "$(0!G!K!c!I!M!W![!Y!](B" 
"$(G!G!K!c!I!M!W![!Y!](B")
-                        ("{" "$(0!B!`!D(B " "$(G!B!`!D(B ")
-                        ("}" "$(0!C!a!E(B" "$(G!C!a!E(B")
-                        ("`" "$(0!j!k(B" "$(G!j!k(B")
-                        ("~" "$(0"D"+",!<!=(B" "$(G"D"+",!<!=(B")
-                        ("!" "$(0!*!5(B" "$(G!*!5(B")
-                        ("@" "$(0"i"n(B" "$(G"i"n(B")
-                        ("#" "$(0!l"-(B" "$(G!l"-(B")
-                        ("$" "$(0"c"l(B" "$(G"c"l(B")
-                        ("%" "$(0"h"m(B" "$(G"h"m(B")
-                        ("&" "$(0!m".(B" "$(G!m".(B")
-                        ("*" "$(0!n"/!o!w!x(B" "$(G!n"/!o!w!x(B")
-                        ("(" "$(0!>!^!@(B" "$(G!>!^!@(B")
-                        (")" "$(0!?!_!A(B" "$(G!?!_!A(B")
-                        ("-" "$(0!7!9"#"$"1"@(B" "$(G!7!9"#"$"1"@(B")
-                        ("_" "$(0"%"&(B" "$(G"%"&(B")
-                        ("=" "$(0"8"C(B" "$(G"8"C(B")
-                        ("+" "$(0"0"?(B" "$(G"0"?(B"))))
+    (let ((punctuation '((";" ";﹔,、﹐﹑" ";﹔,、﹐﹑")
+                        (":" ":︰﹕.。‧﹒·" ":︰﹕.。・﹒·")
+                        ("'" "’‘" "’‘")
+                        ("\"" "”“〝〞〃" "”“〝〞〃")
+                        ("\\" "\﹨╲" "\﹨╲")
+                        ("|" "|︱︳∣" "︱︲��|")
+                        ("/" "/∕╱" "/∕╱")
+                        ("?" "?﹖" "?﹖")
+                        ("<" "〈<﹤︿∠" "〈<﹤︿∠")
+                        (">" "〉>﹥﹀" "〉>﹦﹀")
+                        ("[" "〔【﹝︹︻「『﹁﹃" "〔【﹝︹︻「『﹁﹃")
+                        ("]" "〕】﹞︺︼」』﹂﹄" "〕】﹞︺︼」』﹂﹄")
+                        ("{" "{﹛︷ " "{﹛︷ ")
+                        ("}" "}﹜︸" "}﹜︸")
+                        ("`" "‵′" "′‵")
+                        ("~" "~﹋﹌︴﹏" "∼﹋﹌����")
+                        ("!" "!﹗" "!﹗")
+                        ("@" "@﹫" "@﹫")
+                        ("#" "#﹟" "#﹟")
+                        ("$" "$﹩" "$﹩")
+                        ("%" "%﹪" "%﹪")
+                        ("&" "&﹠" "&﹠")
+                        ("*" "*﹡※☆★" "*﹡※☆★")
+                        ("(" "(﹙︵" "(﹙︵")
+                        (")" ")﹚︶" ")﹚︶")
+                        ("-" "–—¯ ̄-﹣" "—–‾��-﹣")
+                        ("_" "_ˍ" "_��")
+                        ("=" "=﹦" "=﹥")
+                        ("+" "+﹢" "+﹢"))))
     (dolist (elt punctuation)
       (insert (format "(%S %S)\n" (concat "z" (car elt))
                      (if big5-p (nth 1 elt) (nth 2 elt))))))
@@ -850,11 +838,11 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 
 (defun py-converter (dicbuf)
   (goto-char (point-max))
-  (insert (format "%S\n" "$A::WVJdHk!KF4Rt!K(B
+  (insert (format "%S\n" "汉字输入∷拼音∷
 
-       $AF4Rt7=08(B
+       拼音方案
 
- $AP!P4S"NDWVD84z1m!8F4Rt!97{:E#,(B \"u(yu) $ATrSC(B u: $A1mJ>!C(B
+ 小写英文字母代表「拼音」符号, \"u(yu) 则用 u: 表示∶
 
 Pinyin base input method for Chinese charset GB2312 (`chinese-gb2312').
 
@@ -868,14 +856,14 @@ character.  The sequence is made by the combination of 
the initials
           iang ing iong u ua uo uai ui uan un uan ueng yu yue yuan yun
 
   (Note: In the correct Pinyin writing, the sequence \"yu\" in the last
-   four finals should be written by the character u-umlaut `$A(9(B'.)
+   four finals should be written by the character u-umlaut `ü'.)
 
 With this input method, you enter a Chinese character by first
 entering its pinyin spelling.
 
 \\<quail-translation-docstring>
 
-For instance, to input $ADc(B, you type \"n i C-n 3\".  The first \"n i\"
+For instance, to input 你, you type \"n i C-n 3\".  The first \"n i\"
 is a Pinyin, \"C-n\" selects the next group of candidates (each group
 contains at most 10 characters), \"3\" select the third character in
 that group.
@@ -953,27 +941,27 @@ method `chinese-tonepy' with which you must specify tones 
by digits
                                     (= (length (aref trans i)) 1))
                           (setq i (1+ i)))
                         (if (= i len)
-                            (setq trans (mapconcat 'identity trans "")))))
+                            (setq trans (mapconcat #'identity trans "")))))
                     (setq dic (cons (cons key trans) dic)))
                 table)))
     (setq dic (sort dic (lambda (x y) (string< (car x) (car y)))))
     (goto-char (point-max))
-    (insert (format "%S\n" "$A::WVJdHk!K!>WTH;!?!K(B
-
-                            $A<|EL6TUU1m(B:
- $A)3)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)7(B
- $A)'#Q(B  $A)'#W(B  $A)'#E(B  $A)'#R(B  $A)'#T(B  $A)'#Y(B  
$A)'#U(Bsh$A)'#I(Bch$A)'#O(B  $A)'#P(B  $A)'(B
- $A)'(B  iu$A)'(B  ua$A)'(B   e$A)'(B uan$A)'(B  ue$A)'(B 
uai$A)'(B   u$A)'(B   i$A)'(B   o$A)'(B  un$A)'(B
- $A)'(B    $A)'(B  ia$A)'(B    $A)'(B van$A)'(B  ve$A)'(B 
ing$A)'(B    $A)'(B    $A)'(B  uo$A)'(B  vn$A)'(B
- $A);)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)?(B
-   $A)'#A(B  $A)'#S(B  $A)'#D(B  $A)'#F(B  $A)'#G(B  $A)'#H(B  
$A)'#J(B  $A)'#K(B  $A)'#L(B  $A)'(B
-   $A)'(B   a$A)'(Biong$A)'(Buang$A)'(B  en$A)'(B eng$A)'(B 
ang$A)'(B  an$A)'(B  ao$A)'(B  ai$A)'(B
-   $A)'(B    $A)'(B ong$A)'(Biang$A)'(B    $A)'(B  ng$A)'(B    
$A)'(B    $A)'(B    $A)'(B    $A)'(B
-   $A);)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)%)7(B
-     $A)'#Z(B  $A)'#X(B  $A)'#C(B  $A)'#V(Bzh$A)'#B(B  $A)'#N(B  
$A)'#M(B  $A)'#,(B  $A)'#.(B  $A)'(B $A#/(B $A)'(B
-     $A)'(B  ei$A)'(B  ie$A)'(B iao$A)'(B  ui$A)'(B  ou$A)'(B  
in$A)'(B ian$A)'G0R3)':sR3)'7{:E)'(B
-     $A)'(B    $A)'(B    $A)'(B    $A)'(B   v$A)'(B    $A)'(B    
$A)'(B    $A)'(B    $A)'(B    $A)'(B    $A)'(B
-     $A);)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)?(B
+    (insert (format "%S\n" "汉字输入∷【自然】∷
+
+                            键盘对照表:
+ ┏━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┓
+ ┃Q  ┃W  ┃E  ┃R  ┃T  ┃Y  ┃Ush┃Ich┃O  ┃P  ┃
+ ┃  iu┃  ua┃   e┃ uan┃  ue┃ uai┃   u┃   i┃   o┃  un┃
+ ┃    ┃  ia┃    ┃ van┃  ve┃ ing┃    ┃    ┃  uo┃  vn┃
+ ┗┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┛
+   ┃A  ┃S  ┃D  ┃F  ┃G  ┃H  ┃J  ┃K  ┃L  ┃
+   ┃   a┃iong┃uang┃  en┃ eng┃ ang┃  an┃  ao┃  ai┃
+   ┃    ┃ ong┃iang┃    ┃  ng┃    ┃    ┃    ┃    ┃
+   ┗┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━━┓
+     ┃Z  ┃X  ┃C  ┃Vzh┃B  ┃N  ┃M  ┃,  ┃.  ┃ / ┃
+     ┃  ei┃  ie┃ iao┃  ui┃  ou┃  in┃ ian┃前页┃后页┃符号┃
+     ┃    ┃    ┃    ┃   v┃    ┃    ┃    ┃    ┃    ┃    ┃
+     ┗━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┛
 
 
 Pinyin base input method for Chinese GB2312 characters (`chinese-gb2312').
@@ -985,34 +973,34 @@ method `chinese-py'.
 Unlike the standard spelling of Pinyin, in this input method all
 initials and finals are assigned to single keys (see the above table).
 For instance, the initial \"ch\" is assigned to the key `i', the final
-\"iu\" is assigned to the key `q', and tones 1, 2, 3, 4, and $AGaIy(B are
+\"iu\" is assigned to the key `q', and tones 1, 2, 3, 4, and 轻声 are
 assigned to the keys `q', `w', `e', `r', `t' respectively.
 
 \\<quail-translation-docstring>
 
 To input one-letter words, you type 4 keys, the first two for the
 Pinyin of the letter, next one for tone, and the last one is always a
-quote (').  For instance, \"vsq'\" input $AVP(B.  Exceptions are these
+quote (').  For instance, \"vsq'\" input 中.  Exceptions are these
 letters.  You can input them just by typing a single key.
 
-       Character: $A04(B $A2;(B $A4N(B $A5D(B $A6~(B $A7"(B 
$A8v(B $A:M(B $A3v(B $A<0(B $A?I(B $AAK(B $AC;(B
+       Character: 按 不 次 的 二 发 个 和 出 及 可 了 没
        Key:       a  b  c  d  e  f  g  h  i  j  k  l  m
-       Character: $ADc(B $AE7(B $AF,(B $AF_(B $AHK(B $AH}(B 
$AK{(B $AJG(B $AWE(B $ANR(B $AP!(B $AR;(B $ATZ(B
+       Character: 你 欧 片 七 人 三 他 是 着 我 小 一 在
        Key:       n  o  p  q  r  s  t  u  v  w  x  y  z
 
 To input two-letter words, you have two ways.  One way is to type 4
 keys, two for the first Pinyin, two for the second Pinyin.  For
-instance, \"vsgo\" inputs $AVP9z(B.  Another way is to type 3 keys: 2
+instance, \"vsgo\" inputs 中国.  Another way is to type 3 keys: 2
 initials of two letters, and quote (').  For instance, \"vg'\" also
-inputs $AVP9z(B.
+inputs 中国.
 
 To input three-letter words, you type 4 keys: initials of three
-letters, and the last is quote (').  For instance, \"bjy'2\" inputs $A11(B
-$A>)Q<(B (the last `2' is to select one of the candidates).
+letters, and the last is quote (').  For instance, \"bjy'2\" inputs 北
+京鸭 (the last `2' is to select one of the candidates).
 
 To input words of more than three letters, you type 4 keys, initials
 of the first three letters and the last letter.  For instance,
-\"bjdt\" inputs $A11>)5gJSL((B.
+\"bjdt\" inputs 北京电视台.
 
 To input symbols and punctuation, type `/' followed by one of `a' to
 `z', then select one of the candidates."))
@@ -1059,7 +1047,7 @@ To input symbols and punctuation, type `/' followed by 
one of `a' to
     ;; which the file is converted have no Big5 equivalent.  Go
     ;; through and delete them.
     (goto-char pos)
-    (while (search-forward "$(0!{(B" nil t)
+    (while (search-forward "□" nil t)
       (delete-char -1))
     ;; Uppercase keys in dictionary need to be downcased.  Backslashes
     ;; at the beginning of keys need to be turned into double
@@ -1083,31 +1071,31 @@ To input symbols and punctuation, type `/' followed by 
one of `a' to
 
 (defun ctlau-gb-converter (dicbuf)
   (ctlau-converter dicbuf
-"$A::WVJdHk!KAuN}OiJ=TARt!K(B
+"汉字输入∷刘锡祥式粤音∷
 
- $AAuN}OiJ=TASoW"Rt7=08(B
+ 刘锡祥式粤语注音方案
  Sidney Lau's Cantonese transcription scheme as described in his book
  \"Elementary Cantonese\", The Government Printer, Hong Kong, 1972.
- This file was prepared by Fung Fung Lee ($A@n7c7e(B).
+ This file was prepared by Fung Fung Lee (李枫峰).
  Originally converted from CTCPS3.tit
  Last modified: June 2, 1993.
 
  Some infrequent GB characters are accessed by typing \\, followed by
- the Cantonese romanization of the respective radical ($A2?JW(B)."))
+ the Cantonese romanization of the respective radical (部首)."))
 
 (defun ctlau-b5-converter (dicbuf)
   (ctlau-converter dicbuf
-"$(0KH)tTT&,!(N,Tg>A*#Gn5x!((B
+"漢字輸入:劉錫祥式粵音:
 
- $(0N,Tg>A*#GnM$0D5x'J7{(B
+ 劉錫祥式粵語注音方案
  Sidney Lau's Cantonese transcription scheme as described in his book
  \"Elementary Cantonese\", The Government Printer, Hong Kong, 1972.
- This file was prepared by Fung Fung Lee ($(0,XFS76(B).
+ This file was prepared by Fung Fung Lee (李楓峰).
  Originally converted from CTCPS3.tit
  Last modified: June 2, 1993.
 
  Some infrequent characters are accessed by typing \\, followed by
- the Cantonese romanization of the respective radical ($(0?f5}(B)."))
+ the Cantonese romanization of the respective radical (部首)."))
 
 (declare-function dos-8+3-filename "dos-fns.el" (filename))
 
@@ -1147,6 +1135,8 @@ the generated Quail package is saved."
        ;; Explicitly set eol format to `unix'.
        (setq coding-system-for-write 'utf-8-unix)
        (with-temp-file (expand-file-name quailfile dirname)
+          (insert (format ";;; %s  -*- lexical-binding:t -*-\n"
+                          (file-name-nondirectory quailfile)))
          (insert (format-message ";; Quail package `%s'\n" name))
          (insert (format-message
                   ";;   Generated by the command `miscdic-convert'\n"))
@@ -1212,8 +1202,10 @@ The library is named pinyin.el, and contains the constant
         (dst-file (cadr command-line-args-left))
         (coding-system-for-write 'utf-8-unix))
     (with-temp-file dst-file
-      (insert ";; This file is automatically generated from pinyin.map,\
- by the\n;; function pinyin-convert.\n\n")
+      (insert ";;; " (file-name-nondirectory dst-file)
+              "   -*- lexical-binding:t -*-
+;; This file is automatically generated from pinyin.map, by the
+;; function pinyin-convert.\n\n")
       (insert "(defconst pinyin-character-map\n'(")
       (let ((pos (point)))
         (insert-file-contents src-file)
diff --git a/lisp/international/utf-7.el b/lisp/international/utf-7.el
index e941abb..dece184 100644
--- a/lisp/international/utf-7.el
+++ b/lisp/international/utf-7.el
@@ -1,4 +1,4 @@
-;;; utf-7.el --- utf-7 coding system
+;;; utf-7.el --- utf-7 coding system  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2003-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/isearch.el b/lisp/isearch.el
index a866785..a1e3fe2 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -513,7 +513,7 @@ This is like `describe-bindings', but displays only Isearch 
keys."
     (call-interactively command)))
 
 (defvar isearch-menu-bar-commands
-  '(isearch-tmm-menubar menu-bar-open mouse-minor-mode-menu)
+  '(isearch-tmm-menubar tmm-menubar menu-bar-open mouse-minor-mode-menu)
   "List of commands that can open a menu during Isearch.")
 
 (defvar isearch-menu-bar-yank-map
@@ -787,7 +787,6 @@ This is like `describe-bindings', but displays only Isearch 
keys."
 
     (define-key map [menu-bar search-menu]
       (list 'menu-item "Isearch" isearch-menu-bar-map))
-    (define-key map [remap tmm-menubar] 'isearch-tmm-menubar)
 
     map)
   "Keymap for `isearch-mode'.")
diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index bb8dacf..303f38a 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -172,6 +172,7 @@ macro to be executed before appending to it."
     (define-key map "\C-k" 'kmacro-end-or-call-macro-repeat)
     (define-key map "r"    'apply-macro-to-region-lines)
     (define-key map "q"    'kbd-macro-query)  ;; Like C-x q
+    (define-key map "Q"    'kdb-macro-redisplay)
 
     ;; macro ring
     (define-key map "\C-n" 'kmacro-cycle-ring-next)
@@ -1298,6 +1299,16 @@ To customize possible responses, change the \"bindings\" 
in
       (kmacro-push-ring)
       (setq last-kbd-macro kmacro-step-edit-new-macro))))
 
+(defun kdb-macro-redisplay ()
+  "Force redisplay during kbd macro execution."
+  (interactive)
+  (or executing-kbd-macro
+      defining-kbd-macro
+      (user-error "Not defining or executing kbd macro"))
+  (when executing-kbd-macro
+    (let ((executing-kbd-macro nil))
+      (redisplay))))
+
 (provide 'kmacro)
 
 ;;; kmacro.el ends here
diff --git a/lisp/language/burmese.el b/lisp/language/burmese.el
index d689e87..373f25a 100644
--- a/lisp/language/burmese.el
+++ b/lisp/language/burmese.el
@@ -51,7 +51,7 @@
                                               regexp t t))))
     regexp))
 
-(let ((elt (list (vector burmese-composable-pattern 0 'font-shape-gstring)
-                (vector "." 0 'font-shape-gstring))))
+(let ((elt (list (vector burmese-composable-pattern 0 #'font-shape-gstring)
+                (vector "." 0 #'font-shape-gstring))))
   (set-char-table-range composition-function-table '(#x1000 . #x107F) elt)
   (set-char-table-range composition-function-table '(#xAA60 . #xAA7B) elt))
diff --git a/lisp/language/cham.el b/lisp/language/cham.el
index 089988d..3aac986 100644
--- a/lisp/language/cham.el
+++ b/lisp/language/cham.el
@@ -23,13 +23,13 @@
 
 ;;; Commentary:
 
-;; Tai Viet is being included in the Unicode at the range U+AA80..U+AADF.
+;; Cham script is included in the Unicode at the range U+AA00..U+AA5F.
 
 ;;; Code:
 
 (set-char-table-range composition-function-table
                      '(#xAA00 . #xAA5F)
-                     (list (vector "[\xAA00-\xAA5F]+" 0 'font-shape-gstring)))
+                     (list (vector "[\xAA00-\xAA5F]+" 0 #'font-shape-gstring)))
 
 (set-language-info-alist
  "Cham" '((charset unicode)
diff --git a/lisp/language/china-util.el b/lisp/language/china-util.el
index 4bc2eaa..105e7a7 100644
--- a/lisp/language/china-util.el
+++ b/lisp/language/china-util.el
@@ -1,4 +1,4 @@
-;;; china-util.el --- utilities for Chinese  -*- coding: utf-8 -*-
+;;; china-util.el --- utilities for Chinese  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1995, 2001-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
diff --git a/lisp/language/cyril-util.el b/lisp/language/cyril-util.el
index 72ceffd..04e681d 100644
--- a/lisp/language/cyril-util.el
+++ b/lisp/language/cyril-util.el
@@ -1,4 +1,4 @@
-;;; cyril-util.el --- utilities for Cyrillic scripts
+;;; cyril-util.el --- utilities for Cyrillic scripts  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 1997-1998, 2001-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/language/ethio-util.el b/lisp/language/ethio-util.el
index 174b9ec..9b5fdf2 100644
--- a/lisp/language/ethio-util.el
+++ b/lisp/language/ethio-util.el
@@ -1,4 +1,4 @@
-;;; ethio-util.el --- utilities for Ethiopic   -*- coding: utf-8-emacs; -*-
+;;; ethio-util.el --- utilities for Ethiopic   -*- coding: utf-8-emacs; 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-1998, 2002-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
@@ -832,11 +832,12 @@ The 2nd and 3rd arguments BEGIN and END specify the 
region."
     (set-buffer-modified-p nil)))
 
 ;;;###autoload
-(defun ethio-tex-to-fidel-buffer nil
+(defun ethio-tex-to-fidel-buffer ()
   "Convert fidel-tex commands in the current buffer into fidel chars."
   (interactive)
-  (let ((buffer-read-only nil)
-       (p) (ch))
+  (let ((inhibit-read-only t)
+       ;; (p) (ch)
+       )
 
     ;; TeX macros to Ethiopic characters
     (robin-convert-region (point-min) (point-max) "ethiopic-tex")
@@ -1018,7 +1019,7 @@ With ARG, insert that many delimiters."
 ;;
 
 ;;;###autoload
-(defun ethio-composition-function (pos to font-object string _direction)
+(defun ethio-composition-function (pos _to _font-object string _direction)
   (setq pos (1- pos))
   (let ((pattern "\\ce\\(፟\\|����\\)"))
     (if string
diff --git a/lisp/language/ethiopic.el b/lisp/language/ethiopic.el
index 8573f61..209dcd5 100644
--- a/lisp/language/ethiopic.el
+++ b/lisp/language/ethiopic.el
@@ -79,8 +79,8 @@
 )))
 
 ;; For automatic composition
-(aset composition-function-table ?���� 'ethio-composition-function)
-(aset composition-function-table ?፟ 'ethio-composition-function)
+(aset composition-function-table ?���� #'ethio-composition-function)
+(aset composition-function-table ?፟ #'ethio-composition-function)
 
 (provide 'ethiopic)
 
diff --git a/lisp/language/hanja-util.el b/lisp/language/hanja-util.el
index 313fc63..9e92135 100644
--- a/lisp/language/hanja-util.el
+++ b/lisp/language/hanja-util.el
@@ -1,4 +1,4 @@
-;;; hanja-util.el --- Korean Hanja util module  -*- coding: utf-8 -*-
+;;; hanja-util.el --- Korean Hanja util module  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2008-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/language/hebrew.el b/lisp/language/hebrew.el
index 3895656..c55d23f 100644
--- a/lisp/language/hebrew.el
+++ b/lisp/language/hebrew.el
@@ -245,9 +245,9 @@ Bidirectional editing is supported.")))
        (pattern2 (concat base "\u200D" combining)))
   (set-char-table-range
    composition-function-table '(#x591 . #x5C7)
-   (list (vector pattern2 3 'hebrew-shape-gstring)
-        (vector pattern2 2 'hebrew-shape-gstring)
-        (vector pattern1 1 'hebrew-shape-gstring)
+   (list (vector pattern2 3 #'hebrew-shape-gstring)
+        (vector pattern2 2 #'hebrew-shape-gstring)
+        (vector pattern1 1 #'hebrew-shape-gstring)
         [nil 0 hebrew-shape-gstring]))
   ;; Exclude non-combining characters.
   (set-char-table-range
diff --git a/lisp/language/ind-util.el b/lisp/language/ind-util.el
index 4bd1cd7..8d4b2a8 100644
--- a/lisp/language/ind-util.el
+++ b/lisp/language/ind-util.el
@@ -1,4 +1,4 @@
-;;; ind-util.el --- Transliteration and Misc. Tools for Indian Languages -*- 
coding: utf-8-emacs; -*-
+;;; ind-util.el --- Transliteration and Misc. Tools for Indian Languages -*- 
coding: utf-8-emacs; lexical-binding: t; -*-
 
 ;; Copyright (C) 2001-2021 Free Software Foundation, Inc.
 
@@ -40,7 +40,7 @@
 (defun indian-regexp-of-hashtbl-keys (hashtbl)
   "Return the regular expression of hash table keys."
   (let (keys)
-    (maphash (lambda (key val) (push key keys)) hashtbl)
+    (maphash (lambda (key _val) (push key keys)) hashtbl)
     (regexp-opt keys)))
 
 (defvar indian-dev-base-table
@@ -565,7 +565,7 @@
        (let ((regexp ,(indian-regexp-of-hashtbl-keys
                       (if encode-p (car (eval hashtable))
                         (cdr (eval hashtable))))))
-        (narrow-to-region from to)
+        (narrow-to-region ,from ,to)
         (goto-char (point-min))
         (while (re-search-forward regexp nil t)
           (let ((matchstr (gethash (match-string 0)
@@ -613,7 +613,7 @@
 
 ;; The followings provide conversion between IS 13194 (ISCII) and UCS.
 
-(let
+(dlet
     ;;Unicode vs IS13194  ;; only Devanagari is supported now.
     ((ucs-devanagari-to-is13194-alist
       '((?\x0900 . "[U+0900]")
@@ -820,11 +820,11 @@ Returns new end position."
     (save-restriction
       (narrow-to-region from to)
       (goto-char (point-min))
-      (let* ((current-repertory is13194-default-repertory))
+      ;; (let* ((current-repertory is13194-default-repertory))
        (while (re-search-forward indian-ucs-to-is13194-regexp nil t)
          (replace-match
           (get-char-code-property (string-to-char (match-string 0))
-                                  'iscii))))
+                                  'iscii)));; )
       (point-max))))
 
 (defun indian-iscii-to-ucs-region (from to)
@@ -1246,7 +1246,7 @@ Returns new end position."
   (interactive "r")
   (save-excursion
     (save-restriction
-      (let ((pos from)
+      (let (;; (pos from)
            (alist (char-table-extra-slot indian-2-column-to-ucs-chartable 0)))
        (narrow-to-region from to)
        (decompose-region from to)
diff --git a/lisp/language/indian.el b/lisp/language/indian.el
index 5ff5796..6f9d270 100644
--- a/lisp/language/indian.el
+++ b/lisp/language/indian.el
@@ -381,7 +381,7 @@ South Indian language Malayalam is supported in this 
language environment."))
         (if slot
             (set-char-table-range
              composition-function-table key
-             (list (vector (cdr slot) 0 'font-shape-gstring))))))
+             (list (vector (cdr slot) 0 #'font-shape-gstring))))))
    char-script-table))
 
 (provide 'indian)
diff --git a/lisp/language/japan-util.el b/lisp/language/japan-util.el
index 9dce17c..948bfef 100644
--- a/lisp/language/japan-util.el
+++ b/lisp/language/japan-util.el
@@ -1,4 +1,4 @@
-;;; japan-util.el --- utilities for Japanese
+;;; japan-util.el --- utilities for Japanese  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2001-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
@@ -236,7 +236,7 @@ of which charset is `japanese-jisx0201-kana'."
               (composition
                (and (not hankaku)
                     (get-char-code-property kana 'kana-composition)))
-              next slot)
+              slot) ;; next
          (if (and composition (setq slot (assq (following-char) composition)))
              (japanese-replace-region (match-beginning 0) (1+ (point))
                                       (cdr slot))
@@ -258,7 +258,7 @@ of which charset is `japanese-jisx0201-kana'."
       (while (re-search-forward "\\cK\\|\\ck" nil t)
        (let* ((kata (preceding-char))
               (composition (get-char-code-property kata 'kana-composition))
-              next slot)
+              slot) ;; next
          (if (and composition (setq slot (assq (following-char) composition)))
              (japanese-replace-region (match-beginning 0) (1+ (point))
                                       (get-char-code-property
@@ -305,7 +305,7 @@ Optional argument KATAKANA-ONLY non-nil means to convert 
only KATAKANA char."
                      (re-search-forward "\\ca\\|\\ck" nil t)))
        (let* ((hankaku (preceding-char))
               (composition (get-char-code-property hankaku 'kana-composition))
-              next slot)
+              slot) ;; next
          (if (and composition (setq slot (assq (following-char) composition)))
              (japanese-replace-region (match-beginning 0) (1+ (point))
                                       (cdr slot))
diff --git a/lisp/language/khmer.el b/lisp/language/khmer.el
index 37173c9..6f08e60 100644
--- a/lisp/language/khmer.el
+++ b/lisp/language/khmer.el
@@ -31,7 +31,7 @@
           (documentation . t)))
 
 (let ((val (list (vector "[\x1780-\x17FF\x19E0-\x19FF\x200C\x200D]+"
-                        0 'font-shape-gstring))))
+                        0 #'font-shape-gstring))))
   (set-char-table-range composition-function-table '(#x1780 . #x17FF) val)
   (set-char-table-range composition-function-table '(#x19E0 . #x19FF) val))
 
diff --git a/lisp/language/korea-util.el b/lisp/language/korea-util.el
index eb7b85b..c99ff3c 100644
--- a/lisp/language/korea-util.el
+++ b/lisp/language/korea-util.el
@@ -1,4 +1,4 @@
-;;; korea-util.el --- utilities for Korean
+;;; korea-util.el --- utilities for Korean  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1997, 1999, 2001-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -45,7 +45,7 @@
     (activate-input-method
      (concat "korean-hangul" default-korean-keyboard))))
 
-(defun quail-hangul-switch-symbol-ksc (&rest ignore)
+(defun quail-hangul-switch-symbol-ksc (&rest _ignore)
   "Switch to/from Korean symbol package."
   (interactive "i")
   (and current-input-method
@@ -54,7 +54,7 @@
                                          default-korean-keyboard))
         (activate-input-method "korean-symbol"))))
 
-(defun quail-hangul-switch-hanja (&rest ignore)
+(defun quail-hangul-switch-hanja (&rest _ignore)
   "Switch to/from Korean hanja package."
   (interactive "i")
   (and current-input-method
diff --git a/lisp/language/korean.el b/lisp/language/korean.el
index 22b33a4..bdf8240 100644
--- a/lisp/language/korean.el
+++ b/lisp/language/korean.el
@@ -92,10 +92,10 @@ and the following key bindings are available within Korean 
input methods:
        (pattern (concat choseong jungseong jongseong)))
   (set-char-table-range composition-function-table
                         '(#x1100 . #x115F)
-                        (list (vector pattern 0 'font-shape-gstring)))
+                        (list (vector pattern 0 #'font-shape-gstring)))
   (set-char-table-range composition-function-table
                         '(#xA960 . #xA97C)
-                        (list (vector pattern 0 'font-shape-gstring))))
+                        (list (vector pattern 0 #'font-shape-gstring))))
 
 (provide 'korean)
 
diff --git a/lisp/language/lao-util.el b/lisp/language/lao-util.el
index 59c9850..c8c3fe4 100644
--- a/lisp/language/lao-util.el
+++ b/lisp/language/lao-util.el
@@ -1,4 +1,4 @@
-;;; lao-util.el --- utilities for Lao -*- coding: utf-8; -*-
+;;; lao-util.el --- utilities for Lao -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2001-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -498,10 +498,10 @@ syllable.  In that case, FROM and TO are indexes to STR."
       (compose-gstring-for-graphic gstring direction)
     (or (font-shape-gstring gstring direction)
        (let ((glyph-len (lgstring-glyph-len gstring))
-             (i 0)
-             glyph)
+             (i 0)) ;; glyph
          (while (and (< i glyph-len)
-                     (setq glyph (lgstring-glyph gstring i)))
+                     ;; (setq glyph
+                     (lgstring-glyph gstring i)) ;;)
            (setq i (1+ i)))
          (compose-glyph-string-relative gstring 0 i 0.1)))))
 
diff --git a/lisp/language/lao.el b/lisp/language/lao.el
index 5252f1e..c699d57 100644
--- a/lisp/language/lao.el
+++ b/lisp/language/lao.el
@@ -66,7 +66,7 @@
                                        (t (string c))))
                              (cdr l) ""))
           ;; Element of composition-function-table.
-          (elt (list (vector regexp 1 'lao-composition-function)
+          (elt (list (vector regexp 1 #'lao-composition-function)
                      fallback-rule))
           ch)
       (dotimes (i len)
diff --git a/lisp/language/misc-lang.el b/lisp/language/misc-lang.el
index 0a274f1..a2ca678 100644
--- a/lisp/language/misc-lang.el
+++ b/lisp/language/misc-lang.el
@@ -137,9 +137,9 @@ thin (i.e. 1-dot width) space."
  composition-function-table
  '(#x600 . #x74F)
  (list (vector "[\u200C\u200D][\u0600-\u074F\u200C\u200D]+"
-               1 'arabic-shape-gstring)
+               1 #'arabic-shape-gstring)
        (vector "[\u0600-\u074F\u200C\u200D]+"
-               0 'arabic-shape-gstring)))
+               0 #'arabic-shape-gstring)))
 
 ;; The Egyptian Hieroglyph Format Controls were introduced in Unicode
 ;; Standard v12.0.  Apparently, they are not yet well supported in
@@ -186,13 +186,13 @@ thin (i.e. 1-dot width) space."
                  ;; doesn't support these controls, the glyphs are
                  ;; displayed individually, and not as a single
                  ;; grapheme cluster.
-                 1 'font-shape-gstring)))
+                 1 #'font-shape-gstring)))
   ;; Grouping controls
   (set-char-table-range
    composition-function-table
    #x13437
    (list (vector "\U00013437[\U00013000-\U0001343F]+"
-                 0 'egyptian-shape-grouping))))
+                 0 #'egyptian-shape-grouping))))
 
 (provide 'misc-lang)
 
diff --git a/lisp/language/sinhala.el b/lisp/language/sinhala.el
index 90fc41c..99a104e 100644
--- a/lisp/language/sinhala.el
+++ b/lisp/language/sinhala.el
@@ -43,6 +43,6 @@
         "[\u0D85-\u0D96][\u0D82-\u0D83]?\\|"
         ;; any other singleton characters
         "[\u0D80-\u0DFF]")
-       0 'font-shape-gstring)))
+       0 #'font-shape-gstring)))
 
 ;; sinhala.el ends here
diff --git a/lisp/language/tai-viet.el b/lisp/language/tai-viet.el
index 17abf13..4549b11 100644
--- a/lisp/language/tai-viet.el
+++ b/lisp/language/tai-viet.el
@@ -30,7 +30,7 @@
 
 (set-char-table-range composition-function-table
                      '(#xAA80 . #xAADF)
-                     'tai-viet-composition-function)
+                     #'tai-viet-composition-function)
 
 (set-language-info-alist
  "TaiViet" '((charset unicode)
diff --git a/lisp/language/thai-util.el b/lisp/language/thai-util.el
index f9c57e8..e11a054 100644
--- a/lisp/language/thai-util.el
+++ b/lisp/language/thai-util.el
@@ -1,4 +1,4 @@
-;;; thai-util.el --- utilities for Thai -*- coding: utf-8; -*-
+;;; thai-util.el --- utilities for Thai -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2000-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
@@ -232,10 +232,10 @@ positions (integers or markers) specifying the region."
        (let ((glyph-len (lgstring-glyph-len gstring))
              (last-char (lgstring-char gstring
                                        (1- (lgstring-char-len gstring))))
-             (i 0)
-             glyph)
+             (i 0)) ;; glyph
          (while (and (< i glyph-len)
-                     (setq glyph (lgstring-glyph gstring i)))
+                     ;; (setq glyph
+                     (lgstring-glyph gstring i)) ;; )
            (setq i (1+ i)))
          (if (= last-char ?ำ)
              (setq i (1- i)))
diff --git a/lisp/language/thai-word.el b/lisp/language/thai-word.el
index 94c6ab9..ff1e802 100644
--- a/lisp/language/thai-word.el
+++ b/lisp/language/thai-word.el
@@ -1,4 +1,4 @@
-;;; thai-word.el -- find Thai word boundaries
+;;; thai-word.el -- find Thai word boundaries  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 
2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -10973,8 +10973,7 @@ If COUNT is negative, move point backward (- COUNT) 
words."
            ;; special instead of using forward-word.
            (let ((start (point))
                  (limit (match-end 0))
-                 boundaries
-                 tail)
+                 boundaries) ;; tail
              ;; If thai-forward-word has been called within a Thai
              ;; region, we must go back until the Thai region starts
              ;; to do the contextual analysis for finding word
diff --git a/lisp/language/tibet-util.el b/lisp/language/tibet-util.el
index e741af1..ddf4a0c 100644
--- a/lisp/language/tibet-util.el
+++ b/lisp/language/tibet-util.el
@@ -1,4 +1,4 @@
-;;; tibet-util.el --- utilities for Tibetan   -*- coding: utf-8-emacs; -*-
+;;; tibet-util.el --- utilities for Tibetan   -*- coding: utf-8-emacs; 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1997, 2001-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
@@ -126,42 +126,42 @@ The returned string has no composition information."
        (setq t-str-list (cons (substring str idx) t-str-list)))
     (apply 'concat (nreverse t-str-list))))
 
-;;;
+;;
 ;;; Functions for composing/decomposing Tibetan sequence.
-;;;
-;;; A Tibetan syllable is typically structured as follows:
-;;;
-;;;      [Prefix] C [C+] V [M] [Suffix [Post suffix]]
-;;;
-;;; where C's are all vertically stacked, V appears below or above
-;;; consonant cluster and M is always put above the C[C+]V combination.
-;;; (Sanskrit visarga, though it is a vowel modifier, is considered
-;;;  to be a punctuation.)
-;;;
-;;; Here are examples of the words "bsgrubs" and "hfauM"
-;;;
-;;;            བསྒྲུབས            ཧཱུཾ
-;;;
-;;;                             M
-;;;             b s b s         h
-;;;               g             fa
-;;;               r             u
-;;;               u
-;;;
-;;; Consonants `'' (འ), `w' (ཝ), `y' (ཡ), `r' (ར) take special
-;;; forms when they are used as subjoined consonant.  Consonant `r'
-;;; takes another special form when used as superjoined in such a case
-;;; as "rka", while it does not change its form when conjoined with
-;;; subjoined `'', `w' or `y' as in "rwa", "rya".
-
-;; Append a proper composition rule and glyph to COMPONENTS to compose
-;; CHAR with a composition that has COMPONENTS.
+;;
+;; A Tibetan syllable is typically structured as follows:
+;;
+;;      [Prefix] C [C+] V [M] [Suffix [Post suffix]]
+;;
+;; where C's are all vertically stacked, V appears below or above
+;; consonant cluster and M is always put above the C[C+]V combination.
+;; (Sanskrit visarga, though it is a vowel modifier, is considered
+;;  to be a punctuation.)
+;;
+;; Here are examples of the words "bsgrubs" and "hfauM"
+;;
+;;            བསྒྲུབས            ཧཱུཾ
+;;
+;;                             M
+;;             b s b s         h
+;;               g             fa
+;;               r             u
+;;               u
+;;
+;; Consonants `'' (འ), `w' (ཝ), `y' (ཡ), `r' (ར) take special
+;; forms when they are used as subjoined consonant.  Consonant `r'
+;; takes another special form when used as superjoined in such a case
+;; as "rka", while it does not change its form when conjoined with
+;; subjoined `'', `w' or `y' as in "rwa", "rya".
+
+; Append a proper composition rule and glyph to COMPONENTS to compose
+; CHAR with a composition that has COMPONENTS.
 
 (defun tibetan-add-components (components char)
   (let ((last (last components))
        (stack-upper '(tc . bc))
        (stack-under '(bc . tc))
-       rule comp-vowel tmp)
+       rule comp-vowel)
     ;; Special treatment for 'a chung.
     ;; If 'a follows a consonant, turn it into the subjoined form.
     ;; * Disabled by Tomabechi 2000/06/09 *
@@ -246,7 +246,7 @@ The returned string has no composition information."
 (defun tibetan-compose-region (beg end)
   "Compose Tibetan text the region BEG and END."
   (interactive "r")
-  (let (str result chars)
+  ;; (let (str result chars)
     (save-excursion
       (save-restriction
        (narrow-to-region beg end)
@@ -272,7 +272,7 @@ The returned string has no composition information."
            (while (< (point) to)
              (tibetan-add-components components (following-char))
              (forward-char 1))
-           (compose-region from to components)))))))
+           (compose-region from to components)))))) ;; )
 
 (defvar tibetan-decompose-precomposition-alist
   (mapcar (lambda (x) (cons (string-to-char (cdr x)) (car x)))
diff --git a/lisp/language/tibetan.el b/lisp/language/tibetan.el
index edd9d76..48c7638 100644
--- a/lisp/language/tibetan.el
+++ b/lisp/language/tibetan.el
@@ -605,7 +605,7 @@ This also matches some punctuation characters which need 
conversion.")
 ;; For automatic composition.
 (set-char-table-range
  composition-function-table '(#xF00 . #xFD1)
- (list (vector tibetan-composable-pattern 0 'font-shape-gstring)))
+ (list (vector tibetan-composable-pattern 0 #'font-shape-gstring)))
 
 (provide 'tibetan)
 
diff --git a/lisp/language/tv-util.el b/lisp/language/tv-util.el
index 7ce8ee1..1a530d3 100644
--- a/lisp/language/tv-util.el
+++ b/lisp/language/tv-util.el
@@ -1,4 +1,4 @@
-;;; tv-util.el --- support for Tai Viet                        -*- coding: 
utf-8 -*-
+;;; tv-util.el --- support for Tai Viet                -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -128,7 +128,7 @@
 
 
 ;;;###autoload
-(defun tai-viet-composition-function (from to font-object string _direction)
+(defun tai-viet-composition-function (from _to _font-object string _direction)
   (if string
       (if (string-match tai-viet-re string from)
          (tai-viet-compose-string from (match-end 0) string))
diff --git a/lisp/language/viet-util.el b/lisp/language/viet-util.el
index 177b04b..bfaf0f3 100644
--- a/lisp/language/viet-util.el
+++ b/lisp/language/viet-util.el
@@ -1,4 +1,4 @@
-;;; viet-util.el --- utilities for Vietnamese  -*- coding: utf-8; -*-
+;;; viet-util.el --- utilities for Vietnamese  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1998, 2001-2021 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
diff --git a/lisp/leim/quail/compose.el b/lisp/leim/quail/compose.el
index f7ac83a..264a9b4 100644
--- a/lisp/leim/quail/compose.el
+++ b/lisp/leim/quail/compose.el
@@ -1,4 +1,4 @@
-;;; compose.el --- Quail package for Multi_key character composition 
-*-coding: utf-8;-*-
+;;; compose.el --- Quail package for Multi_key character composition 
-*-coding: utf-8; lexical-binding: t -*-
 
 ;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/leim/quail/viqr.el b/lisp/leim/quail/viqr.el
index b7591b1..d127ff2 100644
--- a/lisp/leim/quail/viqr.el
+++ b/lisp/leim/quail/viqr.el
@@ -1,4 +1,4 @@
-;;; viqr.el --- Quail packages for inputting Vietnamese with VIQR system  
-*-coding: utf-8;-*-
+;;; viqr.el --- Quail packages for inputting Vietnamese with VIQR system  
-*-coding: utf-8; lexical-binding: t -*-
 
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 29460cc..9f95b62 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -2723,6 +2723,12 @@ See also `unrmail-mbox-format'."
   :version "24.4"
   :group 'rmail-files)
 
+(defcustom rmail-show-message-set-modified nil
+  "If non-nil, displaying an unseen message marks the Rmail buffer as 
modified."
+  :type 'boolean
+  :group 'rmail
+  :version "28.1")
+
 (defun rmail-show-message-1 (&optional msg)
   "Show message MSG (default: current message) using `rmail-view-buffer'.
 Return text to display in the minibuffer if MSG is out of
@@ -2750,6 +2756,8 @@ The current mail message becomes the message displayed."
        ;; Mark the message as seen, but preserve buffer modified flag.
        (let ((modiff (buffer-modified-p)))
          (rmail-set-attribute rmail-unseen-attr-index nil)
+          (and rmail-show-message-set-modified
+               (setq modiff t))
          (unless modiff
            (restore-buffer-modified-p modiff)))
        ;; bracket the message in the mail
diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el
index d29115a..7f99ecd 100644
--- a/lisp/mail/rmailsum.el
+++ b/lisp/mail/rmailsum.el
@@ -974,8 +974,9 @@ a negative argument means to delete and move forward."
          (delete-char 1)
          (insert "D"))
        ;; Discard cached new summary line.
-       (with-current-buffer rmail-buffer
-         (aset rmail-summary-vector (1- n) nil))))
+        (when n
+         (with-current-buffer rmail-buffer
+           (aset rmail-summary-vector (1- n) nil)))))
   (beginning-of-line))
 
 (defun rmail-summary-update-line (n)
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 9f6fd6d..d2601c3 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -104,7 +104,9 @@ being sent is used), or nil (in which case the value of
 (defcustom mail-self-blind nil
   "Non-nil means insert Bcc to self in messages to be sent.
 This is done when the message is initialized,
-so you can remove or alter the Bcc field to override the default."
+so you can remove or alter the Bcc field to override the default.
+If you are using `message-mode' to compose messages, customize the
+variable `message-default-mail-headers' instead."
   :type 'boolean)
 
 ;;;###autoload
@@ -172,14 +174,18 @@ This is used by the default mail-sending commands.  See 
also
 (defcustom mail-archive-file-name nil
   "Name of file to write all outgoing messages in, or nil for none.
 This is normally an mbox file, but for backwards compatibility may also
-be a Babyl file."
+be a Babyl file.
+If you are using `message-mode' to compose messages, customize the
+variable `message-default-mail-headers' instead."
   :type '(choice file (const nil)))
 
 ;;;###autoload
 (defcustom mail-default-reply-to nil
   "Address to insert as default Reply-To field of outgoing messages.
 If nil, it will be initialized from the REPLYTO environment variable
-when you first send mail."
+when you first send mail.
+If you are using `message-mode' to compose messages, customize the
+variable `message-default-mail-headers' instead."
   :type '(choice (const nil) string))
 
 (defcustom mail-alias-file nil
@@ -388,7 +394,9 @@ in `message-auto-save-directory'."
 (defcustom mail-default-headers nil
   "A string containing header lines, to be inserted in outgoing messages.
 It can contain newlines, and should end in one.  It is inserted
-before you edit the message, so you can edit or delete the lines."
+before you edit the message, so you can edit or delete the lines.
+If you are using `message-mode' to compose messages, customize the
+variable `message-default-mail-headers' instead."
   :type '(choice (const nil) string))
 
 (defcustom mail-bury-selects-summary t
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index 9559b12..fa13dd5 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -2547,7 +2547,7 @@ can parse the output from a DIR listing for a host of 
type TYPE.")
 FILE is the full name of the remote file, LSARGS is any args to pass to the
 `ls' command, and PARSE specifies that the output should be parsed and stored
 away in the internal cache."
-  (when (string-match "^--dired\\s-+" lsargs)
+  (while (string-match "^--dired\\s-+" lsargs)
     (setq lsargs (replace-match "" nil t lsargs)))
   ;; If parse is t, we assume that file is a directory. i.e. we only parse
   ;; full directory listings.
diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el
index 7a7bbef..195ddc6 100644
--- a/lisp/net/dbus.el
+++ b/lisp/net/dbus.el
@@ -2079,6 +2079,7 @@ daemon, it is rather the timestamp the corresponding 
D-Bus event
 has been handled by this function."
   (with-current-buffer (get-buffer-create "*D-Bus Monitor*")
     (special-mode)
+    (buffer-disable-undo)
     ;; Move forward and backward between messages.
     (local-set-key [?n] #'forward-paragraph)
     (local-set-key [?p] #'backward-paragraph)
diff --git a/lisp/net/sasl-cram.el b/lisp/net/sasl-cram.el
index bc2612d..4022a35 100644
--- a/lisp/net/sasl-cram.el
+++ b/lisp/net/sasl-cram.el
@@ -1,4 +1,4 @@
-;;; sasl-cram.el --- CRAM-MD5 module for the SASL client framework
+;;; sasl-cram.el --- CRAM-MD5 module for the SASL client framework  -*- 
lexical-binding: t -*-
 
 ;; Copyright (C) 2000, 2007-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/net/sasl-digest.el b/lisp/net/sasl-digest.el
index efc8f82..5afc195 100644
--- a/lisp/net/sasl-digest.el
+++ b/lisp/net/sasl-digest.el
@@ -1,4 +1,4 @@
-;;; sasl-digest.el --- DIGEST-MD5 module for the SASL client framework
+;;; sasl-digest.el --- DIGEST-MD5 module for the SASL client framework  -*- 
lexical-binding: t -*-
 
 ;; Copyright (C) 2000, 2007-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/net/sasl-ntlm.el b/lisp/net/sasl-ntlm.el
index 6658226..dfb7e71 100644
--- a/lisp/net/sasl-ntlm.el
+++ b/lisp/net/sasl-ntlm.el
@@ -1,4 +1,4 @@
-;;; sasl-ntlm.el --- NTLM (NT Lan Manager) module for the SASL client framework
+;;; sasl-ntlm.el --- NTLM (NT Lan Manager) module for the SASL client 
framework  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2000, 2007-2021 Free Software Foundation, Inc.
 
@@ -40,7 +40,7 @@
   "A list of functions to be called in sequence for the NTLM
 authentication steps.  They are called by `sasl-next-step'.")
 
-(defun sasl-ntlm-request (client step)
+(defun sasl-ntlm-request (client _step)
   "SASL step function to generate a NTLM authentication request to the server.
 Called from `sasl-next-step'.
 CLIENT is a vector [mechanism user service server sasl-client-properties]
diff --git a/lisp/net/sasl.el b/lisp/net/sasl.el
index 7f0431a..b7f814f 100644
--- a/lisp/net/sasl.el
+++ b/lisp/net/sasl.el
@@ -1,4 +1,4 @@
-;;; sasl.el --- SASL client framework
+;;; sasl.el --- SASL client framework  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2000, 2007-2021 Free Software Foundation, Inc.
 
@@ -161,15 +161,8 @@ the current challenge.  At the first time STEP should be 
set to nil."
     (if function
        (vector function (funcall function client step)))))
 
-(defvar sasl-read-passphrase nil)
+(defvar sasl-read-passphrase 'read-passwd)
 (defun sasl-read-passphrase (prompt)
-  (if (not sasl-read-passphrase)
-      (if (functionp 'read-passwd)
-         (setq sasl-read-passphrase 'read-passwd)
-       (if (load "passwd" t)
-           (setq sasl-read-passphrase 'read-passwd)
-         (autoload 'ange-ftp-read-passwd "ange-ftp")
-         (setq sasl-read-passphrase 'ange-ftp-read-passwd))))
   (funcall sasl-read-passphrase prompt))
 
 (defun sasl-unique-id ()
@@ -210,7 +203,7 @@ It contain at least 64 bits of entropy."
 (defconst sasl-plain-steps
   '(sasl-plain-response))
 
-(defun sasl-plain-response (client step)
+(defun sasl-plain-response (client _step)
   (let ((passphrase
         (sasl-read-passphrase
          (format "PLAIN passphrase for %s: " (sasl-client-name client))))
@@ -236,12 +229,12 @@ It contain at least 64 bits of entropy."
     sasl-login-response-1
     sasl-login-response-2))
 
-(defun sasl-login-response-1 (client step)
+(defun sasl-login-response-1 (client _step)
 ;;;  (unless (string-match "^Username:" (sasl-step-data step))
 ;;;    (sasl-error (format "Unexpected response: %s" (sasl-step-data step))))
   (sasl-client-name client))
 
-(defun sasl-login-response-2 (client step)
+(defun sasl-login-response-2 (client _step)
 ;;;  (unless (string-match "^Password:" (sasl-step-data step))
 ;;;    (sasl-error (format "Unexpected response: %s" (sasl-step-data step))))
   (sasl-read-passphrase
@@ -257,7 +250,7 @@ It contain at least 64 bits of entropy."
   '(ignore                             ;no initial response
     sasl-anonymous-response))
 
-(defun sasl-anonymous-response (client step)
+(defun sasl-anonymous-response (client _step)
   (or (sasl-client-property client 'trace)
       (sasl-client-name client)))
 
diff --git a/lisp/net/sieve-mode.el b/lisp/net/sieve-mode.el
index fbc4e75..7bc1d16 100644
--- a/lisp/net/sieve-mode.el
+++ b/lisp/net/sieve-mode.el
@@ -128,6 +128,9 @@
     (modify-syntax-entry ?| "." st)
     (modify-syntax-entry ?_ "_" st)
     (modify-syntax-entry ?\' "\"" st)
+    (modify-syntax-entry ?\{ "(}" st)
+    (modify-syntax-entry ?\} "){" st)
+    (modify-syntax-entry ?\" "\"" st)
     st)
   "Syntax table in use in sieve-mode buffers.")
 
@@ -178,12 +181,8 @@
                          'syntax-table (string-to-syntax "|")))))
 
 ;;;###autoload
-(define-derived-mode sieve-mode c-mode "Sieve"
+(define-derived-mode sieve-mode prog-mode "Sieve"
   "Major mode for editing Sieve code.
-This is much like C mode except for the syntax of comments.  Its keymap
-inherits from C mode's and it has the same variables for customizing
-indentation.  It has its own abbrev table and its own syntax table.
-
 Turning on Sieve mode runs `sieve-mode-hook'."
   (setq-local paragraph-start (concat "$\\|" page-delimiter))
   (setq-local paragraph-separate paragraph-start)
@@ -194,8 +193,17 @@ Turning on Sieve mode runs `sieve-mode-hook'."
   (setq-local syntax-propertize-function #'sieve-syntax-propertize)
   (setq-local font-lock-defaults
               '(sieve-font-lock-keywords nil nil ((?_ . "w"))))
+  (setq-local indent-line-function #'sieve-mode-indent-function)
   (easy-menu-add-item nil nil sieve-mode-menu))
 
+(defun sieve-mode-indent-function ()
+  (save-excursion
+    (beginning-of-line)
+    (let ((depth (car (syntax-ppss))))
+      (when (looking-at "[ \t]*}")
+        (setq depth (1- depth)))
+      (indent-line-to (* 2 depth)))))
+
 (provide 'sieve-mode)
 
 ;; sieve-mode.el ends here
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 2c4ef2a..73dffe1 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -636,7 +636,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
       (copy-directory filename newname keep-date t)
 
     (let ((t1 (tramp-tramp-file-p filename))
-         (t2 (tramp-tramp-file-p newname)))
+         (t2 (tramp-tramp-file-p newname))
+         ;; We don't want the target file to be compressed, so we
+         ;; let-bind `jka-compr-inhibit' to t.
+         (jka-compr-inhibit t))
       (with-parsed-tramp-file-name (if t1 filename newname) nil
        (unless (file-exists-p filename)
          (tramp-error
@@ -717,7 +720,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
        (delete-directory filename 'recursive))
 
     (let ((t1 (tramp-tramp-file-p filename))
-         (t2 (tramp-tramp-file-p newname)))
+         (t2 (tramp-tramp-file-p newname))
+         ;; We don't want the target file to be compressed, so we
+         ;; let-bind `jka-compr-inhibit' to t.
+         (jka-compr-inhibit t))
       (with-parsed-tramp-file-name (if t1 filename newname) nil
        (unless (file-exists-p filename)
          (tramp-error
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index ed3d153..2274efd 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1708,6 +1708,12 @@ ID-FORMAT valid values are `string' and `integer'."
             (= (tramp-compat-file-attribute-user-id attributes)
                (tramp-get-remote-uid v 'integer))
             (or (not group)
+                ;; On BSD-derived systems files always inherit the
+                 ;; parent directory's group, so skip the group-gid
+                 ;; test.
+                (string-match-p
+                 "BSD\\|DragonFly\\|Darwin"
+                 (tramp-get-connection-property v "uname" ""))
                 (= (tramp-compat-file-attribute-group-id attributes)
                    (tramp-get-remote-gid v 'integer)))))))))
 
diff --git a/lisp/net/webjump.el b/lisp/net/webjump.el
index e5941ae..1fa625c 100644
--- a/lisp/net/webjump.el
+++ b/lisp/net/webjump.el
@@ -96,9 +96,6 @@
     ("DuckDuckGo" .
      [simple-query "duckduckgo.com"
                   "duckduckgo.com/?q=" ""])
-    ("Google" .
-     [simple-query "www.google.com"
-                  "www.google.com/search?q=" ""])
     ("Google Groups" .
      [simple-query "groups.google.com"
                   "groups.google.com/groups?q=" ""])
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 5d0d105..ea47eec 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -832,12 +832,17 @@ Ensure that `comment-normalize-vars' has been called 
before you use this."
   (when (and (stringp str) (string-match "\\S-" str))
     ;; Separate the actual string from any leading/trailing padding
     (string-match "\\`\\s-*\\(.*?\\)\\s-*\\'" str)
-    (let ((s (match-string 1 str))     ;actual string
+    (let ((s (match-string 1 str))                     ;actual string
          (lpad (substring str 0 (match-beginning 1))) ;left padding
-         (rpad (concat (substring str (match-end 1)) ;original right padding
-                       (substring comment-padding ;additional right padding
-                                  (min (- (match-end 0) (match-end 1))
-                                       (length comment-padding)))))
+         (rpad (concat
+                 (substring str (match-end 1)) ;original right padding
+                 (if (numberp comment-padding)
+                     (make-string (min comment-padding
+                                       (- (match-end 0) (match-end 1)))
+                                  ?\s)
+                  (substring comment-padding ;additional right padding
+                             (min (- (match-end 0) (match-end 1))
+                                  (length comment-padding))))))
          ;; We can only duplicate C if the comment-end has multiple chars
          ;; or if comments can be nested, else the comment-end `}' would
          ;; be turned into `}}}' where only the first ends the comment
@@ -852,7 +857,7 @@ Ensure that `comment-normalize-vars' has been called before 
you use this."
        (concat (mapconcat (lambda (c) (concat (regexp-quote (string c)) "?"))
                           lpad "")     ;padding is not required
                (regexp-quote s)
-               (when multi "+")        ;the last char of S might be repeated
+               (when multi "+") ;the last char of S might be repeated
                (mapconcat (lambda (c) (concat (regexp-quote (string c)) "?"))
                           rpad "")))))) ;padding is not required
 
@@ -1221,21 +1226,33 @@ changed with `comment-style'."
     ;; FIXME: maybe we should call uncomment depending on ARG.
     (funcall comment-region-function beg end arg)))
 
-(defun comment-region-default-1 (beg end &optional arg)
+(defun comment-region-default-1 (beg end &optional arg noadjust)
+  "Comment region between BEG and END.
+See `comment-region' for ARG.  If NOADJUST, do not skip past
+leading/trailing space when determining the region to comment
+out."
   (let* ((numarg (prefix-numeric-value arg))
         (style (cdr (assoc comment-style comment-styles)))
         (lines (nth 2 style))
         (block (nth 1 style))
         (multi (nth 0 style)))
 
-    ;; We use `chars' instead of `syntax' because `\n' might be
-    ;; of end-comment syntax rather than of whitespace syntax.
-    ;; sanitize BEG and END
-    (goto-char beg) (skip-chars-forward " \t\n\r") (beginning-of-line)
-    (setq beg (max beg (point)))
-    (goto-char end) (skip-chars-backward " \t\n\r") (end-of-line)
-    (setq end (min end (point)))
-    (if (>= beg end) (error "Nothing to comment"))
+    (if noadjust
+        (when (bolp)
+          (setq end (1- end)))
+      ;; We use `chars' instead of `syntax' because `\n' might be
+      ;; of end-comment syntax rather than of whitespace syntax.
+      ;; sanitize BEG and END
+      (goto-char beg)
+      (skip-chars-forward " \t\n\r")
+      (beginning-of-line)
+      (setq beg (max beg (point)))
+      (goto-char end)
+      (skip-chars-backward " \t\n\r")
+      (end-of-line)
+      (setq end (min end (point)))
+      (when (>= beg end)
+        (error "Nothing to comment")))
 
     ;; sanitize LINES
     (setq lines
diff --git a/lisp/nxml/rng-util.el b/lisp/nxml/rng-util.el
index 59465c3..a20e950 100644
--- a/lisp/nxml/rng-util.el
+++ b/lisp/nxml/rng-util.el
@@ -1,4 +1,4 @@
-;;; rng-util.el --- utility functions for RELAX NG library
+;;; rng-util.el --- utility functions for RELAX NG library  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 2003, 2007-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/obsolete/nnir.el b/lisp/obsolete/nnir.el
index 0b7d1e4..147efed 100644
--- a/lisp/obsolete/nnir.el
+++ b/lisp/obsolete/nnir.el
@@ -504,6 +504,7 @@ Add an entry here when adding a new search engine.")
                        ,@(mapcar (lambda (elem) (list 'const (car elem)))
                                  nnir-engines)))))
 
+
 (defmacro nnir-add-result (dirnam artno score prefix server artlist)
   "Construct a result vector and add it to ARTLIST.
 DIRNAM, ARTNO, SCORE, PREFIX and SERVER are passed to
diff --git a/lisp/org/ol.el b/lisp/org/ol.el
index d1db168..994e30f 100644
--- a/lisp/org/ol.el
+++ b/lisp/org/ol.el
@@ -376,9 +376,9 @@ changes to the current buffer."
 
 Shell links can be dangerous: just think about a link
 
-     [[shell:rm -rf ~/*][Google Search]]
+     [[shell:rm -rf ~/*][Web Search]]
 
-This link would show up in your Org document as \"Google Search\",
+This link would show up in your Org document as \"Web Search\",
 but really it would remove your entire home directory.
 Therefore we advise against setting this variable to nil.
 Just change it to `y-or-n-p' if you want to confirm with a
@@ -401,9 +401,9 @@ single keystroke rather than having to type \"yes\"."
   "Non-nil means ask for confirmation before executing Emacs Lisp links.
 Elisp links can be dangerous: just think about a link
 
-     [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]]
+     [[elisp:(shell-command \"rm -rf ~/*\")][Web Search]]
 
-This link would show up in your Org document as \"Google Search\",
+This link would show up in your Org document as \"Web Search\",
 but really it would remove your entire home directory.
 Therefore we advise against setting this variable to nil.
 Just change it to `y-or-n-p' if you want to confirm with a
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 43aa0a1..2d21a44 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -1846,7 +1846,7 @@ link types.  The types are:
 bracket   The recommended [[link][description]] or [[link]] links with hiding.
 angle     Links in angular brackets that may contain whitespace like
           <bbdb:Carsten Dominik>.
-plain     Plain links in normal text, no whitespace, like http://google.com.
+plain     Plain links in normal text, no whitespace, like https://gnu.org.
 radio     Text that is matched by a radio target, see manual for details.
 tag       Tag settings in a headline (link to tag search).
 date      Time stamps (link to calendar).
diff --git a/lisp/play/handwrite.el b/lisp/play/handwrite.el
index 7ad3de6..98da26c 100644
--- a/lisp/play/handwrite.el
+++ b/lisp/play/handwrite.el
@@ -1,8 +1,9 @@
-;;; handwrite.el --- turns your emacs buffer into a handwritten document
+;;; handwrite.el --- turns your emacs buffer into a handwritten document  -*- 
lexical-binding: t -*-
 
 ;; Copyright (C) 1996, 2001-2021 Free Software Foundation, Inc.
 
 ;; Author: Danny Roozendaal (was: <danny@tvs.kun.nl>)
+;; Maintainer: emacs-devel@gnu.org
 ;; Created: October 21 1996
 ;; Keywords: wp, print, postscript, cursive writing
 
@@ -22,11 +23,11 @@
 ;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
 
 ;;; Commentary:
+
+;; The function `handwrite' creates PostScript output containing a
+;; handwritten version of the current buffer.
 ;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; The function handwrite creates PostScript output containing a
-;; handwritten version of the current buffer..
-;; Other functions that may be useful are
+;; Other functions that may be useful are:
 ;;
 ;;      handwrite-10pt: sets the font size to 10 and finds corresponding
 ;;                      values for the line spacing and the number of lines
@@ -54,8 +55,6 @@
 ;;              unknown characters.
 ;;
 ;; Thanks to anyone who emailed me suggestions!
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
 ;;; Code:
 
@@ -64,7 +63,6 @@
 (defvar ps-lpr-command)
 (defvar ps-lpr-switches)
 
-
 ;; Variables
 
 (defgroup handwrite nil
@@ -98,44 +96,43 @@
 
 (defcustom handwrite-numlines 60
   "The number of lines on a page of the PostScript output from `handwrite'."
-  :type 'integer
-  :group 'handwrite)
+  :type 'integer)
+
 (defcustom handwrite-fontsize 11
   "The size of the font for the PostScript output from `handwrite'."
-  :type 'integer
-  :group 'handwrite)
+  :type 'integer)
+
 (defcustom handwrite-linespace 12
   "The spacing for the PostScript output from `handwrite'."
-  :type 'integer
-  :group 'handwrite)
+  :type 'integer)
+
 (defcustom handwrite-xstart 30
   "X-axis translation in the PostScript output from `handwrite'."
-  :type 'integer
-  :group 'handwrite)
+  :type 'integer)
+
 (defcustom handwrite-ystart 810
   "Y-axis translation in the PostScript output from `handwrite'."
-  :type 'integer
-  :group 'handwrite)
+  :type 'integer)
+
 (defcustom handwrite-pagenumbering nil
   "If non-nil, number each page of the PostScript output from `handwrite'."
-  :type 'boolean
-  :group 'handwrite)
+  :type 'boolean)
+
 (defcustom handwrite-10pt-numlines 65
   "The number of lines on a page for the function `handwrite-10pt'."
-  :type 'integer
-  :group 'handwrite)
+  :type 'integer)
+
 (defcustom handwrite-11pt-numlines 60
   "The number of lines on a page for the function `handwrite-11pt'."
-  :type 'integer
-  :group 'handwrite)
+  :type 'integer)
+
 (defcustom handwrite-12pt-numlines 55
   "The number of lines on a page for the function `handwrite-12pt'."
-  :type 'integer
-  :group 'handwrite)
+  :type 'integer)
+
 (defcustom handwrite-13pt-numlines 50
   "The number of lines on a page for the function `handwrite-13pt'."
-  :type 'integer
-  :group 'handwrite)
+  :type 'integer)
 
 ;; Interactive functions
 
@@ -150,17 +147,17 @@ Variables: `handwrite-linespace'     (default 12)
            `handwrite-numlines'      (default 60)
            `handwrite-pagenumbering' (default nil)"
   (interactive)
+  (setq handwrite-psindex (1+ handwrite-psindex))
   (let
-      (;(pmin)                         ; thanks, Havard
-       (cur-buf (current-buffer))
+      ((cur-buf (current-buffer))
        (tpoint (point))
        (ps-ypos 63)
        (lcount 0)
        (ipage 1)
-       (nlan next-line-add-newlines)   ;remember the old value
+       (next-line-add-newlines t)
        (buf-name (buffer-name) )
        (textp)
-       (ps-buf-name)                   ;name of the PostScript buffer
+       (ps-buf-name (format "*handwritten%d.ps*" handwrite-psindex))
        (trans-table
        '(("ÿ" . "264") ("á" . "207") ("à" . "210") ("â" . "211")
          ("ä" . "212") ("ã" . "213") ("å" . "214") ("é" . "216")
@@ -175,10 +172,6 @@ Variables: `handwrite-linespace'     (default 12)
                                        ; on inserted backslashes
        line)
     (goto-char (point-min))            ;start at beginning
-    (setq handwrite-psindex (1+ handwrite-psindex))
-    (setq ps-buf-name
-         (format "*handwritten%d.ps*" handwrite-psindex))
-    (setq next-line-add-newlines t)
     (switch-to-buffer ps-buf-name)
     (handwrite-insert-header buf-name)
     (insert "%%Creator: GNU Emacs's handwrite version " emacs-version  "\n")
@@ -258,9 +251,7 @@ Variables: `handwrite-linespace'     (default 12)
     (message "")
     (bury-buffer ())
     (switch-to-buffer cur-buf)
-    (goto-char tpoint)
-    (setq next-line-add-newlines nlan)
-    ))
+    (goto-char tpoint)))
 
 
 (defun handwrite-set-pagenumber ()
@@ -280,7 +271,6 @@ values for `handwrite-linespace' and `handwrite-numlines'."
   (setq handwrite-numlines handwrite-10pt-numlines)
   (message "Handwrite output size set to 10 points"))
 
-
 (defun handwrite-11pt ()
   "Specify 11-point output for `handwrite'.
 This sets `handwrite-fontsize' to 11 and finds correct
@@ -1238,28 +1228,16 @@ end
 /Joepie Hwfdict definefont
 %%EndFont Joepie\n\n"))
 
-;;Sets page numbering off
 (defun handwrite-set-pagenumber-off ()
+  "Set page numbering off."
   (setq handwrite-pagenumbering nil)
   (message "page numbering off"))
 
-;;Sets page numbering on
 (defun handwrite-set-pagenumber-on ()
+  "Set page numbering on."
   (setq handwrite-pagenumbering t)
   (message "page numbering on" ))
 
-
-;; Key bindings
-
-;; I'd rather not fill up the menu bar menus with
-;; lots of random miscellaneous features. -- rms.
-;;;(define-key-after
-;;;  (lookup-key global-map [menu-bar edit])
-;;;  [handwrite]
-;;;  '("Write by hand" . menu-bar-handwrite-map)
-;;;  'spell)
-
 (provide 'handwrite)
 
-
 ;;; handwrite.el ends here
diff --git a/lisp/play/mpuz.el b/lisp/play/mpuz.el
index 7fff604..838bddf 100644
--- a/lisp/play/mpuz.el
+++ b/lisp/play/mpuz.el
@@ -1,4 +1,4 @@
-;;; mpuz.el --- multiplication puzzle for GNU Emacs
+;;; mpuz.el --- multiplication puzzle for GNU Emacs  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 1990, 2001-2021 Free Software Foundation, Inc.
 
@@ -40,49 +40,41 @@
 The value t means never ding, and `error' means only ding on wrong input."
   :type '(choice (const :tag "No" nil)
                 (const :tag "Yes" t)
-                (const :tag "If correct" error))
-  :group 'mpuz)
+                 (const :tag "If correct" error)))
 
 (defcustom mpuz-solve-when-trivial t
   "Solve any row that can be trivially calculated from what you've found."
-  :type 'boolean
-  :group 'mpuz)
+  :type 'boolean)
 
 (defcustom mpuz-allow-double-multiplicator nil
   "Allow 2nd factors like 33 or 77."
-  :type 'boolean
-  :group 'mpuz)
+  :type 'boolean)
 
 (defface mpuz-unsolved
   '((default :weight bold)
     (((class color)) :foreground "red1"))
-  "Face for letters to be solved."
-  :group 'mpuz)
+  "Face for letters to be solved.")
 
 (defface mpuz-solved
   '((default :weight bold)
     (((class color)) :foreground "green1"))
-  "Face for solved digits."
-  :group 'mpuz)
+  "Face for solved digits.")
 
 (defface mpuz-trivial
   '((default :weight bold)
     (((class color)) :foreground "blue"))
-  "Face for trivial digits solved for you."
-  :group 'mpuz)
+  "Face for trivial digits solved for you.")
 
 (defface mpuz-text
   '((t :inherit variable-pitch))
-  "Face for text on right."
-  :group 'mpuz)
+  "Face for text on right.")
 
 
 ;; Mpuz mode and keymaps
 ;;----------------------
 (defcustom mpuz-mode-hook nil
   "Hook to run upon entry to mpuz."
-  :type 'hook
-  :group 'mpuz)
+  :type 'hook)
 
 (defvar mpuz-mode-map
   (let ((map (make-sparse-keymap)))
@@ -341,8 +333,8 @@ You may abort a game by typing 
\\<mpuz-mode-map>\\[mpuz-offer-abort]."
 
 (defun mpuz-switch-to-window ()
   "Find or create the Mult-Puzzle buffer, and display it."
-  (let ((buf (mpuz-get-buffer)))
-    (or buf (setq buf (mpuz-create-buffer)))
+  (let ((buf (or (mpuz-get-buffer)
+                 (mpuz-create-buffer))))
     (switch-to-buffer buf)
     (setq buffer-read-only t)
     (mpuz-mode)))
diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el
index 62ff783..99b2ec6 100644
--- a/lisp/progmodes/asm-mode.el
+++ b/lisp/progmodes/asm-mode.el
@@ -141,8 +141,7 @@ Special commands:
   (setq-local comment-add 1)
   (setq-local comment-start-skip "\\(?:\\s<+\\|/[/*]+\\)[ \t]*")
   (setq-local comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)")
-  (setq-local comment-end "")
-  (setq fill-prefix "\t"))
+  (setq-local comment-end ""))
 
 (defun asm-indent-line ()
   "Auto-indent the current line."
diff --git a/lisp/progmodes/bat-mode.el b/lisp/progmodes/bat-mode.el
index 44295c3..7ba8a69 100644
--- a/lisp/progmodes/bat-mode.el
+++ b/lisp/progmodes/bat-mode.el
@@ -1,4 +1,4 @@
-;;; bat-mode.el --- Major mode for editing DOS/Windows scripts
+;;; bat-mode.el --- Major mode for editing DOS/Windows scripts  -*- 
lexical-binding: t -*-
 
 ;; Copyright (C) 2003, 2008-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 94e4f3c..2c1e6ff 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -3041,7 +3041,12 @@ TRUE-DIRNAME is the `file-truename' of DIRNAME, if 
given."
            ;; Get the specified directory from FILE.
            (spec-directory
              (if (cdr file)
-                (file-truename (concat comint-file-name-prefix (cdr file))))))
+                 ;; This function is active in `compilation-filter'.
+                 ;; There could be problems to call `file-truename'
+                 ;; for remote compilation processes.
+                (if (file-remote-p default-directory)
+                    (concat comint-file-name-prefix (cdr file))
+                  (file-truename (concat comint-file-name-prefix (cdr 
file)))))))
 
        ;; Check for a comint-file-name-prefix and prepend it if appropriate.
        ;; (This is very useful for compilation-minor-mode in an rlogin-mode
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 460af71..5d96c62 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -352,12 +352,20 @@ diagnostics at BEG."
 (flymake--diag-accessor flymake-diagnostic-data flymake--diag-data backend)
 
 (defun flymake-diagnostic-beg (diag)
-  "Get Flymake diagnostic DIAG's start position."
-  (overlay-start (flymake--diag-overlay diag)))
+  "Get Flymake diagnostic DIAG's start position.
+This position only be queried after DIAG has been reported to Flymake."
+  (let ((overlay (flymake--diag-overlay diag)))
+    (unless overlay
+      (error "DIAG %s not reported to Flymake yet" diag))
+    (overlay-start overlay)))
 
 (defun flymake-diagnostic-end (diag)
-  "Get Flymake diagnostic DIAG's end position."
-  (overlay-end (flymake--diag-overlay diag)))
+  "Get Flymake diagnostic DIAG's end position.
+This position only be queried after DIAG has been reported to Flymake."
+  (let ((overlay (flymake--diag-overlay diag)))
+    (unless overlay
+      (error "DIAG %s not reported to Flymake yet" diag))
+    (overlay-end overlay)))
 
 (cl-defun flymake--overlays (&key beg end filter compare key)
   "Get flymake-related overlays.
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index d047dd5..0120e4a 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -143,7 +143,7 @@
   '(;; Functions
     (nil "^[ \t]*sub\\s-+\\([-[:alnum:]+_:]+\\)" 1)
     ;;Variables
-    ("Variables" "^[ 
\t]*\\(?:anon\\|argument\\|has\\|local\\|my\\|our\\|state\\|supersede\\)\\s-+\\([$@%][-[:alnum:]+_:]+\\)\\s-*="
 1)
+    ("Variables" "^[ 
\t]*\\(?:has\\|local\\|my\\|our\\|state\\)\\s-+\\([$@%][-[:alnum:]+_:]+\\)\\s-*="
 1)
     ("Packages" "^[ \t]*package\\s-+\\([-[:alnum:]+_:]+\\);" 1)
     ("Doc sections" "^=head[0-9][ \t]+\\(.*\\)" 1))
   "Imenu generic expression for Perl mode.  See `imenu-generic-expression'.")
@@ -188,9 +188,8 @@
               "\\>")
      ;;
      ;; Fontify declarators and prefixes as types.
-     
("\\<\\(anon\\|argument\\|has\\|local\\|my\\|our\\|state\\|supersede\\)\\>" . 
font-lock-type-face) ; declarators
-     ("\\<\\(let\\|temp\\)\\>" . font-lock-type-face) ; prefixes
-     ;;
+     ("\\<\\(has\\|local\\|my\\|our\\|state\\)\\>" . font-lock-type-face) ; 
declarators
+          ;;
      ;; Fontify function, variable and file name references.
      ("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face)
      ;; Additionally fontify non-scalar variables.  `perl-non-scalar-variable'
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 768cd58..fc5e301 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1,8 +1,8 @@
 ;;; project.el --- Operations on the current project  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
-;; Version: 0.5.3
-;; Package-Requires: ((emacs "26.3") (xref "1.0.2"))
+;; Version: 0.5.4
+;; Package-Requires: ((emacs "26.1") (xref "1.0.2"))
 
 ;; This is a GNU ELPA :core package.  Avoid using functionality that
 ;; not compatible with the version of Emacs recorded above.
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index cc045a1..fd68952 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1957,12 +1957,18 @@ May return nil if the line should not be treated as 
continued."
     ('(:after . "case-)") (- (sh-var-value 'sh-indent-for-case-alt)
                              (sh-var-value 'sh-indent-for-case-label)))
     (`(:before . ,(or "(" "{" "[" "while" "if" "for" "case"))
-     (if (not (smie-rule-prev-p "&&" "||" "|"))
-         (when (smie-rule-hanging-p)
-           (smie-rule-parent))
+     (cond
+      ((and (equal token "{") (smie-rule-parent-p "for"))
+       (let ((data (smie-backward-sexp "in")))
+         (when (equal (nth 2 data) "for")
+           `(column . ,(smie-indent-virtual)))))
+      ((not (smie-rule-prev-p "&&" "||" "|"))
+       (when (smie-rule-hanging-p)
+         (smie-rule-parent)))
+      (t
        (unless (smie-rule-bolp)
         (while (equal "|" (nth 2 (smie-backward-sexp 'halfexp))))
-        `(column . ,(smie-indent-virtual)))))
+        `(column . ,(smie-indent-virtual))))))
     ;; FIXME: Maybe this handling of ;; should be made into
     ;; a smie-rule-terminator function that takes the substitute ";" as arg.
     (`(:before . ,(or ";;" ";&" ";;&"))
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 898cb4f..18fdd96 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2014-2021 Free Software Foundation, Inc.
 ;; Version: 1.0.4
-;; Package-Requires: ((emacs "26.3"))
+;; Package-Requires: ((emacs "26.1"))
 
 ;; This is a GNU ELPA :core package.  Avoid functionality that is not
 ;; compatible with the version of Emacs recorded above.
@@ -972,6 +972,7 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)."
             (erase-buffer)
             (xref--insert-xrefs alist))
         (user-error
+         (erase-buffer)
          (insert
           (propertize
            (error-message-string err)
diff --git a/lisp/recentf.el b/lisp/recentf.el
index a28a397..d39a523 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -1352,7 +1352,14 @@ That is, remove duplicates, non-kept, and excluded 
files."
 
 When Recentf mode is enabled, a \"Open Recent\" submenu is
 displayed in the \"File\" menu, containing a list of files that
-were operated on recently, in the most-recently-used order."
+were operated on recently, in the most-recently-used order.
+
+By default, only operations like opening a file, writing a buffer
+to a file, and killing a buffer is counted as \"operating\" on
+the file.  If instead you want to prioritize files that appear in
+buffers you switch to a lot, you can say something like the following:
+
+  (add-hook 'buffer-list-update-hook 'recentf-track-opened-file)"
   :global t
   :group 'recentf
   :keymap recentf-mode-map
diff --git a/lisp/replace.el b/lisp/replace.el
index db5b340..f13d27a 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -186,6 +186,21 @@ See `replace-regexp' and `query-replace-regexp-eval'.")
                         length)
              length)))))
 
+(defun query-replace-read-from-suggestions ()
+  "Return a list of standard suggestions for `query-replace-read-from'.
+By default, the list includes the active region, the identifier
+(a.k.a. \"tag\") at point (see Info node `(emacs) Identifier Search'),
+the last isearch string, and the last replacement regexp.
+`query-replace-read-from' appends the list returned
+by this function to the end of values available via
+\\<minibuffer-local-map>\\[next-history-element]."
+  (delq nil (list (when (use-region-p)
+                    (buffer-substring-no-properties
+                     (region-beginning) (region-end)))
+                  (find-tag-default)
+                  (car search-ring)
+                  (car (symbol-value query-replace-from-history-variable)))))
+
 (defun query-replace-read-from (prompt regexp-flag)
   "Query and return the `from' argument of a query-replace operation.
 Prompt with PROMPT.  REGEXP-FLAG non-nil means the response should be a regexp.
@@ -242,7 +257,8 @@ wants to replace FROM with TO."
                 (if regexp-flag
                     (read-regexp prompt nil 'minibuffer-history)
                   (read-from-minibuffer
-                   prompt nil nil nil nil (car search-ring) t)))))
+                   prompt nil nil nil nil
+                   (query-replace-read-from-suggestions) t)))))
            (to))
       (if (and (zerop (length from)) query-replace-defaults)
          (cons (caar query-replace-defaults)
@@ -327,14 +343,15 @@ Prompt with PROMPT.  REGEXP-FLAG non-nil means the 
response should a regexp."
 (defun query-replace-read-args (prompt regexp-flag &optional noerror)
   (unless noerror
     (barf-if-buffer-read-only))
-  (let* ((from (query-replace-read-from prompt regexp-flag))
-        (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
-              (query-replace-read-to from prompt regexp-flag))))
-    (list from to
-         (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
-              (and (plist-member (text-properties-at 0 from) 
'isearch-regexp-function)
-                   (get-text-property 0 'isearch-regexp-function from)))
-         (and current-prefix-arg (eq current-prefix-arg '-)))))
+  (save-mark-and-excursion
+    (let* ((from (query-replace-read-from prompt regexp-flag))
+           (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
+                 (query-replace-read-to from prompt regexp-flag))))
+      (list from to
+            (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
+                (and (plist-member (text-properties-at 0 from) 
'isearch-regexp-function)
+                     (get-text-property 0 'isearch-regexp-function from)))
+            (and current-prefix-arg (eq current-prefix-arg '-))))))
 
 (defun query-replace (from-string to-string &optional delimited start end 
backward region-noncontiguous-p)
   "Replace some occurrences of FROM-STRING with TO-STRING.
@@ -808,11 +825,16 @@ the function that you set this to can check 
`this-command'."
 
 (defun read-regexp-suggestions ()
   "Return a list of standard suggestions for `read-regexp'.
-By default, the list includes the tag at point, the last isearch regexp,
-the last isearch string, and the last replacement regexp.  `read-regexp'
-appends the list returned by this function to the end of values available
-via \\<minibuffer-local-map>\\[next-history-element]."
+By default, the list includes the active region, the identifier
+(a.k.a. \"tag\") at point (see Info node `(emacs) Identifier Search'),
+the last isearch regexp, the last isearch string, and the last
+replacement regexp.  `read-regexp' appends the list returned
+by this function to the end of values available via
+\\<minibuffer-local-map>\\[next-history-element]."
   (list
+   (when (use-region-p)
+     (buffer-substring-no-properties
+      (region-beginning) (region-end)))
    (find-tag-default-as-regexp)
    (find-tag-default-as-symbol-regexp)
    (car regexp-search-ring)
@@ -825,31 +847,35 @@ Prompt with the string PROMPT.  If PROMPT ends in \":\" 
(followed by
 optional whitespace), use it as-is.  Otherwise, add \": \" to the end,
 possibly preceded by the default result (see below).
 
-The optional argument DEFAULTS can be either: nil, a string, a list
-of strings, or a symbol.  We use DEFAULTS to construct the default
-return value in case of empty input.
+The optional argument DEFAULTS is used to construct the default
+return value in case of empty input.  DEFAULTS can be nil, a string,
+a list of strings, or a symbol.
 
-If DEFAULTS is a string, we use it as-is.
+If DEFAULTS is a string, the function uses it as-is.
 
 If DEFAULTS is a list of strings, the first element is the
 default return value, but all the elements are accessible
 using the history command \\<minibuffer-local-map>\\[next-history-element].
 
-If DEFAULTS is a non-nil symbol, then if `read-regexp-defaults-function'
-is non-nil, we use that in place of DEFAULTS in the following:
-  If DEFAULTS is the symbol `regexp-history-last', we use the first
-  element of HISTORY (if specified) or `regexp-history'.
-  If DEFAULTS is a function, we call it with no arguments and use
-  what it returns, which should be either nil, a string, or a list of strings.
+If DEFAULTS is the symbol `regexp-history-last', the default return
+value will be the first element of HISTORY.  If HISTORY is omitted or
+nil, `regexp-history' is used instead.
+If DEFAULTS is a symbol with a function definition, it is called with
+no arguments and should return either nil, a string, or a list of
+strings, which will be used as above.
+Other symbol values for DEFAULTS are ignored.
+
+If `read-regexp-defaults-function' is non-nil, its value is used
+instead of DEFAULTS in the two cases described in the last paragraph.
 
-We append the standard values from `read-regexp-suggestions' to DEFAULTS
-before using it.
+Before using whatever value DEFAULTS yields, the function appends the
+standard values from `read-regexp-suggestions' to that value.
 
 If the first element of DEFAULTS is non-nil (and if PROMPT does not end
-in \":\", followed by optional whitespace), we add it to the prompt.
+in \":\", followed by optional whitespace), DEFAULT is added to the prompt.
 
 The optional argument HISTORY is a symbol to use for the history list.
-If nil, uses `regexp-history'."
+If nil, use `regexp-history'."
   (let* ((defaults
           (if (and defaults (symbolp defaults))
               (cond
diff --git a/lisp/simple.el b/lisp/simple.el
index 8d4e4a7..742fc50 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2472,11 +2472,24 @@ previous element of the minibuffer history in the 
minibuffer."
                                   (save-excursion
                                     (goto-char (1- prompt-end))
                                     (current-column)))
-                               0)
+                               1)
                         (current-column)))))
     (condition-case nil
        (with-no-warnings
-         (previous-line arg))
+         (previous-line arg)
+          ;; Avoid moving point to the prompt
+          (when (< (point) (minibuffer-prompt-end))
+            ;; If there is minibuffer contents on the same line
+            (if (<= (minibuffer-prompt-end)
+                    (save-excursion
+                      (if (or truncate-lines (not line-move-visual))
+                          (end-of-line)
+                        (end-of-visual-line))
+                      (point)))
+                ;; Move to the beginning of minibuffer contents
+                (goto-char (minibuffer-prompt-end))
+              ;; Otherwise, go to the previous history element
+              (signal 'beginning-of-buffer nil))))
       (beginning-of-buffer
        ;; Restore old position since `line-move-visual' moves point to
        ;; the beginning of the line when it fails to go to the previous line.
@@ -3978,6 +3991,9 @@ impose the use of a shell (with its need to quote 
arguments)."
                          (start-process-shell-command "Shell" buffer command)))
                  (setq mode-line-process '(":%s"))
                   (shell-mode)
+                  (setq-local revert-buffer-function
+                              (lambda (&rest _)
+                                (async-shell-command command buffer)))
                   (set-process-sentinel proc #'shell-command-sentinel)
                  ;; Use the comint filter for proper handling of
                  ;; carriage motion (see comint-inhibit-carriage-motion).
@@ -4244,6 +4260,9 @@ characters."
                                              buffer))))
             ;; Report the output.
             (with-current-buffer buffer
+              (setq-local revert-buffer-function
+                          (lambda (&rest _)
+                            (shell-command command)))
               (setq mode-line-process
                     (cond ((null exit-status)
                            " - Error")
diff --git a/lisp/startup.el b/lisp/startup.el
index 09635b1..ec58418 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -320,6 +320,8 @@ early init file.")
 This variable is used to define the proper function and keypad
 keys for use under X.  It is used in a fashion analogous to the
 environment variable TERM.")
+(make-obsolete-variable 'keyboard-type nil "28.1")
+(internal-make-var-non-special 'keyboard-type)
 
 (defvar window-setup-hook nil
   "Normal hook run after loading init files and handling the command line.
diff --git a/lisp/subr.el b/lisp/subr.el
index b1295a0..b5f7dfd 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2970,8 +2970,6 @@ Also discard all previous input in the minibuffer."
     (minibuffer-message "Wrong answer")
     (sit-for 2)))
 
-(defvar empty-history)
-
 (defun read-char-from-minibuffer (prompt &optional chars history)
   "Read a character from the minibuffer, prompting for it with PROMPT.
 Like `read-char', but uses the minibuffer to read and return a character.
@@ -2986,6 +2984,7 @@ while calling this function, then pressing `help-char'
 causes it to evaluate `help-form' and display the result.
 There is no need to explicitly add `help-char' to CHARS;
 `help-char' is bound automatically to `help-form-show'."
+  (defvar empty-history)
   (let* ((empty-history '())
          (map (if (consp chars)
                   (or (gethash (list help-form (cons help-char chars))
@@ -3098,8 +3097,6 @@ Also discard all previous input in the minibuffer."
   "Prefer `read-key' when answering a \"y or n\" question by `y-or-n-p'.
 Otherwise, use the minibuffer.")
 
-(defvar empty-history)
-
 (defun y-or-n-p (prompt)
   "Ask user a \"y or n\" question.
 Return t if answer is \"y\" and nil if it is \"n\".
@@ -3195,6 +3192,7 @@ is nil and `use-dialog-box' is non-nil."
         (discard-input)))
      (t
       (setq prompt (funcall padded prompt))
+      (defvar empty-history)
       (let* ((empty-history '())
              (enable-recursive-minibuffers t)
              (msg help-form)
@@ -4928,7 +4926,9 @@ file, FORM is evaluated immediately after the provide 
statement.
 Usually FILE is just a library name like \"font-lock\" or a feature name
 like `font-lock'.
 
-This function makes or adds to an entry on `after-load-alist'."
+This function makes or adds to an entry on `after-load-alist'.
+
+See also `with-eval-after-load'."
   (declare (compiler-macro
             (lambda (whole)
               (if (eq 'quote (car-safe form))
diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index 2726947..9209f2d 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -651,7 +651,9 @@ corresponding to the switched buffer."
   (if (functionp tab-line-new-tab-choice)
       (funcall tab-line-new-tab-choice)
     (let ((tab-line-tabs-buffer-groups mouse-buffer-menu-mode-groups))
-      (if (and (listp mouse-event) window-system) ; (display-popup-menus-p)
+      (if (and (listp mouse-event)
+               (display-popup-menus-p)
+               (not tty-menu-open-use-tmm))
           (mouse-buffer-menu mouse-event) ; like (buffer-menu-open)
         ;; tty menu doesn't support mouse clicks, so use tmm
         (tmm-prompt (mouse-buffer-menu-keymap))))))
diff --git a/lisp/term/w32console.el b/lisp/term/w32console.el
index 8859f13..4a925cd 100644
--- a/lisp/term/w32console.el
+++ b/lisp/term/w32console.el
@@ -1,4 +1,4 @@
-;;; w32console.el -- Setup w32 console keys and colors.
+;;; w32console.el -- Setup w32 console keys and colors.  -*- lexical-binding: 
t; -*-
 
 ;; Copyright (C) 2007-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/textmodes/nroff-mode.el b/lisp/textmodes/nroff-mode.el
index 8965785..fe70e92 100644
--- a/lisp/textmodes/nroff-mode.el
+++ b/lisp/textmodes/nroff-mode.el
@@ -1,4 +1,4 @@
-;;; nroff-mode.el --- GNU Emacs major mode for editing nroff source
+;;; nroff-mode.el --- GNU Emacs major mode for editing nroff source  -*- 
lexical-binding: t -*-
 
 ;; Copyright (C) 1985-1986, 1994-1995, 1997, 2001-2021 Free Software
 ;; Foundation, Inc.
@@ -43,7 +43,6 @@
 
 (defcustom nroff-electric-mode nil
   "Non-nil means automatically closing requests when you insert an open."
-  :group 'nroff
   :type 'boolean)
 
 (defvar nroff-mode-map
@@ -111,7 +110,7 @@
    ;; arguments in common cases, like \f.
    (concat "\\\\"                    ; backslash
         "\\("                        ; followed by various possibilities
-        (mapconcat 'identity
+         (mapconcat #'identity
                    '("[f*n]*\\[.+?]" ; some groff extensions
                      "(.."           ; two chars after (
                      "[^(\"#]"       ; single char escape
@@ -119,13 +118,11 @@
         "\\)")
    )
   "Font-lock highlighting control in `nroff-mode'."
-  :group 'nroff
   :type '(repeat regexp))
 
 (defcustom nroff-mode-hook nil
   "Hook run by function `nroff-mode'."
-  :type 'hook
-  :group 'nroff)
+  :type 'hook)
 
 ;;;###autoload
 (define-derived-mode nroff-mode text-mode "Nroff"
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 8465e82..c50c544 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -2402,9 +2402,9 @@ To work around that, do:
 
   (setq-local sgml-empty-tags
              ;; From HTML-4.01's loose.dtd, parsed with
-             ;; `sgml-parse-dtd', plus manual addition of "wbr".
+              ;; `sgml-parse-dtd', plus manual additions of "source" and "wbr".
              '("area" "base" "basefont" "br" "col" "frame" "hr" "img" "input"
-               "isindex" "link" "meta" "param" "wbr"))
+                "isindex" "link" "meta" "source" "param" "wbr"))
   (setq-local sgml-unclosed-tags
              ;; From HTML-4.01's loose.dtd, parsed with `sgml-parse-dtd'.
              '("body" "colgroup" "dd" "dt" "head" "html" "li" "option"
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index c4e4864..ce665e6 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1169,7 +1169,12 @@ subshell is initiated, `tex-shell-hook' is run."
   (setq-local outline-regexp latex-outline-regexp)
   (setq-local outline-level #'latex-outline-level)
   (setq-local forward-sexp-function #'latex-forward-sexp)
-  (setq-local skeleton-end-hook nil))
+  (setq-local skeleton-end-hook nil)
+  (setq-local comment-region-function #'latex--comment-region)
+  (setq-local comment-style 'plain))
+
+(defun latex--comment-region (beg end &optional arg)
+  (comment-region-default-1 beg end arg t))
 
 ;;;###autoload
 (define-derived-mode slitex-mode latex-mode "SliTeX"
diff --git a/lisp/tmm.el b/lisp/tmm.el
index e49246a..2040f52 100644
--- a/lisp/tmm.el
+++ b/lisp/tmm.el
@@ -56,12 +56,14 @@ to invoke `tmm-menubar' instead, customize the variable
 `tty-menu-open-use-tmm' to a non-nil value."
   (interactive)
   (run-hooks 'menu-bar-update-hook)
-  (let ((menu-bar (menu-bar-keymap))
-        (menu-bar-item-cons (and x-position
-                                 (menu-bar-item-at-x x-position))))
-    (tmm-prompt menu-bar
-                nil
-                (and menu-bar-item-cons (car menu-bar-item-cons)))))
+  (if isearch-mode
+      (isearch-tmm-menubar)
+    (let ((menu-bar (menu-bar-keymap))
+          (menu-bar-item-cons (and x-position
+                                   (menu-bar-item-at-x x-position))))
+      (tmm-prompt menu-bar
+                  nil
+                  (and menu-bar-item-cons (car menu-bar-item-cons))))))
 
 ;;;###autoload
 (defun tmm-menubar-mouse (event)
diff --git a/lisp/url/url-about.el b/lisp/url/url-about.el
index bff5570..6ae90cc 100644
--- a/lisp/url/url-about.el
+++ b/lisp/url/url-about.el
@@ -1,4 +1,4 @@
-;;; url-about.el --- Show internal URLs
+;;; url-about.el --- Show internal URLs  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2001, 2004-2021 Free Software Foundation, Inc.
 
@@ -44,7 +44,7 @@
 
 (defvar url-scheme-registry)
 
-(defun url-about-protocols (url)
+(defun url-about-protocols (_url)
   (url-probe-protocols)
   (insert "<html>\n"
          " <head>\n"
@@ -73,13 +73,15 @@
                    "ynchronous<br>\n"
                    (if (url-scheme-get-property k 'default-port)
                        (format "Default Port: %d<br>\n"
-                               (url-scheme-get-property k 'default-port)) "")
+                               (url-scheme-get-property k 'default-port))
+                     "")
                    (if (assoc k url-proxy-services)
                        (format "Proxy: %s<br>\n" (assoc k url-proxy-services)) 
""))
            ;; Now the description...
            (insert "    <td valign=top>"
                    (or (url-scheme-get-property k 'description) "N/A"))))
-       (sort (let (x) (maphash (lambda (k v) (push k x)) url-scheme-registry) 
x) 'string-lessp))
+       (sort (let (x) (maphash (lambda (k _v) (push k x)) url-scheme-registry) 
x)
+             #'string-lessp))
   (insert "  </table>\n"
          " </body>\n"
          "</html>\n"))
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index acf88eb..830e6ba 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -1,4 +1,4 @@
-;;; url-cache.el --- Uniform Resource Locator retrieval tool
+;;; url-cache.el --- Uniform Resource Locator retrieval tool  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/url/url-cid.el b/lisp/url/url-cid.el
index d465cab..0ca2d8a 100644
--- a/lisp/url/url-cid.el
+++ b/lisp/url/url-cid.el
@@ -1,4 +1,4 @@
-;;; url-cid.el --- Content-ID URL loader
+;;; url-cid.el --- Content-ID URL loader  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1998-1999, 2004-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/url/url-dav.el b/lisp/url/url-dav.el
index 12d5a68..edb1c1d 100644
--- a/lisp/url/url-dav.el
+++ b/lisp/url/url-dav.el
@@ -1,4 +1,4 @@
-;;; url-dav.el --- WebDAV support
+;;; url-dav.el --- WebDAV support  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2001, 2004-2021 Free Software Foundation, Inc.
 
@@ -133,7 +133,8 @@ Returns nil if WebDAV is not supported."
        (node-type nil)
        (props nil)
        (value nil)
-       (handler-func nil))
+       ;; (handler-func nil)
+       )
     (when (not children)
       (error "No child nodes in DAV:prop"))
 
@@ -453,7 +454,7 @@ FAILURE-RESULTS is a list of (URL STATUS)."
           "  </DAV:owner>\n"))
         (response nil)           ; Responses to the LOCK request
         (result nil)             ; For walking thru the response list
-        (child-url nil)
+        ;; (child-url nil)
         (child-status nil)
         (failures nil)           ; List of failure cases (URL . STATUS)
         (successes nil))         ; List of success cases (URL . STATUS)
@@ -468,7 +469,7 @@ FAILURE-RESULTS is a list of (URL STATUS)."
     ;; status code.
     (while response
       (setq result (pop response)
-           child-url (url-expand-file-name (pop result) url)
+           ;; child-url (url-expand-file-name (pop result) url)
            child-status (or (plist-get result 'DAV:status) 500))
       (if (url-dav-http-success-p child-status)
          (push (list url child-status "huh") successes)
@@ -478,7 +479,7 @@ FAILURE-RESULTS is a list of (URL STATUS)."
 (defun url-dav-active-locks (url &optional depth)
   "Return an assoc list of all active locks on URL."
   (let ((response (url-dav-get-properties url '(DAV:lockdiscovery) depth))
-       (properties nil)
+       ;; (properties nil)
        (child nil)
        (child-url nil)
        (child-results nil)
@@ -676,7 +677,6 @@ Use with care, and even then think three times."
 If optional second argument RECURSIVE is non-nil, then delete all
 files in the collection as well."
   (let ((status nil)
-       (props nil)
        (props nil))
     (setq props (url-dav-delete-something
                 url lock-token
@@ -769,7 +769,7 @@ If NOSORT is non-nil, the list is not sorted--its order is 
unpredictable.
     (when (member 'DAV:collection (plist-get properties 'DAV:resourcetype))
       t)))
 
-(defun url-dav-make-directory (url &optional parents)
+(defun url-dav-make-directory (url &optional _parents)
   "Create the directory DIR and any nonexistent parent dirs."
   (let* ((url-request-extra-headers nil)
         (url-request-method "MKCOL")
@@ -849,7 +849,9 @@ that start with FILE.
 If there is only one and FILE matches it exactly, returns t.
 Returns nil if URL contains no name starting with FILE."
   (let ((matches (url-dav-file-name-all-completions file url))
-       (result nil))
+       ;; (result nil)
+       )
+    ;; FIXME: Use `try-completion'!
     (cond
      ((null matches)
       ;; No matches
diff --git a/lisp/url/url-expand.el b/lisp/url/url-expand.el
index a42b4c7..05088e3 100644
--- a/lisp/url/url-expand.el
+++ b/lisp/url/url-expand.el
@@ -66,7 +66,7 @@ path components followed by `..' are removed, along with the 
`..' itself."
       ;; Need to nuke newlines and spaces in the URL, or we open
       ;; ourselves up to potential security holes.
       (setq url (mapconcat (lambda (x)
-                             (if (memq x '(?  ?\n ?\r))
+                             (if (memq x '(?\s ?\n ?\r))
                                  ""
                                (char-to-string x)))
                           url "")))
diff --git a/lisp/url/url-file.el b/lisp/url/url-file.el
index 52a9588..0e2ab55 100644
--- a/lisp/url/url-file.el
+++ b/lisp/url/url-file.el
@@ -154,7 +154,7 @@ to them."
     ;; not the compressed one.
     ;; FIXME should this regexp not include more extensions; basically
     ;; everything that url-file-find-possibly-compressed-file does?
-    (setq uncompressed-filename (if (string-match "\\.\\(gz\\|Z\\|z\\)$" 
filename)
+    (setq uncompressed-filename (if (string-match "\\.\\(gz\\|Z\\|z\\)\\'" 
filename)
                                    (substring filename 0 (match-beginning 0))
                                  filename))
     (setq content-type (mailcap-extension-to-mime
diff --git a/lisp/url/url-gw.el b/lisp/url/url-gw.el
index 68df67f..d2bf843 100644
--- a/lisp/url/url-gw.el
+++ b/lisp/url/url-gw.el
@@ -1,4 +1,4 @@
-;;; url-gw.el --- Gateway munging for URL loading
+;;; url-gw.el --- Gateway munging for URL loading  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-1998, 2004-2021 Free Software Foundation, Inc.
 
@@ -222,18 +222,17 @@ overriding the value of `url-gateway-method'."
                                 host))
                           'native
                         gwm))
-         ;; An attempt to deal with denied connections, and attempt
-         ;; to reconnect
-         (cur-retries 0)
-         (retry t)
-         (errobj nil)
-         (conn nil))
+          ;; An attempt to deal with denied connections, and attempt
+          ;; to reconnect
+          ;; (cur-retries 0)
+          ;; (retry t)
+          (conn nil))
 
       ;; If the user told us to do DNS for them, do it.
       (if url-gateway-broken-resolution
          (setq host (url-gateway-nslookup-host host)))
 
-      (condition-case errobj
+      (condition-case nil
          ;; This is a clean way to ensure the new process inherits the
          ;; right coding systems in both Emacs and XEmacs.
          (let ((coding-system-for-read 'binary)
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 324cf99..61e07a0 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -66,7 +66,7 @@
 
 (defconst url-http-default-port 80 "Default HTTP port.")
 (defconst url-http-asynchronous-p t "HTTP retrievals are asynchronous.")
-(defalias 'url-http-expand-file-name 'url-default-expander)
+(defalias 'url-http-expand-file-name #'url-default-expander)
 
 (defvar url-http-real-basic-auth-storage nil)
 (defvar url-http-proxy-basic-auth-storage nil)
@@ -150,7 +150,7 @@ request.")
 ;; These routines will allow us to implement persistent HTTP
 ;; connections.
 (defsubst url-http-debug (&rest args)
-  (apply 'url-debug 'http args))
+  (apply #'url-debug 'http args))
 
 (defun url-http-mark-connection-as-busy (host port proc)
   (url-http-debug "Marking connection as busy: %s:%d %S" host port proc)
@@ -1203,8 +1203,7 @@ the end of the document."
          ;; We got back a headerless malformed response from the
          ;; server.
          (url-http-activate-callback))
-        ((or (= url-http-response-status 204)
-             (= url-http-response-status 205))
+        ((memq url-http-response-status '(204 205))
          (url-http-debug "%d response must have headers only (%s)."
                          url-http-response-status (buffer-name))
          (when (url-http-parse-headers)
@@ -1239,11 +1238,11 @@ the end of the document."
          (url-http-debug
           "Saw HTTP/0.9 response, connection closed means end of document.")
          (setq url-http-after-change-function
-               'url-http-simple-after-change-function))
+               #'url-http-simple-after-change-function))
         ((equal url-http-transfer-encoding "chunked")
          (url-http-debug "Saw chunked encoding.")
          (setq url-http-after-change-function
-               'url-http-chunked-encoding-after-change-function)
+               #'url-http-chunked-encoding-after-change-function)
          (when (> nd url-http-end-of-headers)
            (url-http-debug
             "Calling initial chunked-encoding for extra data at end of 
headers")
@@ -1254,7 +1253,7 @@ the end of the document."
          (url-http-debug
           "Got a content-length, being smart about document end.")
          (setq url-http-after-change-function
-               'url-http-content-length-after-change-function)
+               #'url-http-content-length-after-change-function)
          (cond
           ((= 0 url-http-content-length)
            ;; We got a NULL body!  Activate the callback
@@ -1275,7 +1274,7 @@ the end of the document."
         (t
          (url-http-debug "No content-length, being dumb.")
          (setq url-http-after-change-function
-               'url-http-simple-after-change-function)))))
+               #'url-http-simple-after-change-function)))))
     ;; We are still at the beginning of the buffer... must just be
     ;; waiting for a response.
     (url-http-debug "Spinning waiting for headers...")
@@ -1374,7 +1373,7 @@ The return value of this function is the retrieval 
buffer."
               url-http-referer referer)
 
        (set-process-buffer connection buffer)
-       (set-process-filter connection 'url-http-generic-filter)
+       (set-process-filter connection #'url-http-generic-filter)
        (pcase (process-status connection)
           ('connect
            ;; Asynchronous connection
@@ -1388,12 +1387,12 @@ The return value of this function is the retrieval 
buffer."
                                             (url-type url-current-object)))
                (url-https-proxy-connect connection)
              (set-process-sentinel connection
-                                   'url-http-end-of-document-sentinel)
+                                   #'url-http-end-of-document-sentinel)
              (process-send-string connection (url-http-create-request)))))))
     buffer))
 
 (defun url-https-proxy-connect (connection)
-  (setq url-http-after-change-function 'url-https-proxy-after-change-function)
+  (setq url-http-after-change-function #'url-https-proxy-after-change-function)
   (process-send-string
    connection
    (format
@@ -1441,7 +1440,7 @@ The return value of this function is the retrieval 
buffer."
                   (with-current-buffer process-buffer (erase-buffer))
                   (set-process-buffer tls-connection process-buffer)
                   (setq url-http-after-change-function
-                        'url-http-wait-for-headers-change-function)
+                        #'url-http-wait-for-headers-change-function)
                   (set-process-filter tls-connection 'url-http-generic-filter)
                   (process-send-string tls-connection
                                        (url-http-create-request)))
@@ -1510,7 +1509,7 @@ The return value of this function is the retrieval 
buffer."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defalias 'url-http-symbol-value-in-buffer
   (if (fboundp 'symbol-value-in-buffer)
-      'symbol-value-in-buffer
+      #'symbol-value-in-buffer
     (lambda (symbol buffer &optional unbound-value)
       "Return the value of SYMBOL in BUFFER, or UNBOUND-VALUE if it is 
unbound."
       (with-current-buffer buffer
diff --git a/lisp/url/url-imap.el b/lisp/url/url-imap.el
index 05c3e73..492907f 100644
--- a/lisp/url/url-imap.el
+++ b/lisp/url/url-imap.el
@@ -1,4 +1,4 @@
-;;; url-imap.el --- IMAP retrieval routines
+;;; url-imap.el --- IMAP retrieval routines  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1999, 2004-2021 Free Software Foundation, Inc.
 
@@ -37,6 +37,9 @@
 
 (defconst url-imap-default-port 143 "Default IMAP port.")
 
+(defvar imap-username)
+(defvar imap-password)
+
 (defun url-imap-open-host (host port user pass)
   ;; xxx use user and password
   (if (fboundp 'nnheader-init-server-buffer)
diff --git a/lisp/url/url-ldap.el b/lisp/url/url-ldap.el
index 0fa9970..d26562b 100644
--- a/lisp/url/url-ldap.el
+++ b/lisp/url/url-ldap.el
@@ -1,4 +1,4 @@
-;;; url-ldap.el --- LDAP Uniform Resource Locator retrieval code
+;;; url-ldap.el --- LDAP Uniform Resource Locator retrieval code  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1998-1999, 2004-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/url/url-mailto.el b/lisp/url/url-mailto.el
index 688f102..72884c0 100644
--- a/lisp/url/url-mailto.el
+++ b/lisp/url/url-mailto.el
@@ -1,4 +1,4 @@
-;;; url-mail.el --- Mail Uniform Resource Locator retrieval code
+;;; url-mail.el --- Mail Uniform Resource Locator retrieval code  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc.
 
@@ -67,7 +67,7 @@
       ;; mailto:wmperry@gnu.org
       (setf (url-filename url) (concat (url-user url) "@" (url-filename url))))
   (setq url (url-filename url))
-  (let (to args source-url subject func headers-start)
+  (let (to args source-url subject headers-start) ;; func
     (if (string-match (regexp-quote "?") url)
        (setq headers-start (match-end 0)
              to (url-unhex-string (substring url 0 (match-beginning 0)))
@@ -76,10 +76,11 @@
       (setq to (url-unhex-string url)))
     (setq source-url (url-view-url t))
     (if (and url-request-data (not (assoc "subject" args)))
-       (setq args (cons (list "subject"
+       (push (list "subject"
                               (concat "Automatic submission from "
                                       url-package-name "/"
-                                      url-package-version)) args)))
+                                      url-package-version))
+             args))
     (if (and source-url (not (assoc "x-url-from" args)))
        (setq args (cons (list "x-url-from" source-url) args)))
 
@@ -107,7 +108,7 @@
                         (replace-regexp-in-string "\r\n" "\n" string))
                     (cdar args) "\n")))
        (url-mail-goto-field (caar args))
-       (setq func (intern-soft (concat "mail-" (caar args))))
+       ;; (setq func (intern-soft (concat "mail-" (caar args))))
        (insert (mapconcat 'identity (cdar args) ", ")))
       (setq args (cdr args)))
     ;; (url-mail-goto-field "User-Agent")
diff --git a/lisp/url/url-methods.el b/lisp/url/url-methods.el
index 7aad741..cfe7d5b 100644
--- a/lisp/url/url-methods.el
+++ b/lisp/url/url-methods.el
@@ -1,4 +1,4 @@
-;;; url-methods.el --- Load URL schemes as needed
+;;; url-methods.el --- Load URL schemes as needed  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc.
 
@@ -57,7 +57,7 @@
        'file-exists-p 'ignore
        'file-attributes 'ignore))
 
-(defun url-scheme-default-loader (url &optional callback cbargs)
+(defun url-scheme-default-loader (url &optional _callback _cbargs)
   "Signal an error for an unknown URL scheme."
   (error "Unknown URL scheme: %s" (url-type url)))
 
diff --git a/lisp/url/url-misc.el b/lisp/url/url-misc.el
index d3db31d..fe2393b 100644
--- a/lisp/url/url-misc.el
+++ b/lisp/url/url-misc.el
@@ -1,4 +1,4 @@
-;;; url-misc.el --- Misc Uniform Resource Locator retrieval code
+;;; url-misc.el --- Misc Uniform Resource Locator retrieval code  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1996-1999, 2002, 2004-2021 Free Software Foundation,
 ;; Inc.
diff --git a/lisp/url/url-news.el b/lisp/url/url-news.el
index d5f8483..585a282 100644
--- a/lisp/url/url-news.el
+++ b/lisp/url/url-news.el
@@ -1,4 +1,4 @@
-;;; url-news.el --- News Uniform Resource Locator retrieval code
+;;; url-news.el --- News Uniform Resource Locator retrieval code  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc.
 
@@ -106,7 +106,7 @@
   ;; Find a news reference
   (let* ((host (or (url-host url) url-news-server))
         (port (url-port url))
-        (article-brackets nil)
+        ;; (article-brackets nil)
         (buf nil)
         (article (url-unhex-string (url-filename url))))
     (url-news-open-host host port (url-user url) (url-password url))
diff --git a/lisp/url/url-nfs.el b/lisp/url/url-nfs.el
index 3c80c80..0449930 100644
--- a/lisp/url/url-nfs.el
+++ b/lisp/url/url-nfs.el
@@ -1,4 +1,4 @@
-;;; url-nfs.el --- NFS URL interface
+;;; url-nfs.el --- NFS URL interface  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/url/url-privacy.el b/lisp/url/url-privacy.el
index e3ca0f6..d926775 100644
--- a/lisp/url/url-privacy.el
+++ b/lisp/url/url-privacy.el
@@ -1,4 +1,4 @@
-;;; url-privacy.el --- Global history tracking for URL package
+;;; url-privacy.el --- Global history tracking for URL package  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1996-1999, 2004-2021 Free Software Foundation, Inc.
 
@@ -23,7 +23,7 @@
 
 (require 'url-vars)
 
-(defun url-device-type (&optional device)
+(defun url-device-type (&optional _device)
   (declare (obsolete nil "27.1"))
   (or window-system 'tty))
 
diff --git a/lisp/url/url-proxy.el b/lisp/url/url-proxy.el
index 6bf6584..8436c7a 100644
--- a/lisp/url/url-proxy.el
+++ b/lisp/url/url-proxy.el
@@ -1,4 +1,4 @@
-;;; url-proxy.el --- Proxy server support
+;;; url-proxy.el --- Proxy server support  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1999, 2004-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/url/url-tramp.el b/lisp/url/url-tramp.el
index 325d25c..5b9dd8a 100644
--- a/lisp/url/url-tramp.el
+++ b/lisp/url/url-tramp.el
@@ -1,4 +1,4 @@
-;;; url-tramp.el --- file-name-handler magic invoking Tramp for some protocols
+;;; url-tramp.el --- file-name-handler magic invoking Tramp for some protocols 
 -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2014-2021 Free Software Foundation, Inc.
 
diff --git a/lisp/url/url.el b/lisp/url/url.el
index 172a3af..8daf9f0 100644
--- a/lisp/url/url.el
+++ b/lisp/url/url.el
@@ -156,16 +156,16 @@ If INHIBIT-COOKIES, cookies will neither be stored nor 
sent to
 the server.
 If URL is a multibyte string, it will be encoded as utf-8 and
 URL-encoded before it's used."
-;;; XXX: There is code in Emacs that does dynamic binding
-;;; of the following variables around url-retrieve:
-;;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets,
-;;; url-confirmation-func, url-cookie-multiple-line,
-;;; url-cookie-{{,secure-}storage,confirmation}
-;;; url-standalone-mode and url-gateway-unplugged should work as
-;;; usual.  url-confirmation-func is only used in nnwarchive.el and
-;;; webmail.el; the latter should be updated.  Is
-;;; url-cookie-multiple-line needed anymore?  The other url-cookie-*
-;;; are (for now) only used in synchronous retrievals.
+  ;; XXX: There is code in Emacs that does dynamic binding
+  ;; of the following variables around url-retrieve:
+  ;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets,
+  ;; url-confirmation-func, url-cookie-multiple-line,
+  ;; url-cookie-{{,secure-}storage,confirmation}
+  ;; url-standalone-mode and url-gateway-unplugged should work as
+  ;; usual.  url-confirmation-func is only used in nnwarchive.el and
+  ;; webmail.el; the latter should be updated.  Is
+  ;; url-cookie-multiple-line needed anymore?  The other url-cookie-*
+  ;; are (for now) only used in synchronous retrievals.
   (url-retrieve-internal url callback (cons nil cbargs) silent
                         inhibit-cookies))
 
@@ -210,7 +210,7 @@ URL-encoded before it's used."
        (asynch (url-scheme-get-property (url-type url) 'asynchronous-p)))
     (if url-using-proxy
        (setq asynch t
-             loader 'url-proxy))
+             loader #'url-proxy))
     (if asynch
        (let ((url-current-object url))
          (setq buffer (funcall loader url callback cbargs)))
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index bbb7324..9d0808c 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -300,7 +300,6 @@ See `run-hooks'."
     (define-key map "\C-o" 'vc-dir-display-file)
     (define-key map "\C-c\C-c" 'vc-dir-kill-dir-status-process)
     (define-key map [down-mouse-3] 'vc-dir-menu)
-    (define-key map [mouse-2] 'vc-dir-toggle-mark)
     (define-key map [follow-link] 'mouse-face)
     (define-key map "x" 'vc-dir-hide-up-to-date)
     (define-key map [?\C-k] 'vc-dir-kill-line)
@@ -1085,7 +1084,6 @@ U - if the cursor is on a file: unmark all the files with 
the same state
       as the current file
   - if the cursor is on a directory: unmark all child files
   - with a prefix argument: unmark all files
-mouse-2  - toggles the mark state
 
 VC commands
 VC commands in the `C-x v' prefix can be used.
@@ -1392,6 +1390,12 @@ These are the commands available for use in the file 
status buffer:
    (propertize "Please add backend specific headers here.  It's easy!"
               'face 'font-lock-warning-face)))
 
+(defvar vc-dir-status-mouse-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [mouse-2] 'vc-dir-toggle-mark)
+    map)
+  "Local keymap for toggling mark.")
+
 (defvar vc-dir-filename-mouse-map
    (let ((map (make-sparse-keymap)))
      (define-key map [mouse-2] 'vc-dir-find-file-other-window)
@@ -1418,7 +1422,8 @@ These are the commands available for use in the file 
status buffer:
                  ((memq state '(missing conflict)) 'font-lock-warning-face)
                  ((eq state 'edited) 'font-lock-constant-face)
                  (t 'font-lock-variable-name-face))
-      'mouse-face 'highlight)
+      'mouse-face 'highlight
+      'keymap vc-dir-status-mouse-map)
      " "
      (propertize
       (format "%s" filename)
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index a9ee28e..94fac3a 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -481,7 +481,8 @@ or an empty string if none."
       'face (cond ((eq state 'up-to-date) 'font-lock-builtin-face)
                  ((eq state 'missing) 'font-lock-warning-face)
                  (t 'font-lock-variable-name-face))
-      'mouse-face 'highlight)
+      'mouse-face 'highlight
+      'keymap vc-dir-status-mouse-map)
      "  " (vc-git-permissions-as-string old-perm new-perm)
      "    "
      (propertize (vc-git-escape-file-name (vc-dir-fileinfo->name info))
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index c4b82ab..1d163a6 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -1166,7 +1166,8 @@ hg binary."
 ;; Modeled after the similar function in vc-bzr.el
 (defun vc-hg-rename-file (old new)
   "Rename file from OLD to NEW using `hg mv'."
-  (vc-hg-command nil 0 new "mv" old))
+  (vc-hg-command nil 0 (expand-file-name new) "mv"
+                 (expand-file-name old)))
 
 (defun vc-hg-register (files &optional _comment)
   "Register FILES under hg. COMMENT is ignored."
diff --git a/lisp/wdired.el b/lisp/wdired.el
index f4a0b6d..a096abd 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -27,26 +27,26 @@
 ;; wdired.el (the "w" is for writable) provides an alternative way of
 ;; renaming files.
 ;;
-;; Have you ever wished to use C-x r t (string-rectangle), M-%
+;; Have you ever wanted to use C-x r t (string-rectangle), M-%
 ;; (query-replace), M-c (capitalize-word), etc... to change the name of
-;; the files in a "dired" buffer? Now you can do this.  All the power
-;; of Emacs commands are available to renaming files!
+;; the files in a "dired" buffer?  Now you can do this.  All the power
+;; of Emacs commands are available when renaming files!
 ;;
 ;; This package provides a function that makes the filenames of a
 ;; dired buffer editable, by changing the buffer mode (which inhibits
-;; all of the commands of dired mode). Here you can edit the names of
+;; all of the commands of dired mode).  Here you can edit the names of
 ;; one or more files and directories, and when you press C-c C-c, the
 ;; renaming takes effect and you are back to dired mode.
 ;;
-;; Another things you can do with WDired:
+;; Other things you can do with WDired:
 ;;
-;; - To move files to another directory (by typing their path,
+;; - Move files to another directory (by typing their path,
 ;;   absolute or relative, as a part of the new filename).
 ;;
-;; - To change the target of symbolic links.
+;; - Change the target of symbolic links.
 ;;
-;; - To change the permission bits of the filenames (in systems with a
-;;   working unix-alike `dired-chmod-program'). See and customize the
+;; - Change the permission bits of the filenames (in systems with a
+;;   working unix-alike `dired-chmod-program').  See and customize the
 ;;   variable `wdired-allow-to-change-permissions'.  To change a single
 ;;   char (toggling between its two more usual values) you can press
 ;;   the space bar over it or left-click the mouse.  To set any char to
@@ -56,7 +56,7 @@
 ;;   the change would affect to their targets, and this would not be
 ;;   WYSIWYG :-).
 ;;
-;; - To mark files for deletion, by deleting their whole filename.
+;; - Mark files for deletion, by deleting their whole filename.
 
 ;;; Usage:
 
@@ -68,8 +68,8 @@
 
 ;;; Change Log:
 
-;; Google is your friend (previous versions with complete changelogs
-;; were posted to gnu.emacs.sources)
+;; Previous versions with complete changelogs were posted to
+;; gnu.emacs.sources.
 
 ;;; Code:
 
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 7b8e5b7..22bfae0 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -1000,8 +1000,8 @@ See also `whitespace-style', `whitespace-newline' and
           ((eq whitespace-global-modes t))
           ((listp whitespace-global-modes)
            (if (eq (car-safe whitespace-global-modes) 'not)
-               (not (memq major-mode (cdr whitespace-global-modes)))
-             (memq major-mode whitespace-global-modes)))
+               (not (apply #'derived-mode-p (cdr whitespace-global-modes)))
+             (apply #'derived-mode-p whitespace-global-modes)))
           (t nil))
          ;; ...we have a display (not running a batch job)
          (not noninteractive)
diff --git a/lisp/window.el b/lisp/window.el
index 0a37d16..d587691 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8196,8 +8196,8 @@ such alists.
 If ALIST has a non-nil `inhibit-same-window' entry, the selected
 window is not usable.  A dedicated window is usable only if it
 already shows BUFFER.  If ALIST contains a `previous-window'
-entry, the window specified by that entry is usable even if it
-never showed BUFFER before.
+entry, the window specified by that entry (either a variable
+or a value) is usable even if it never showed BUFFER before.
 
 If ALIST contains a `reusable-frames' entry, its value determines
 which frames to search for a usable window:
@@ -8239,6 +8239,7 @@ indirectly called by the latter."
                   0)
                  (display-buffer-reuse-frames 0)
                  (t (last-nonminibuffer-frame))))
+         (previous-window (cdr (assq 'previous-window alist)))
         best-window second-best-window window)
     ;; Scan windows whether they have shown the buffer recently.
     (catch 'best
@@ -8252,7 +8253,9 @@ indirectly called by the latter."
            (throw 'best t)))))
     ;; When ALIST has a `previous-window' entry, that entry may override
     ;; anything we found so far.
-    (when (and (setq window (cdr (assq 'previous-window alist)))
+    (when (and previous-window (boundp previous-window))
+      (setq previous-window (symbol-value previous-window)))
+    (when (and (setq window previous-window)
               (window-live-p window)
               (or (eq buffer (window-buffer window))
                    (not (window-dedicated-p window))))
diff --git a/src/cmds.c b/src/cmds.c
index 1547db8..c8a96d9 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -99,6 +99,7 @@ DEFUN ("forward-line", Fforward_line, Sforward_line, 0, 1, 
"^p",
 Precisely, if point is on line I, move to the start of line I + N
 \("start of line" in the logical order).
 If there isn't room, go as far as possible (no error).
+Interactively, N is the numeric prefix argument and defaults to 1.
 
 Returns the count of lines left to move.  If moving forward,
 that is N minus number of lines moved; if backward, N plus number
diff --git a/src/dispextern.h b/src/dispextern.h
index 3ad98b8..f4e8726 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1826,6 +1826,7 @@ enum face_id
   WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID,
   WINDOW_DIVIDER_LAST_PIXEL_FACE_ID,
   INTERNAL_BORDER_FACE_ID,
+  CHILD_FRAME_BORDER_FACE_ID,
   TAB_BAR_FACE_ID,
   TAB_LINE_FACE_ID,
   BASIC_FACE_ID_SENTINEL
diff --git a/src/editfns.c b/src/editfns.c
index 6f04c99..e328549 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -52,6 +52,9 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "window.h"
 #include "blockinput.h"
 
+#ifdef WINDOWSNT
+# include "w32common.h"
+#endif
 static void update_buffer_properties (ptrdiff_t, ptrdiff_t);
 static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool);
 
@@ -121,12 +124,14 @@ init_editfns (void)
   else if (NILP (Vuser_full_name))
     Vuser_full_name = build_string ("unknown");
 
-#ifdef HAVE_SYS_UTSNAME_H
+#if defined HAVE_SYS_UTSNAME_H
   {
     struct utsname uts;
     uname (&uts);
     Voperating_system_release = build_string (uts.release);
   }
+#elif defined WINDOWSNT
+  Voperating_system_release = build_string (w32_version_string ());
 #else
   Voperating_system_release = Qnil;
 #endif
@@ -4479,7 +4484,9 @@ functions if all the text being accessed has this 
property.  */);
               doc: /* The user's name, based upon the real uid only.  */);
 
   DEFVAR_LISP ("operating-system-release", Voperating_system_release,
-              doc: /* The release of the operating system Emacs is running on. 
 */);
+              doc: /* The kernel version of the operating system on which 
Emacs is running.
+The value is a string.  It can also be nil if Emacs doesn't
+know how to get the kernel version on the underlying OS.  */);
 
   DEFVAR_BOOL ("binary-as-unsigned",
               binary_as_unsigned,
diff --git a/src/emacs.c b/src/emacs.c
index c6581bb..acf8a17 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -186,7 +186,8 @@ bool build_details;
 /* Name for the server started by the daemon.*/
 static char *daemon_name;
 
-/* 0 not a daemon, 1 new-style (foreground), 2 old-style (background).  */
+/* 0 not a daemon, 1 new-style (foreground), 2 old-style (background).
+   A negative value means the daemon initialization was already done.  */
 int daemon_type;
 
 #ifndef WINDOWSNT
@@ -2387,7 +2388,10 @@ all of which are called before Emacs is actually killed. 
 */
   int exit_code;
 
 #ifdef HAVE_LIBSYSTEMD
-  sd_notify(0, "STOPPING=1");
+  /* Notify systemd we are shutting down, but only if we have notified
+     it about startup.  */
+  if (daemon_type == -1)
+    sd_notify(0, "STOPPING=1");
 #endif /* HAVE_LIBSYSTEMD */
 
   /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
@@ -2903,7 +2907,7 @@ from the parent process and its tty file descriptors.  */)
     }
 
   /* Set it to an invalid value so we know we've already run this function.  */
-  daemon_type = -1;
+  daemon_type = -daemon_type;
 
 #else  /* WINDOWSNT */
   /* Signal the waiting emacsclient process.  */
diff --git a/src/fns.c b/src/fns.c
index 7ab2e8f..bd4afa0 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4599,33 +4599,29 @@ sweep_weak_table (struct Lisp_Hash_Table *h, bool 
remove_entries_p)
 EMACS_UINT
 hash_string (char const *ptr, ptrdiff_t len)
 {
-  EMACS_UINT const *p   = (EMACS_UINT const *) ptr;
-  EMACS_UINT const *end = (EMACS_UINT const *) (ptr + len);
+  char const *p   = ptr;
+  char const *end = ptr + len;
   EMACS_UINT hash = len;
   /* At most 8 steps.  We could reuse SXHASH_MAX_LEN, of course,
    * but dividing by 8 is cheaper.  */
-  ptrdiff_t step = 1 + ((end - p) >> 3);
+  ptrdiff_t step = sizeof hash + ((end - p) >> 3);
 
-  /* Beware: `end` might be unaligned, so `p < end` is not always the same
-   * as `p <= end - 1`.  */
-  while (p <= end - 1)
+  while (p + sizeof hash <= end)
     {
-      EMACS_UINT c = *p;
+      EMACS_UINT c;
+      /* We presume that the compiler will replace this `memcpy` with
+         a single load/move instruction when applicable.  */
+      memcpy (&c, p, sizeof hash);
       p += step;
       hash = sxhash_combine (hash, c);
     }
-  if (p < end)
-    { /* A few last bytes remain (smaller than an EMACS_UINT).  */
-      /* FIXME: We could do this without a loop, but it'd require
-         endian-dependent code :-(  */
-      char const *p1 = (char const *)p;
-      char const *end1 = (char const *)end;
-      do
-        {
-          unsigned char c = *p1++;
-          hash = sxhash_combine (hash, c);
-        }
-      while (p1 < end1);
+  /* A few last bytes may remain (smaller than an EMACS_UINT).  */
+  /* FIXME: We could do this without a loop, but it'd require
+     endian-dependent code :-(  */
+  while (p < end)
+    {
+      unsigned char c = *p++;
+      hash = sxhash_combine (hash, c);
     }
 
   return hash;
diff --git a/src/frame.c b/src/frame.c
index 599c407..a2167ce 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -3543,6 +3543,13 @@ DEFUN ("frame-fringe-width", Ffringe_width, 
Sfringe_width, 0, 1, 0,
   return make_fixnum (FRAME_TOTAL_FRINGE_WIDTH (decode_any_frame (frame)));
 }
 
+DEFUN ("frame-child-frame-border-width", Fframe_child_frame_border_width, 
Sframe_child_frame_border_width, 0, 1, 0,
+       doc: /* Return width of FRAME's child-frame border in pixels.  */)
+  (Lisp_Object frame)
+{
+  return make_fixnum (FRAME_CHILD_FRAME_BORDER_WIDTH (decode_any_frame 
(frame)));
+}
+
 DEFUN ("frame-internal-border-width", Fframe_internal_border_width, 
Sframe_internal_border_width, 0, 1, 0,
        doc: /* Return width of FRAME's internal border in pixels.  */)
   (Lisp_Object frame)
@@ -3759,6 +3766,7 @@ static const struct frame_parm_table frame_parms[] =
   {"foreground-color",         -1},
   {"icon-name",                        SYMBOL_INDEX (Qicon_name)},
   {"icon-type",                        SYMBOL_INDEX (Qicon_type)},
+  {"child-frame-border-width", SYMBOL_INDEX (Qchild_frame_border_width)},
   {"internal-border-width",    SYMBOL_INDEX (Qinternal_border_width)},
   {"right-divider-width",      SYMBOL_INDEX (Qright_divider_width)},
   {"bottom-divider-width",     SYMBOL_INDEX (Qbottom_divider_width)},
@@ -4302,6 +4310,8 @@ gui_report_frame_params (struct frame *f, Lisp_Object 
*alistptr)
 
   store_in_alist (alistptr, Qborder_width,
                  make_fixnum (f->border_width));
+  store_in_alist (alistptr, Qchild_frame_border_width,
+                 make_fixnum (FRAME_CHILD_FRAME_BORDER_WIDTH (f)));
   store_in_alist (alistptr, Qinternal_border_width,
                  make_fixnum (FRAME_INTERNAL_BORDER_WIDTH (f)));
   store_in_alist (alistptr, Qright_divider_width,
@@ -5999,6 +6009,7 @@ syms_of_frame (void)
   DEFSYM (Qhorizontal_scroll_bars, "horizontal-scroll-bars");
   DEFSYM (Qicon_name, "icon-name");
   DEFSYM (Qicon_type, "icon-type");
+  DEFSYM (Qchild_frame_border_width, "child-frame-border-width");
   DEFSYM (Qinternal_border_width, "internal-border-width");
   DEFSYM (Qleft_fringe, "left-fringe");
   DEFSYM (Qline_spacing, "line-spacing");
@@ -6423,6 +6434,7 @@ iconify the top level frame instead.  */);
   defsubr (&Sscroll_bar_width);
   defsubr (&Sscroll_bar_height);
   defsubr (&Sfringe_width);
+  defsubr (&Sframe_child_frame_border_width);
   defsubr (&Sframe_internal_border_width);
   defsubr (&Sright_divider_width);
   defsubr (&Sbottom_divider_width);
diff --git a/src/frame.h b/src/frame.h
index 8cf41dc..9b0852c 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -534,6 +534,10 @@ struct frame
   /* Border width of the frame window as known by the (X) window system.  */
   int border_width;
 
+  /* Width of child frames' internal border.  Acts as
+     internal_border_width for child frames.  */
+  int child_frame_border_width;
+
   /* Width of the internal border.  This is a line of background color
      just inside the window's border.  When the frame is selected,
      a highlighting is displayed inside the internal border.  */
@@ -1432,11 +1436,27 @@ FRAME_TOTAL_FRINGE_WIDTH (struct frame *f)
   return FRAME_LEFT_FRINGE_WIDTH (f) + FRAME_RIGHT_FRINGE_WIDTH (f);
 }
 
-/* Pixel-width of internal border lines.  */
+INLINE int
+FRAME_CHILD_FRAME_BORDER_WIDTH (struct frame *f)
+{
+  return frame_dimension (f->child_frame_border_width);
+}
+
+/* Pixel-width of internal border.  Uses child_frame_border_width for
+   child frames if possible, and falls back on internal_border_width
+   otherwise.  */
 INLINE int
 FRAME_INTERNAL_BORDER_WIDTH (struct frame *f)
 {
+#ifdef HAVE_WINDOW_SYSTEM
+  return FRAME_PARENT_FRAME(f)
+    ? (f->child_frame_border_width
+       ? FRAME_CHILD_FRAME_BORDER_WIDTH(f)
+       : frame_dimension (f->internal_border_width))
+    : frame_dimension (f->internal_border_width);
+#else
   return frame_dimension (f->internal_border_width);
+#endif
 }
 
 /* Pixel-size of window divider lines.  */
diff --git a/src/nsfns.m b/src/nsfns.m
index 24ea7d7..c383e2f 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -687,6 +687,21 @@ ns_set_tool_bar_lines (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
   }
 }
 
+static void
+ns_set_child_frame_border_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
+{
+  int old_width = FRAME_CHILD_FRAME_BORDER_WIDTH (f);
+  int new_width = check_int_nonnegative (arg);
+
+  if (new_width == old_width)
+    return;
+  f->child_frame_border_width = new_width;
+
+  if (FRAME_NATIVE_WINDOW (f) != 0)
+    adjust_frame_size (f, -1, -1, 3, 0, Qchild_frame_border_width);
+
+  SET_FRAME_GARBAGED (f);
+}
 
 static void
 ns_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
@@ -912,6 +927,7 @@ frame_parm_handler ns_frame_parm_handlers[] =
   ns_set_foreground_color,
   ns_set_icon_name,
   ns_set_icon_type,
+  ns_set_child_frame_border_width,
   ns_set_internal_border_width,
   gui_set_right_divider_width, /* generic OK */
   gui_set_bottom_divider_width, /* generic OK */
@@ -1197,6 +1213,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   gui_default_parameter (f, parms, Qinternal_border_width, make_fixnum (2),
                          "internalBorderWidth", "InternalBorderWidth",
                          RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qchild_frame_border_width, make_fixnum (2),
+                        "childFrameBorderWidth", "childFrameBorderWidth",
+                        RES_TYPE_NUMBER);
   gui_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
                       NULL, NULL, RES_TYPE_NUMBER);
   gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
diff --git a/src/nsterm.m b/src/nsterm.m
index df3934c..1b23286 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3037,9 +3037,13 @@ ns_clear_under_internal_border (struct frame *f)
       NSRectEdge edge[] = {NSMinXEdge, NSMinYEdge, NSMaxXEdge, NSMaxYEdge};
 
       int face_id =
-       !NILP (Vface_remapping_alist)
-       ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
-       : INTERNAL_BORDER_FACE_ID;
+        (FRAME_PARENT_FRAME (f)
+         ? (!NILP (Vface_remapping_alist)
+            ? lookup_basic_face (NULL, f, CHILD_FRAME_BORDER_FACE_ID)
+            : CHILD_FRAME_BORDER_FACE_ID)
+         : (!NILP (Vface_remapping_alist)
+            ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
+            : INTERNAL_BORDER_FACE_ID));
       struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
 
       if (!face)
diff --git a/src/process.c b/src/process.c
index 1df4ed9..3beb9cf 100644
--- a/src/process.c
+++ b/src/process.c
@@ -7217,7 +7217,7 @@ child_signal_read (int fd, void *data)
   eassert (0 <= fd);
   eassert (fd == child_signal_read_fd);
   char dummy;
-  if (emacs_read (fd, &dummy, 1) < 0)
+  if (emacs_read (fd, &dummy, 1) < 0 && errno != EAGAIN)
     emacs_perror ("reading from child signal FD");
 }
 #endif /* !WINDOWSNT */
diff --git a/src/w32common.h b/src/w32common.h
index 90e8887..cbe05c5 100644
--- a/src/w32common.h
+++ b/src/w32common.h
@@ -50,6 +50,11 @@ extern int os_subtype;
 /* Cache system info, e.g., the NT page size.  */
 extern void cache_system_info (void);
 
+#ifdef WINDOWSNT
+/* Return a static buffer with the MS-Windows version string.  */
+extern char * w32_version_string (void);
+#endif
+
 typedef void (* VOIDFNPTR) (void);
 
 /* Load a function address from a DLL.  Cast the result via VOIDFNPTR
diff --git a/src/w32fns.c b/src/w32fns.c
index c1e18ff..e93a0b8 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1519,9 +1519,13 @@ w32_clear_under_internal_border (struct frame *f)
       int width = FRAME_PIXEL_WIDTH (f);
       int height = FRAME_PIXEL_HEIGHT (f);
       int face_id =
-       !NILP (Vface_remapping_alist)
-       ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
-       : INTERNAL_BORDER_FACE_ID;
+       (FRAME_PARENT_FRAME (f)
+        ? (!NILP (Vface_remapping_alist)
+           ? lookup_basic_face (NULL, f, CHILD_FRAME_BORDER_FACE_ID)
+           : CHILD_FRAME_BORDER_FACE_ID)
+        : (!NILP (Vface_remapping_alist)
+           ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
+           : INTERNAL_BORDER_FACE_ID));
       struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
 
       block_input ();
@@ -1548,6 +1552,32 @@ w32_clear_under_internal_border (struct frame *f)
     }
 }
 
+/**
+ * w32_set_child_frame_border_width:
+ *
+ * Set width of child frame F's internal border to ARG pixels.
+ * ARG < 0 is treated like ARG = 0.
+ */
+static void
+w32_set_child_frame_border_width (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
+{
+  int argval = check_integer_range (arg, INT_MIN, INT_MAX);
+  int border = max (argval, 0);
+
+  if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f))
+    {
+      f->child_frame_border_width = border;
+
+      if (FRAME_NATIVE_WINDOW (f) != 0)
+       {
+         adjust_frame_size (f, -1, -1, 3, false, Qchild_frame_border_width);
+
+         if (FRAME_VISIBLE_P (f))
+           w32_clear_under_internal_border (f);
+       }
+    }
+}
+
 
 /**
  * w32_set_internal_border_width:
@@ -5873,6 +5903,28 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
                            parameters);
     }
 
+  /* Same for child frames.  */
+  if (NILP (Fassq (Qchild_frame_border_width, parameters)))
+    {
+      Lisp_Object value;
+
+      value = gui_display_get_arg (dpyinfo, parameters, 
Qchild_frame_border_width,
+                                   "childFrameBorderWidth", 
"childFrameBorderWidth",
+                                   RES_TYPE_NUMBER);
+      if (! EQ (value, Qunbound))
+       parameters = Fcons (Fcons (Qchild_frame_border_width, value),
+                      parameters);
+
+    }
+
+  gui_default_parameter (f, parameters, Qchild_frame_border_width,
+#ifdef USE_GTK /* We used to impose 0 in xg_create_frame_widgets.  */
+                        make_fixnum (0),
+#else
+                        make_fixnum (1),
+#endif
+                        "childFrameBorderWidth", "childFrameBorderWidth",
+                        RES_TYPE_NUMBER);
   gui_default_parameter (f, parameters, Qinternal_border_width, make_fixnum 
(0),
                          "internalBorderWidth", "InternalBorder", 
RES_TYPE_NUMBER);
   gui_default_parameter (f, parameters, Qright_divider_width, make_fixnum (0),
@@ -9428,6 +9480,18 @@ cache_system_info (void)
   w32_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
 }
 
+#ifdef WINDOWSNT
+char *
+w32_version_string (void)
+{
+  /* NNN.NNN.NNNNNNNNNN */
+  static char version_string[3 + 1 + 3 + 1 + 10 + 1];
+  _snprintf (version_string, sizeof version_string, "%d.%d.%d",
+            w32_major_version, w32_minor_version, w32_build_number);
+  return version_string;
+}
+#endif
+
 #ifdef EMACSDEBUG
 void
 _DebPrint (const char *fmt, ...)
@@ -10232,6 +10296,7 @@ frame_parm_handler w32_frame_parm_handlers[] =
   w32_set_foreground_color,
   w32_set_icon_name,
   w32_set_icon_type,
+  w32_set_child_frame_border_width,
   w32_set_internal_border_width,
   gui_set_right_divider_width,
   gui_set_bottom_divider_width,
diff --git a/src/w32term.c b/src/w32term.c
index 109aa58..0ee805a 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -2404,14 +2404,29 @@ w32_draw_stretch_glyph_string (struct glyph_string *s)
   else if (!s->background_filled_p)
     {
       int background_width = s->background_width;
-      int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
+      int x = s->x, text_left_x = window_box_left_offset (s->w, TEXT_AREA);
 
-      /* Don't draw into left margin, fringe or scrollbar area
-         except for header line and mode line.  */
-      if (x < left_x && !s->row->mode_line_p)
+      /* Don't draw into left fringe or scrollbar area except for
+         header line and mode line.  */
+      if (x < text_left_x && !s->row->mode_line_p)
        {
-         background_width -= left_x - x;
-         x = left_x;
+         int left_x = WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (s->w);
+         int right_x = text_left_x;
+
+         if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (s->w))
+           left_x += WINDOW_LEFT_FRINGE_WIDTH (s->w);
+         else
+           right_x -= WINDOW_LEFT_FRINGE_WIDTH (s->w);
+
+         /* Adjust X and BACKGROUND_WIDTH to fit inside the space
+            between LEFT_X and RIGHT_X.  */
+         if (x < left_x)
+           {
+             background_width -= left_x - x;
+             x = left_x;
+           }
+         if (x + background_width > right_x)
+           background_width = right_x - x;
        }
       if (background_width > 0)
        w32_draw_glyph_string_bg_rect (s, x, s->y, background_width, s->height);
diff --git a/src/xdisp.c b/src/xdisp.c
index e1e4ff4..11b9e1b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -29813,7 +29813,8 @@ produce_stretch_glyph (struct it *it)
 #endif /* HAVE_WINDOW_SYSTEM */
     height = 1;
 
-  if (width > 0 && it->line_wrap != TRUNCATE
+  if (width > 0
+      && it->area == TEXT_AREA && it->line_wrap != TRUNCATE
       && it->current_x + width > it->last_visible_x)
     {
       width = it->last_visible_x - it->current_x;
diff --git a/src/xfaces.c b/src/xfaces.c
index 258b365..1208713 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4914,6 +4914,7 @@ lookup_basic_face (struct window *w, struct frame *f, int 
face_id)
     case WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID:   name = 
Qwindow_divider_first_pixel;     break;
     case WINDOW_DIVIDER_LAST_PIXEL_FACE_ID:    name = 
Qwindow_divider_last_pixel;      break;
     case INTERNAL_BORDER_FACE_ID:      name = Qinternal_border;        break;
+    case CHILD_FRAME_BORDER_FACE_ID:   name = Qchild_frame_border;     break;
 
     default:
       emacs_abort (); /* the caller is supposed to pass us a basic face id */
@@ -5620,6 +5621,7 @@ realize_basic_faces (struct frame *f)
       realize_named_face (f, Qwindow_divider_last_pixel,
                          WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
       realize_named_face (f, Qinternal_border, INTERNAL_BORDER_FACE_ID);
+      realize_named_face (f, Qchild_frame_border, CHILD_FRAME_BORDER_FACE_ID);
       realize_named_face (f, Qtab_bar, TAB_BAR_FACE_ID);
       realize_named_face (f, Qtab_line, TAB_LINE_FACE_ID);
 
@@ -6973,6 +6975,7 @@ syms_of_xfaces (void)
   DEFSYM (Qwindow_divider_first_pixel, "window-divider-first-pixel");
   DEFSYM (Qwindow_divider_last_pixel, "window-divider-last-pixel");
   DEFSYM (Qinternal_border, "internal-border");
+  DEFSYM (Qchild_frame_border, "child-frame-border");
 
   /* TTY color-related functions (defined in tty-colors.el).  */
   DEFSYM (Qtty_color_desc, "tty-color-desc");
diff --git a/src/xfns.c b/src/xfns.c
index 9ab537c..cac41ee 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1800,6 +1800,28 @@ x_change_tool_bar_height (struct frame *f, int height)
 #endif /* USE_GTK */
 }
 
+static void
+x_set_child_frame_border_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
+{
+  int border = check_int_nonnegative (arg);
+
+  if (border != FRAME_CHILD_FRAME_BORDER_WIDTH (f))
+    {
+      f->child_frame_border_width = border;
+
+#ifdef USE_X_TOOLKIT
+      if (FRAME_X_OUTPUT (f)->edit_widget)
+       widget_store_internal_border (FRAME_X_OUTPUT (f)->edit_widget);
+#endif
+
+      if (FRAME_X_WINDOW (f))
+       {
+         adjust_frame_size (f, -1, -1, 3, false, Qchild_frame_border_width);
+         x_clear_under_internal_border (f);
+       }
+    }
+
+}
 
 static void
 x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
@@ -3897,6 +3919,29 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
        parms = Fcons (Fcons (Qinternal_border_width, value),
                       parms);
     }
+
+  /* Same for child frames.  */
+  if (NILP (Fassq (Qchild_frame_border_width, parms)))
+    {
+      Lisp_Object value;
+
+      value = gui_display_get_arg (dpyinfo, parms, Qchild_frame_border_width,
+                                   "childFrameBorderWidth", 
"childFrameBorderWidth",
+                                   RES_TYPE_NUMBER);
+      if (! EQ (value, Qunbound))
+       parms = Fcons (Fcons (Qchild_frame_border_width, value),
+                      parms);
+
+    }
+
+  gui_default_parameter (f, parms, Qchild_frame_border_width,
+#ifdef USE_GTK /* We used to impose 0 in xg_create_frame_widgets.  */
+                        make_fixnum (0),
+#else
+                        make_fixnum (1),
+#endif
+                        "childFrameBorderWidth", "childFrameBorderWidth",
+                        RES_TYPE_NUMBER);
   gui_default_parameter (f, parms, Qinternal_border_width,
 #ifdef USE_GTK /* We used to impose 0 in xg_create_frame_widgets.  */
                          make_fixnum (0),
@@ -7762,6 +7807,7 @@ frame_parm_handler x_frame_parm_handlers[] =
   x_set_foreground_color,
   x_set_icon_name,
   x_set_icon_type,
+  x_set_child_frame_border_width,
   x_set_internal_border_width,
   gui_set_right_divider_width,
   gui_set_bottom_divider_width,
diff --git a/src/xterm.c b/src/xterm.c
index b8374fe..744b80c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1293,9 +1293,13 @@ x_clear_under_internal_border (struct frame *f)
       int height = FRAME_PIXEL_HEIGHT (f);
       int margin = FRAME_TOP_MARGIN_HEIGHT (f);
       int face_id =
-       !NILP (Vface_remapping_alist)
-       ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
-       : INTERNAL_BORDER_FACE_ID;
+       (FRAME_PARENT_FRAME (f)
+        ? (!NILP (Vface_remapping_alist)
+           ? lookup_basic_face (NULL, f, CHILD_FRAME_BORDER_FACE_ID)
+           : CHILD_FRAME_BORDER_FACE_ID)
+        : (!NILP (Vface_remapping_alist)
+           ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
+           : INTERNAL_BORDER_FACE_ID));
       struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
 
       block_input ();
@@ -1360,9 +1364,13 @@ x_after_update_window_line (struct window *w, struct 
glyph_row *desired_row)
       {
        int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
        int face_id =
-         !NILP (Vface_remapping_alist)
-         ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
-         : INTERNAL_BORDER_FACE_ID;
+         (FRAME_PARENT_FRAME (f)
+          ? (!NILP (Vface_remapping_alist)
+             ? lookup_basic_face (NULL, f, CHILD_FRAME_BORDER_FACE_ID)
+             : CHILD_FRAME_BORDER_FACE_ID)
+          : (!NILP (Vface_remapping_alist)
+             ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
+             : INTERNAL_BORDER_FACE_ID));
        struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
 
        block_input ();
@@ -3577,14 +3585,29 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
   else if (!s->background_filled_p)
     {
       int background_width = s->background_width;
-      int x = s->x, left_x = window_box_left_offset (s->w, TEXT_AREA);
+      int x = s->x, text_left_x = window_box_left_offset (s->w, TEXT_AREA);
 
-      /* Don't draw into left margin, fringe or scrollbar area
-         except for header line and mode line.  */
-      if (x < left_x && !s->row->mode_line_p)
+      /* Don't draw into left fringe or scrollbar area except for
+         header line and mode line.  */
+      if (x < text_left_x && !s->row->mode_line_p)
        {
-         background_width -= left_x - x;
-         x = left_x;
+         int left_x = WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (s->w);
+         int right_x = text_left_x;
+
+         if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (s->w))
+           left_x += WINDOW_LEFT_FRINGE_WIDTH (s->w);
+         else
+           right_x -= WINDOW_LEFT_FRINGE_WIDTH (s->w);
+
+         /* Adjust X and BACKGROUND_WIDTH to fit inside the space
+            between LEFT_X and RIGHT_X.  */
+         if (x < left_x)
+           {
+             background_width -= left_x - x;
+             x = left_x;
+           }
+         if (x + background_width > right_x)
+           background_width = right_x - x;
        }
       if (background_width > 0)
        x_draw_glyph_string_bg_rect (s, x, s->y, background_width, s->height);
diff --git a/test/Makefile.in b/test/Makefile.in
index bfab95b..3b6c18d 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -123,8 +123,9 @@ MODULES_EMACSOPT :=
 endif
 
 # The actual Emacs command run in the targets below.
-# Prevent any setting of EMACSLOADPATH in user environment causing problems.
-emacs = EMACSLOADPATH= \
+# Prevent any setting of EMACSLOADPATH in user environment causing problems,
+# and prevent locals to influence the text of the errors we expect to receive.
+emacs = LANG=C EMACSLOADPATH=             \
  EMACS_TEST_DIRECTORY=$(abspath $(srcdir)) \
  $(GDB) "$(EMACS)" $(MODULES_EMACSOPT) $(EMACSOPT)
 
diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el
index 1b7beea..62a42b7 100644
--- a/test/lisp/electric-tests.el
+++ b/test/lisp/electric-tests.el
@@ -1,4 +1,4 @@
-;;; electric-tests.el --- tests for electric.el
+;;; electric-tests.el --- tests for electric.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
 
@@ -135,9 +135,11 @@ The buffer's contents should %s:
                   (length fixture)
                   fixture
                   (if fixture-fn (format "\nNow call this:\n\n%s"
-                                         (pp-to-string fixture-fn)) "")
+                                         (pp-to-string fixture-fn))
+                    "")
                   (if bindings (format "\nEnsure the following bindings:\n\n%s"
-                                       (pp-to-string bindings)) "")
+                                       (pp-to-string bindings))
+                    "")
                   char
                   (if (string= fixture expected-string) "stay" "become")
                   (replace-regexp-in-string "\n" "\\\\n" expected-string)
@@ -163,8 +165,11 @@ The buffer's contents should %s:
           (test-in-comments t)
           (test-in-strings t)
           (test-in-code t)
-          (fixture-fn #'(lambda ()
-                          (electric-pair-mode 1))))
+          ;; The semantics of CL's defmacro "default values" is subtle:
+          ;; contrary to the actual arguments, these are evaluated (and
+          ;; are expected to return the "default form").
+          ;; `fixture-fn' contains a form whose evaluation returns a function.
+          (fixture-fn '#'electric-pair-mode))
   `(progn
      ,@(cl-loop
         for mode in (eval modes) ;FIXME: avoid `eval'
diff --git a/test/lisp/find-cmd-tests.el b/test/lisp/find-cmd-tests.el
new file mode 100644
index 0000000..b8e0f27
--- /dev/null
+++ b/test/lisp/find-cmd-tests.el
@@ -0,0 +1,45 @@
+;;; find-cmd-tests.el --- tests for find-cmd.el.  -*- lexical-binding: t -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'find-cmd)
+
+(ert-deftest find-cmd-test-find-cmd ()
+  (should
+   (string-match
+    (rx "find " (+ any)
+        " \\( \\( -name .svn -or -name .git -or -name .CVS \\)"
+        " -prune -or -true \\)"
+        " \\( \\( \\(" " -name \\*.pl -or -name \\*.pm -or -name \\*.t \\)"
+        " -or -mtime \\+1 \\) -and \\( -fstype nfs -or -fstype ufs \\) \\) ")
+    (find-cmd '(prune (name ".svn" ".git" ".CVS"))
+              '(and (or (name "*.pl" "*.pm" "*.t")
+                        (mtime "+1"))
+                    (fstype "nfs" "ufs"))))))
+
+(ert-deftest find-cmd-test-find-cmd/error-unknown-atom ()
+  (should-error (find-cmd '(unknown 123))))
+
+(ert-deftest find-cmd-test-find-cmd/error-wrong-argnum ()
+  (should-error (find-cmd '(name))))
+
+(provide 'find-cmd-tests)
+;;; find-cmd-tests.el ends here
diff --git a/test/lisp/net/sasl-cram-tests.el b/test/lisp/net/sasl-cram-tests.el
new file mode 100644
index 0000000..e0230dd
--- /dev/null
+++ b/test/lisp/net/sasl-cram-tests.el
@@ -0,0 +1,46 @@
+;;; sasl-cram-tests.el --- tests for sasl-cram.el  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Stefan Kangas <stefankangas@gmail.com>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Test case from RFC 2195.
+
+;;; Code:
+
+(require 'ert)
+(require 'sasl)
+(require 'sasl-cram)
+
+(ert-deftest sasl-cram-md5-response-test ()
+  ;; The following strings are taken from section 2 of RFC 2195.
+  (let ((client
+         (sasl-make-client (sasl-find-mechanism '("CRAM-MD5"))
+                          "user"
+                          "imap"
+                           "localhost"))
+        (data (base64-decode-string 
"PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2UucmVzdG9uLm1jaS5uZXQ+"))
+        (sasl-read-passphrase
+         (lambda (_prompt) (copy-sequence "tanstaaftanstaaf"))))
+    (should (equal (sasl-cram-md5-response client (vector nil data))
+                   "user b913a602c7eda7a495b4e6e7334d3890"))))
+
+(provide 'sasl-cram-tests)
+;;; sasl-cram-tests.el ends here
diff --git a/test/lisp/net/sasl-tests.el b/test/lisp/net/sasl-tests.el
new file mode 100644
index 0000000..dab4075
--- /dev/null
+++ b/test/lisp/net/sasl-tests.el
@@ -0,0 +1,59 @@
+;;; sasl-tests.el --- tests for sasl.el  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Stefan Kangas <stefankangas@gmail.com>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ert)
+(require 'sasl)
+
+(ert-deftest sasl-test-make-client ()
+  (let ((client (sasl-make-client 'foo 'bar 'baz 'zut)))
+    (should (eq (sasl-client-mechanism client) 'foo))
+    (should (eq (sasl-client-name client) 'bar))
+    (should (eq (sasl-client-service client) 'baz))
+    (should (eq (sasl-client-server client) 'zut))))
+
+(ert-deftest sasl-test-client-set-properties ()
+  (let ((client (sasl-make-client 'foo 'bar 'baz 'zut)))
+    (sasl-client-set-property client 'foo 'bar)
+    (should (eq (sasl-client-property client 'foo) 'bar))))
+
+(ert-deftest sasl-test-step-data ()
+  (let ((step [nil nil]))
+    (sasl-step-set-data step "foo")
+    (should (equal (sasl-step-data step) "foo"))))
+
+(ert-deftest sasl-test-unique-id ()
+  (should (stringp (sasl-unique-id)))
+  (should-not (equal (sasl-unique-id) (sasl-unique-id))))
+
+(ert-deftest sasl-test-find-mechanism ()
+  (should (sasl-find-mechanism '("ANONYMOUS")))
+  (should-not (sasl-find-mechanism '("nonexistent mechanism"))))
+
+(ert-deftest sasl-test-mechanism-name ()
+  (let ((mechanism (sasl-find-mechanism '("ANONYMOUS"))))
+    (should (equal (sasl-mechanism-name mechanism) "ANONYMOUS"))))
+
+(provide 'sasl-tests)
+;;; sasl-tests.el ends here
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 7757c55..19a40fd 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -3192,6 +3192,8 @@ This tests also `file-directory-p' and 
`file-accessible-directory-p'."
 (ert-deftest tramp-test17-insert-directory-one-file ()
   "Check `insert-directory' inside directory listing."
   (skip-unless (tramp--test-enabled))
+  ;; Relative file names in dired are not supported in tramp-crypt.el.
+  (skip-unless (not (tramp--test-crypt-p)))
 
   (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
     (let* ((tmp-name1
@@ -5793,7 +5795,9 @@ Additionally, ls does not support \"--dired\"."
   (and (tramp--test-sh-p)
        (with-temp-buffer
         ;; We must refill the cache.  `insert-directory' does it.
-        (insert-directory tramp-test-temporary-file-directory "-al")
+        ;; This fails for tramp-crypt.el, so we ignore that.
+        (ignore-errors
+          (insert-directory tramp-test-temporary-file-directory "-al"))
         (not (tramp-get-connection-property tramp-test-vec "ls--dired" nil)))))
 
 (defun tramp--test-share-p ()
@@ -6033,13 +6037,13 @@ This requires restrictions of file name syntax."
   (let ((files
         (list
          (cond ((or (tramp--test-ange-ftp-p)
+                    (tramp--test-docker-p)
                     (tramp--test-gvfs-p)
                     (tramp--test-rclone-p)
                     (tramp--test-sudoedit-p)
                     (tramp--test-windows-nt-or-smb-p))
                 "foo bar baz")
                ((or (tramp--test-adb-p)
-                    (tramp--test-docker-p)
                     (eq system-type 'cygwin))
                 " foo bar baz ")
                ((tramp--test-sh-no-ls--dired-p)
diff --git a/test/lisp/progmodes/asm-mode-tests.el 
b/test/lisp/progmodes/asm-mode-tests.el
index 6ae4fdf..8787217 100644
--- a/test/lisp/progmodes/asm-mode-tests.el
+++ b/test/lisp/progmodes/asm-mode-tests.el
@@ -69,4 +69,14 @@
     (should (string-match-p ";;; \nlabel:" (buffer-string)))
     (should (= (current-column) 4))))
 
+(ert-deftest asm-mode-tests-fill-comment ()
+  (asm-mode-tests--with-temp-buffer
+    (call-interactively #'comment-dwim)
+    (insert "Pellentesque condimentum, magna ut suscipit hendrerit, \
+ipsum augue ornare nulla, non luctus diam neque sit amet urna.")
+    (call-interactively #'fill-paragraph)
+    (should (equal (buffer-string) "\t;; Pellentesque condimentum, \
+magna ut suscipit hendrerit,\n\t;; ipsum augue ornare nulla, non \
+luctus diam neque sit amet\n\t;; urna."))))
+
 ;;; asm-mode-tests.el ends here
diff --git a/test/lisp/progmodes/elisp-mode-tests.el 
b/test/lisp/progmodes/elisp-mode-tests.el
index 0da0e39..badcad6 100644
--- a/test/lisp/progmodes/elisp-mode-tests.el
+++ b/test/lisp/progmodes/elisp-mode-tests.el
@@ -864,7 +864,6 @@ to (xref-elisp-test-descr-to-target xref)."
               'nil)))
 
 (ert-deftest test-elisp-font-keywords-2 ()
-  :expected-result :failed ; FIXME bug#43265
   (should (eq (test--font '(condition-case nil
                                (foo)
                              (error (when a b)))
@@ -872,12 +871,11 @@ to (xref-elisp-test-descr-to-target xref)."
               'font-lock-keyword-face)))
 
 (ert-deftest test-elisp-font-keywords-3 ()
-  :expected-result :failed ; FIXME bug#43265
   (should (eq (test--font '(setq a '(if when zot))
                           "(\\(if\\)")
               nil)))
 
-(ert-deftest test-elisp-font-keywords-if ()
+(ert-deftest test-elisp-font-keywords-4 ()
   :expected-result :failed ; FIXME bug#43265
   (should (eq (test--font '(condition-case nil
                                (foo)
@@ -885,5 +883,12 @@ to (xref-elisp-test-descr-to-target xref)."
                           "(\\(if\\)")
               nil)))
 
+(ert-deftest test-elisp-font-keywords-5 ()
+  (should (eq (test--font '(condition-case (when a)
+                               (foo)
+                             (error t))
+                          "(\\(when\\)")
+              nil)))
+
 (provide 'elisp-mode-tests)
 ;;; elisp-mode-tests.el ends here
diff --git a/test/manual/indent/shell.sh b/test/manual/indent/shell.sh
index dc184ea..bd4a74f 100755
--- a/test/manual/indent/shell.sh
+++ b/test/manual/indent/shell.sh
@@ -6,6 +6,13 @@ setlock -n /tmp/getmail.lock && echo getmail isn\'t running
 toto=$(grep hello foo |
            wc)
 
+myfun () {
+    for ((it=0; it<${limit}; ++it))
+    {
+       echo "whatever $it"
+    }
+}
+
 # adsgsdg
 
 if foo; then



reply via email to

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