emacs-diffs
[Top][All Lists]
Advanced

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

master 485622b: * lisp/textmodes: Use lexical-binding


From: Stefan Monnier
Subject: master 485622b: * lisp/textmodes: Use lexical-binding
Date: Wed, 17 Mar 2021 23:32:47 -0400 (EDT)

branch: master
commit 485622bbd1afad4c1e39a245cf57605208ca606f
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lisp/textmodes: Use lexical-binding
    
    * lisp/textmodes/enriched.el: Use lexical-binding.
    (enriched-mode): Use `delete-dups` to avoid `add-to-list` on
    a local variable.
    
    * lisp/textmodes/makeinfo.el: Use lexical-binding.
    (makeinfo-region): Remove unused var `filename-or-header`.
    
    * lisp/textmodes/refbib.el: Use lexical-binding.
    (r2b-put-field): Remove unused var `multi-line`.
    (r2b-barf-output): Remove unused var `match`.
    
    * lisp/textmodes/refer.el: Use lexical-binding.
    (refer-find-entry-internal): Remove unused vars `old-buffer` and `found`.
    
    * lisp/textmodes/reftex-auc.el: Use lexical-binding.
    (LaTeX-add-bibitems): Declare function.
    (reftex-plug-into-AUCTeX): Use `add-function` and `advice-add` so we
    can properly unplug.
    
    * lisp/textmodes/reftex-cite.el: Use lexical-binding.
    (reftex-create-bibtex-file): Remove unused var `file`.
    (reftex--found-list): Declare var.
    (reftex-offer-bib-menu): Rename local var to `reftex--found-list`.
    
    * lisp/textmodes/reftex-dcr.el: Use lexical-binding.
    (reftex-use-itimer-in-xemacs): Delete XEmacs-only var.
    (reftex-toggle-auto-view-crossref): Delete XEmacs-only code.
    (reftex-start-itimer-once): Delete XEmacs-only function.
    
    * lisp/textmodes/reftex-global.el: Use lexical-binding.
    (reftex-isearch-push-state-function): Use a closure instead of `(lambda).
    
    * lisp/textmodes/reftex-index.el: Use lexical-binding.
    (mark-active, transient-mark-mode): Delete var declarations.
    (reftex-index-mode-map): Remove XEmacs-only code.
    Use `mapc` so we can use closures instead of hand-built lambdas.
    (reftex-index-next, reftex-index-previous): Tweak interactive spec to
    remove unused prefix arg and mark it as a motion command.
    (reftex-index-phrases-font-lock-keywords)
    (reftex-index-phrases-font-lock-keywords): Move initialization into
    declaration.
    (reftex-index-initialize-phrases-buffer, reftex-index-phrases-mode)
    reftex-index-phrases-apply-to-region: Remove XEmacs-only code.
    (TeX-master): Remove redundant declaration.
    (reftex--chars-first): Rename dynvar from `chars-first`.  Adjust all uses.
    
    * lisp/textmodes/reftex-parse.el: Use lexical-binding.
    
    * lisp/textmodes/reftex-ref.el: Use lexical-binding.
    (reftex-label): Remove always-nil var `text`.
    (reftex-refstyle): Declare before first use.
    (<toplevel>): Use closures rather than `eval` when building commands from
    `reftex-ref-style-alist`.
    
    * lisp/textmodes/reftex-sel.el: Use lexical-binding.
    (reftex-select-label-mode-map, reftex-select-bib-mode-map):
    Use `mapc` so we can use closures instead of hand-built lambdas.
    (reftex-select-label-mode, reftex-select-bib-mode): Remove XEmacs-only code.
    (reftex-select-data, reftex-select-prompt, reftex-refstyle):
    Move declaration before first use.
    (reftex--found-list, reftex--cb-flag, reftex--last-data)
    (reftex--call-back, reftex--help-string): Move declaration before use,
    and rename by adding `reftext--` prefix.  Adjust all uses in this file.
    For `reftex--found-list` adjust corresponding uses in `reftex-cite.el`.
    (reftex-select-item): Explicitly let-bind them.
    Remove XEmacs-only code.
    
    * lisp/textmodes/reftex-toc.el: Use lexical-binding.
    (reftex-toc-mode-map, reftex-toc-mode, reftex-toc-restore-region)
    (reftex-toc-next, reftex-toc-previous, reftex-toc-next-heading)
    (reftex-toc-previous-heading, reftex-toggle-auto-toc-recenter
    (reftex-make-separate-toc-frame): Remove XEmacs-only code.
    
    * lisp/textmodes/reftex-vars.el: Use lexical-binding.
    
    * lisp/textmodes/reftex.el: Use lexical-binding.
    (reftex-mode-map, reftex-mode, reftex-fontify-select-label-buffer)
    (reftex-verified-face): Remove XEmacs-only code.
    (reftex-region-active-p, reftex-overlay-put, reftex-move-overlay)
    (reftex-make-overlay, reftex-get-buffer-visiting, reftex-delete-overlay):
    Redefine as obsolete aliases.  Replace all callers.
    (current-message): Remove XEmacs-only definition.
    
    * lisp/textmodes/remember.el: Use lexical-binding.
    
    * lisp/textmodes/table.el (<toplevel>): Use closures rather than `(lambda)
    to build commands.
    
    * lisp/textmodes/texinfmt.el: Use lexical-binding.
    (texinfo-example-start): Declare var.
    (texinfo-format-region, texinfo-format-buffer-1): Remove unused var
    `last-input-buffer`.
    (texinfo-format-scan): Use `dlet` to bind `whitespace-silent`.
    (texinfo-optional-braces-discard, texinfo-format-parse-line-args)
    (texinfo-format-parse-args): Remove unused var `start`.
    (texinfo-multitable-widths): Remove unused var `start-of-templates`.
    (texinfo-multitable-item): Strength-reduce `eval` to `symbol-value`.
    (texinfo-alias): Remove unused vars `start` and `args`.
    (texinfo-defun-type symbol-property): Change the car to help the type
    symbol rather than an expression returning it.
    (texinfo-format-deffn): Remove corresponding `eval`.
    (texinfo-clear): Remove unused var `value`.
    (texinfo-format-ifeq): Remove unused var `end`.
    
    * lisp/textmodes/texinfo.el: Use lexical-binding.
    (tex-show-print-queue): Declare function.
    
    * lisp/textmodes/texnfo-upd.el: Use lexical-binding.
    (texinfo-start-menu-description): Remove unused var `end`.
    (texinfo-insert-node-lines): Remove unused var `beginning-marker`.
    (texinfo-multiple-files-update): Remove unused vars `next-node-name`
    and `previous-node-name`.
    
    * lisp/textmodes/two-column.el: Use lexical-binding.
---
 lisp/textmodes/bib-mode.el      |  12 +-
 lisp/textmodes/bibtex-style.el  |   2 +-
 lisp/textmodes/dns-mode.el      |   6 +-
 lisp/textmodes/enriched.el      |  36 +++---
 lisp/textmodes/fill.el          |   2 +-
 lisp/textmodes/less-css-mode.el |  10 +-
 lisp/textmodes/makeinfo.el      |   6 +-
 lisp/textmodes/nroff-mode.el    |  12 +-
 lisp/textmodes/page-ext.el      |   2 +-
 lisp/textmodes/paragraphs.el    |  18 +--
 lisp/textmodes/refbib.el        |   6 +-
 lisp/textmodes/refer.el         |   6 +-
 lisp/textmodes/refill.el        |  10 +-
 lisp/textmodes/reftex-auc.el    |  54 +++++----
 lisp/textmodes/reftex-cite.el   |  71 +++++------
 lisp/textmodes/reftex-dcr.el    |  46 ++-----
 lisp/textmodes/reftex-global.el |  34 +++---
 lisp/textmodes/reftex-index.el  | 259 ++++++++++++++++++----------------------
 lisp/textmodes/reftex-parse.el  |  17 +--
 lisp/textmodes/reftex-ref.el    |  38 +++---
 lisp/textmodes/reftex-sel.el    | 207 ++++++++++++++++----------------
 lisp/textmodes/reftex-toc.el    | 114 +++++++-----------
 lisp/textmodes/reftex-vars.el   |  18 +--
 lisp/textmodes/reftex.el        | 193 +++++++++++-------------------
 lisp/textmodes/remember.el      |  24 ++--
 lisp/textmodes/table.el         | 100 ++++++++--------
 lisp/textmodes/tex-mode.el      |  72 +++++------
 lisp/textmodes/texinfmt.el      | 160 +++++++++++++------------
 lisp/textmodes/texinfo.el       | 120 ++++++++++---------
 lisp/textmodes/texnfo-upd.el    |  30 ++---
 lisp/textmodes/text-mode.el     |   4 +-
 lisp/textmodes/tildify.el       |   6 +-
 lisp/textmodes/two-column.el    |  30 ++---
 33 files changed, 815 insertions(+), 910 deletions(-)

diff --git a/lisp/textmodes/bib-mode.el b/lisp/textmodes/bib-mode.el
index ec21987..e2fd3ec 100644
--- a/lisp/textmodes/bib-mode.el
+++ b/lisp/textmodes/bib-mode.el
@@ -29,6 +29,8 @@
 ;;   bibliography file.  Keys are automagically inserted as you type,
 ;;   and appropriate keys are presented for various kinds of entries.
 
+;; FIXME: Fix the namespace use of this library.
+
 ;;; Code:
 
 (defgroup bib nil
@@ -39,7 +41,7 @@
 
 (defcustom bib-file "~/my-bibliography.bib"
   "Default name of file used by `addbib'."
-    :type 'file)
+  :type 'file)
 
 (defcustom unread-bib-file "~/to-be-read.bib"
    "Default name of file used by `unread-bib' in Bib mode."
@@ -48,10 +50,10 @@
 (defvar bib-mode-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map text-mode-map)
-    (define-key map "\C-M" 'return-key-bib)
-    (define-key map "\C-c\C-u" 'unread-bib)
-    (define-key map "\C-c\C-@" 'mark-bib)
-    (define-key map "\e`" 'abbrev-mode)
+    (define-key map "\C-M" #'return-key-bib)
+    (define-key map "\C-c\C-u" #'unread-bib)
+    (define-key map "\C-c\C-@" #'mark-bib)
+    (define-key map "\e`" #'abbrev-mode)
     map))
 
 (defun addbib ()
diff --git a/lisp/textmodes/bibtex-style.el b/lisp/textmodes/bibtex-style.el
index 66d245f..8200334 100644
--- a/lisp/textmodes/bibtex-style.el
+++ b/lisp/textmodes/bibtex-style.el
@@ -70,7 +70,7 @@
   (setq-local outline-regexp "^[a-z]")
   (setq-local imenu-generic-expression
               '((nil "\\<\\(FUNCTION\\|MACRO\\)\\s-+{\\([^}\n]+\\)}" 2)))
-  (setq-local indent-line-function 'bibtex-style-indent-line)
+  (setq-local indent-line-function #'bibtex-style-indent-line)
   (setq-local parse-sexp-ignore-comments t)
   (setq font-lock-defaults
        '(bibtex-style-font-lock-keywords nil t
diff --git a/lisp/textmodes/dns-mode.el b/lisp/textmodes/dns-mode.el
index f1a7517..2fa5e8d 100644
--- a/lisp/textmodes/dns-mode.el
+++ b/lisp/textmodes/dns-mode.el
@@ -144,8 +144,8 @@ manually with \\[dns-mode-soa-increment-serial]."
 
 (defvar dns-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "\C-c\C-s" 'dns-mode-soa-increment-serial)
-    (define-key map "\C-c\C-e" 'dns-mode-ipv6-to-nibbles)
+    (define-key map "\C-c\C-s" #'dns-mode-soa-increment-serial)
+    (define-key map "\C-c\C-e" #'dns-mode-ipv6-to-nibbles)
     map)
   "Keymap for DNS master file mode.")
 
@@ -177,7 +177,7 @@ Turning on DNS mode runs `dns-mode-hook'."
   (setq-local comment-start-skip ";+ *")
   (setq-local font-lock-defaults
               '(dns-mode-font-lock-keywords nil nil ((?_ . "w"))))
-  (add-hook 'before-save-hook 'dns-mode-soa-maybe-increment-serial
+  (add-hook 'before-save-hook #'dns-mode-soa-maybe-increment-serial
             nil t))
 
 ;;;###autoload (defalias 'zone-mode 'dns-mode)
diff --git a/lisp/textmodes/enriched.el b/lisp/textmodes/enriched.el
index e43370c..ba8fac8 100644
--- a/lisp/textmodes/enriched.el
+++ b/lisp/textmodes/enriched.el
@@ -1,4 +1,4 @@
-;;; enriched.el --- read and save files in text/enriched format
+;;; enriched.el --- read and save files in text/enriched format  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1994-1996, 2001-2021 Free Software Foundation, Inc.
 
@@ -181,14 +181,16 @@ The value is a list of \(VAR VALUE VAR VALUE...).")
 
 (defvar enriched-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "\C-m" 'reindent-then-newline-and-indent)
+    ;; FIXME: These newline/reindent bindings might be redundant now
+    ;; that we have `electric-indent-mode' enabled by default.
+    (define-key map "\C-m" #'reindent-then-newline-and-indent)
     (define-key map
-      [remap newline-and-indent] 'reindent-then-newline-and-indent)
+      [remap newline-and-indent] #'reindent-then-newline-and-indent)
     (define-key map "\M-j" 'facemenu-justification-menu)
-    (define-key map "\M-S" 'set-justification-center)
-    (define-key map "\C-x\t" 'increase-left-margin)
-    (define-key map "\C-c[" 'set-left-margin)
-    (define-key map "\C-c]" 'set-right-margin)
+    (define-key map "\M-S" #'set-justification-center)
+    (define-key map "\C-x\t" #'increase-left-margin)
+    (define-key map "\C-c[" #'set-left-margin)
+    (define-key map "\C-c]" #'set-right-margin)
     map)
   "Keymap for Enriched mode.")
 
@@ -215,7 +217,7 @@ Commands:
   (cond ((null enriched-mode)
         ;; Turn mode off
          (remove-hook 'change-major-mode-hook
-                      'enriched-before-change-major-mode 'local)
+                      #'enriched-before-change-major-mode 'local)
         (setq buffer-file-format (delq 'text/enriched buffer-file-format))
         ;; restore old variable values
         (while enriched-old-bindings
@@ -232,7 +234,7 @@ Commands:
 
        (t                              ; Turn mode on
          (add-hook 'change-major-mode-hook
-                   'enriched-before-change-major-mode nil 'local)
+                   #'enriched-before-change-major-mode nil 'local)
         (add-to-list 'buffer-file-format 'text/enriched)
         ;; Save old variable values before we change them.
         ;; These will be restored if we exit Enriched mode.
@@ -245,10 +247,12 @@ Commands:
         (make-local-variable 'default-text-properties)
         (setq buffer-display-table  enriched-display-table)
         (use-hard-newlines 1 (if enriched-rerun-flag 'never nil))
-        (let ((sticky (plist-get default-text-properties 'front-sticky))
-              (p enriched-par-props))
-          (dolist (x p)
-            (add-to-list 'sticky x))
+        (let* ((sticky
+                (delete-dups
+                 (append
+                  enriched-par-props
+                  (copy-sequence
+                   (plist-get default-text-properties 'front-sticky))))))
           (if sticky
               (setq default-text-properties
                     (plist-put default-text-properties
@@ -264,7 +268,7 @@ Commands:
     (let ((enriched-rerun-flag t))
       (enriched-mode 1))))
 
-(add-hook 'after-change-major-mode-hook 'enriched-after-change-major-mode)
+(add-hook 'after-change-major-mode-hook #'enriched-after-change-major-mode)
 
 
 (fset 'enriched-mode-map enriched-mode-map)
@@ -342,7 +346,7 @@ the region, and the START and END of each region."
                  (if orig-buf (set-buffer orig-buf))
                  (funcall enriched-initial-annotation))))
       (enriched-map-property-regions 'hard
-       (lambda (v b e)
+       (lambda (v b _e)
          (if (and v (= ?\n (char-after b)))
              (progn (goto-char b) (insert "\n"))))
        (point) nil)
@@ -386,7 +390,7 @@ which can be the value of the `face' text property."
        ((and (listp face) (eq (car face) :background))
         (list (list "x-bg-color" (cadr face))))
        ((listp face)
-        (apply 'append (mapcar 'enriched-face-ans face)))
+        (apply #'append (mapcar #'enriched-face-ans face)))
        ((let* ((fg (face-attribute face :foreground))
                (bg (face-attribute face :background))
                 (weight (face-attribute face :weight))
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 6681b03..81cd2f0 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -45,7 +45,7 @@ A value of nil means that any change in indentation starts a 
new paragraph."
 (defcustom colon-double-space nil
   "Non-nil means put two spaces after a colon when filling."
   :type 'boolean)
-(put 'colon-double-space 'safe-local-variable 'booleanp)
+(put 'colon-double-space 'safe-local-variable #'booleanp)
 
 (defcustom fill-separate-heterogeneous-words-with-space nil
   "Non-nil means to use a space to separate words of a different kind.
diff --git a/lisp/textmodes/less-css-mode.el b/lisp/textmodes/less-css-mode.el
index 24ccb3c..d374cab 100644
--- a/lisp/textmodes/less-css-mode.el
+++ b/lisp/textmodes/less-css-mode.el
@@ -91,7 +91,7 @@ executable, e.g.: \"~/.gem/ruby/1.8/bin/lessc\"."
   "If non-nil, Less buffers are compiled to CSS after each save."
   :type 'boolean)
 ;;;###autoload
-(put 'less-css-compile-at-save 'safe-local-variable 'booleanp)
+(put 'less-css-compile-at-save 'safe-local-variable #'booleanp)
 
 (defcustom less-css-lessc-options '("--no-color")
   "Command line options for Less executable.
@@ -107,7 +107,7 @@ using `expand-file-name', so both relative and absolute 
paths
 will work as expected."
   :type '(choice (const :tag "Same as Less file" nil) directory))
 ;;;###autoload
-(put 'less-css-output-directory 'safe-local-variable 'stringp)
+(put 'less-css-output-directory 'safe-local-variable #'stringp)
 
 (defcustom less-css-output-file-name nil
   "File name in which to save CSS, or nil to use <name>.css for <name>.less.
@@ -133,7 +133,7 @@ the path is relative, it will be relative to the current
 directory by default."
   :type '(choice (const nil) file))
 ;;;###autoload
-(put 'less-css-input-file-name 'safe-local-variable 'stringp)
+(put 'less-css-input-file-name 'safe-local-variable #'stringp)
 (make-variable-buffer-local 'less-css-input-file-name)
 
 (defconst less-css-default-error-regex
@@ -211,7 +211,7 @@ directory by default."
 
 (defvar less-css-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "\C-c\C-c" 'less-css-compile)
+    (define-key map "\C-c\C-c" #'less-css-compile)
     map))
 
 ;;;###autoload (add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode))
@@ -226,7 +226,7 @@ Special commands:
   (setq-local comment-continue " *")
   (setq-local comment-start-skip "/[*/]+[ \t]*")
   (setq-local comment-end-skip "[ \t]*\\(?:\n\\|\\*+/\\)")
-  (add-hook 'after-save-hook 'less-css-compile-maybe nil t))
+  (add-hook 'after-save-hook #'less-css-compile-maybe nil t))
 
 (provide 'less-css-mode)
 ;;; less-css-mode.el ends here
diff --git a/lisp/textmodes/makeinfo.el b/lisp/textmodes/makeinfo.el
index f63894b..8152f4b 100644
--- a/lisp/textmodes/makeinfo.el
+++ b/lisp/textmodes/makeinfo.el
@@ -1,4 +1,4 @@
-;;; makeinfo.el --- run makeinfo conveniently
+;;; makeinfo.el --- run makeinfo conveniently  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1991, 1993, 2001-2021 Free Software Foundation, Inc.
 
@@ -93,7 +93,7 @@ apply to a temporary file, not the original; use the 
`makeinfo-buffer'
 command to gain use of `next-error'."
 
   (interactive "r")
-  (let (filename-or-header
+  (let (;; filename-or-header
         filename-or-header-beginning
         filename-or-header-end)
     ;; Cannot use `let' for makeinfo-temp-file or
@@ -173,7 +173,7 @@ command to gain use of `next-error'."
             t
              'makeinfo-compilation-sentinel-region)))))))
 
-(defun makeinfo-next-error (arg reset)
+(defun makeinfo-next-error (_arg _reset)
   "This function is used to disable `next-error' if the user has
 used `makeinfo-region'.  Since the compilation process is used on
 a temporary file in that case, calling `next-error' would give
diff --git a/lisp/textmodes/nroff-mode.el b/lisp/textmodes/nroff-mode.el
index 7d9b414..94519c3 100644
--- a/lisp/textmodes/nroff-mode.el
+++ b/lisp/textmodes/nroff-mode.el
@@ -47,12 +47,12 @@
 
 (defvar nroff-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "\t"  'tab-to-tab-stop)
-    (define-key map "\e?" 'nroff-count-text-lines)
-    (define-key map "\n"  'nroff-electric-newline)
-    (define-key map "\en" 'nroff-forward-text-line)
-    (define-key map "\ep" 'nroff-backward-text-line)
-    (define-key map "\C-c\C-c" 'nroff-view)
+    (define-key map "\t"  #'tab-to-tab-stop)
+    (define-key map "\e?" #'nroff-count-text-lines)
+    (define-key map "\n"  #'nroff-electric-newline)
+    (define-key map "\en" #'nroff-forward-text-line)
+    (define-key map "\ep" #'nroff-backward-text-line)
+    (define-key map "\C-c\C-c" #'nroff-view)
     map)
   "Major mode keymap for `nroff-mode'.")
 
diff --git a/lisp/textmodes/page-ext.el b/lisp/textmodes/page-ext.el
index c3e1fb1..87c91e8 100644
--- a/lisp/textmodes/page-ext.el
+++ b/lisp/textmodes/page-ext.el
@@ -293,7 +293,7 @@ Used by `pages-directory-for-addresses' function."
 ;; FIXME: Merely loading a package shouldn't have this kind of side-effects!
 (global-unset-key "\C-x\C-p")
 (define-key ctl-x-map "\C-p" #'pages-ctl-x-ctl-p-prefix)
-(define-obsolete-function-alias 'ctl-x-ctl-p-prefix 'pages-ctl-x-ctl-p-prefix 
"27.1")
+(define-obsolete-function-alias 'ctl-x-ctl-p-prefix #'pages-ctl-x-ctl-p-prefix 
"27.1")
 (defalias 'pages-ctl-x-ctl-p-prefix pages--ctl-x-ctl-p-map)
 
 
diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el
index 472c406..31e91c7 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -97,7 +97,7 @@ lines that start paragraphs from lines that separate them.
 If the variable `use-hard-newlines' is non-nil, then only lines following a
 hard newline are considered to match."
   :type 'regexp)
-(put 'paragraph-start 'safe-local-variable 'stringp)
+(put 'paragraph-start 'safe-local-variable #'stringp)
 
 ;; paragraph-start requires a hard newline, but paragraph-separate does not:
 ;; It is assumed that paragraph-separate is distinctive enough to be believed
@@ -114,7 +114,7 @@ the beginning of the line, so it should not use \"^\" as an 
anchor.  This
 ensures that the paragraph functions will work equally within a region of
 text indented by a margin setting."
   :type 'regexp)
-(put 'paragraph-separate 'safe-local-variable 'stringp)
+(put 'paragraph-separate 'safe-local-variable #'stringp)
 
 (defcustom sentence-end-double-space t
   "Non-nil means a single space does not end a sentence.
@@ -126,7 +126,7 @@ regexp describing the end of a sentence, when the value of 
the variable
 `sentence-end' is nil.  See Info node `(elisp)Standard Regexps'."
   :type 'boolean
   :group 'fill)
-(put 'sentence-end-double-space 'safe-local-variable 'booleanp)
+(put 'sentence-end-double-space 'safe-local-variable #'booleanp)
 
 (defcustom sentence-end-without-period nil
   "Non-nil means a sentence will end without a period.
@@ -138,7 +138,7 @@ regexp describing the end of a sentence, when the value of 
the variable
 `sentence-end' is nil.  See Info node `(elisp)Standard Regexps'."
   :type 'boolean
   :group 'fill)
-(put 'sentence-end-without-period 'safe-local-variable 'booleanp)
+(put 'sentence-end-without-period 'safe-local-variable #'booleanp)
 
 (defcustom sentence-end-without-space
   "。.?!"
@@ -148,7 +148,7 @@ This value is used by the function `sentence-end' to 
construct the
 regexp describing the end of a sentence, when the value of the variable
 `sentence-end' is nil.  See Info node `(elisp)Standard Regexps'."
   :type 'string)
-(put 'sentence-end-without-space 'safe-local-variable 'stringp)
+(put 'sentence-end-without-space 'safe-local-variable #'stringp)
 
 (defcustom sentence-end nil
   "Regexp describing the end of a sentence.
@@ -159,13 +159,13 @@ The value nil means to use the default value defined by 
the
 function `sentence-end'.  You should always use this function
 to obtain the value of this variable."
   :type '(choice regexp (const :tag "Use default value" nil)))
-(put 'sentence-end 'safe-local-variable 'string-or-null-p)
+(put 'sentence-end 'safe-local-variable #'string-or-null-p)
 
 (defcustom sentence-end-base "[.?!…‽][]\"'”’)}»›]*"
   "Regexp matching the basic end of a sentence, not including following space."
   :type 'regexp
   :version "25.1")
-(put 'sentence-end-base 'safe-local-variable 'stringp)
+(put 'sentence-end-base 'safe-local-variable #'stringp)
 
 (defun sentence-end ()
   "Return the regexp describing the end of a sentence.
@@ -193,13 +193,13 @@ in between.  See Info node `(elisp)Standard Regexps'."
 (defcustom page-delimiter "^\014"
   "Regexp describing line-beginnings that separate pages."
   :type 'regexp)
-(put 'page-delimiter 'safe-local-variable 'stringp)
+(put 'page-delimiter 'safe-local-variable #'stringp)
 
 (defcustom paragraph-ignore-fill-prefix nil
   "Non-nil means the paragraph commands are not affected by `fill-prefix'.
 This is desirable in modes where blank lines are the paragraph delimiters."
   :type 'boolean)
-(put 'paragraph-ignore-fill-prefix 'safe-local-variable 'booleanp)
+(put 'paragraph-ignore-fill-prefix 'safe-local-variable #'booleanp)
 
 ;; Silence the compiler.
 (defvar multiple-lines)
diff --git a/lisp/textmodes/refbib.el b/lisp/textmodes/refbib.el
index 2f3e024..084b17c 100644
--- a/lisp/textmodes/refbib.el
+++ b/lisp/textmodes/refbib.el
@@ -1,4 +1,4 @@
-;;; refbib.el --- convert refer-style references to ones usable by Latex bib
+;;; refbib.el --- convert refer-style references to ones usable by Latex bib  
-*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1989, 2001-2021 Free Software Foundation, Inc.
 
@@ -411,7 +411,7 @@ title if CAPITALIZE is true.  Returns value of VAR."
 with a comma and newline; if ABBREVS list is given, then
 try to replace the {DATA} with an abbreviation."
   (if data
-    (let (match nodelim multi-line index)
+    (let (match nodelim index) ;; multi-line
       (cond
        ((and abbrevs (setq match (assoc data abbrevs)))
          (if (null (cdr match))
@@ -507,7 +507,7 @@ but not a publisher."
 
 (defun r2b-barf-output ()
    "Generate bibtex based on global variables."
-   (let ((standard-output r2b-out-buf) (case-fold-search t) match)
+   (let ((standard-output r2b-out-buf) (case-fold-search t)) ;; match
 
       (r2b-trace "...barfing")
       (sit-for 0)
diff --git a/lisp/textmodes/refer.el b/lisp/textmodes/refer.el
index c2bf90f..53519ac 100644
--- a/lisp/textmodes/refer.el
+++ b/lisp/textmodes/refer.el
@@ -1,4 +1,4 @@
-;;; refer.el --- look up references in bibliography files
+;;; refer.el --- look up references in bibliography files  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1992, 1996, 2001-2021 Free Software Foundation, Inc.
 
@@ -176,7 +176,7 @@ found on the last `refer-find-entry' or 
`refer-find-next-entry'."
 
 (defun refer-find-entry-internal (keywords continue)
    (let ((keywords-list (refer-convert-string-to-list-of-strings keywords))
-         (old-buffer (current-buffer))
+         ;; (old-buffer (current-buffer))
          (old-window (selected-window))
          (new-window (selected-window))
          (files (if continue
@@ -184,7 +184,7 @@ found on the last `refer-find-entry' or 
`refer-find-next-entry'."
                   (setq refer-saved-pos nil)
                   (refer-get-bib-files)))
          (n 0)
-         (found nil)
+         ;; (found nil)
          (file nil))
      ;; find window in which to display bibliography file.
      ;; if a bibliography file is already displayed in a window, use
diff --git a/lisp/textmodes/refill.el b/lisp/textmodes/refill.el
index a6400c7..0a0e4cc 100644
--- a/lisp/textmodes/refill.el
+++ b/lisp/textmodes/refill.el
@@ -227,9 +227,9 @@ For true \"word wrap\" behavior, use `visual-line-mode' 
instead."
     (kill-local-variable 'refill-saved-state))
   (if refill-mode
       (progn
-       (add-hook 'after-change-functions 'refill-after-change-function nil t)
-       (add-hook 'post-command-hook 'refill-post-command-function nil t)
-       (add-hook 'pre-command-hook 'refill-pre-command-function nil t)
+       (add-hook 'after-change-functions #'refill-after-change-function nil t)
+       (add-hook 'post-command-hook #'refill-post-command-function nil t)
+       (add-hook 'pre-command-hook #'refill-pre-command-function nil t)
         (setq-local refill-saved-state
                     (mapcar (lambda (s) (cons s (symbol-value s)))
                             '(fill-paragraph-function auto-fill-function)))
@@ -244,8 +244,8 @@ For true \"word wrap\" behavior, use `visual-line-mode' 
instead."
        (overlay-put refill-ignorable-overlay 'insert-behind-hooks
                     '(refill-adjust-ignorable-overlay))
        (auto-fill-mode 0))
-    (remove-hook 'after-change-functions 'refill-after-change-function t)
-    (remove-hook 'post-command-hook 'refill-post-command-function t)
+    (remove-hook 'after-change-functions #'refill-after-change-function t)
+    (remove-hook 'post-command-hook #'refill-post-command-function t)
     (kill-local-variable 'backward-delete-char-untabify-method)))
 
 (provide 'refill)
diff --git a/lisp/textmodes/reftex-auc.el b/lisp/textmodes/reftex-auc.el
index ae3faec..8429fce 100644
--- a/lisp/textmodes/reftex-auc.el
+++ b/lisp/textmodes/reftex-auc.el
@@ -1,4 +1,4 @@
-;;; reftex-auc.el --- RefTeX's interface to AUCTeX
+;;; reftex-auc.el --- RefTeX's interface to AUCTeX  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
 
@@ -69,6 +69,8 @@ What is being used depends upon `reftex-plug-into-AUCTeX'."
         (LaTeX-add-labels label))
     (TeX-argument-insert label optional)))
 
+(declare-function LaTeX-add-bibitems "latex") ;FIXME: Can't find the definition
+
 ;;;###autoload
 (defun reftex-arg-cite (optional &optional prompt definition)
   "Use `reftex-citation' or AUCTeX's code to insert a cite-key macro argument.
@@ -82,13 +84,13 @@ What is being used depends upon `reftex-plug-into-AUCTeX'."
                           (if prompt prompt "Add key")
                           " (default none): "))
       (setq items (multi-prompt "," t prompt (LaTeX-bibitem-list)))))
-    (apply 'LaTeX-add-bibitems items)
-    (TeX-argument-insert (mapconcat 'identity items reftex-cite-key-separator)
+    (apply #'LaTeX-add-bibitems items)
+    (TeX-argument-insert (mapconcat #'identity items reftex-cite-key-separator)
                         optional)))
 
 
 ;;;###autoload
-(defun reftex-arg-index-tag (optional &optional prompt &rest args)
+(defun reftex-arg-index-tag (optional &optional prompt &rest _args)
   "Prompt for an index tag with completion.
 This is the name of an index, not the entry."
   (let (tag taglist)
@@ -102,13 +104,13 @@ This is the name of an index, not the entry."
           (setq taglist
                 (cdr (assoc 'index-tags
                             (symbol-value reftex-docstruct-symbol)))
-                tag (completing-read prompt (mapcar 'list taglist))))
+                tag (completing-read prompt (mapcar #'list taglist))))
       ;; Just ask like AUCTeX does.
       (setq tag (read-string prompt)))
     (TeX-argument-insert tag optional)))
 
 ;;;###autoload
-(defun reftex-arg-index (optional &optional prompt &rest args)
+(defun reftex-arg-index (optional &optional prompt &rest _args)
   "Prompt for an index entry completing with known entries.
 Completion is specific for just one index, if the macro or a tag
 argument identify one of multiple indices."
@@ -149,23 +151,27 @@ argument identify one of multiple indices."
   ;; `reftex-plug-into-AUCTeX'.
 
   (if (reftex-plug-flag 0)
-      (setq LaTeX-label-function 'reftex-label)
-    (setq LaTeX-label-function nil))
-
-  (and (or (reftex-plug-flag 1) (reftex-plug-flag 2))
-       (fboundp 'TeX-arg-label)
-       (fset 'TeX-arg-label 'reftex-arg-label))
-
-  (and (reftex-plug-flag 3)
-       (fboundp 'TeX-arg-cite)
-       (fset 'TeX-arg-cite 'reftex-arg-cite))
-
-  (and (reftex-plug-flag 4)
-       (fboundp 'TeX-arg-index-tag)
-       (fset 'TeX-arg-index-tag 'reftex-arg-index-tag))
-  (and (reftex-plug-flag 4)
-       (fboundp 'TeX-arg-index)
-       (fset 'TeX-arg-index 'reftex-arg-index)))
+      (if (bound-and-true-p LaTeX-label-function)
+          (add-function :override LaTeX-label-function #'reftex-label)
+        (setq LaTeX-label-function #'reftex-label))
+    (if (eq #'reftex-label (bound-and-true-p LaTeX-label-function))
+        (setq LaTeX-label-function nil)
+      (remove-function LaTeX-label-function #'reftex-label)))
+
+  (if (or (reftex-plug-flag 1) (reftex-plug-flag 2))
+      (advice-add 'TeX-arg-label :override #'reftex-arg-label)
+    (advice-remove 'TeX-arg-label #'reftex-arg-label))
+
+  (if (reftex-plug-flag 3)
+      (advice-add 'TeX-arg-cite :override #'reftex-arg-cite)
+    (advice-remove 'TeX-arg-cite #'reftex-arg-cite))
+
+  (if (reftex-plug-flag 4)
+      (advice-add 'TeX-arg-index-tag :override #'reftex-arg-index-tag)
+    (advice-remove 'TeX-arg-index-tag #'reftex-arg-index-tag))
+  (if (reftex-plug-flag 4)
+      (advice-add 'TeX-arg-index :override #'reftex-arg-index)
+    (advice-remove 'TeX-arg-index #'reftex-arg-index)))
 
 ;;;###autoload
 (defun reftex-toggle-plug-into-AUCTeX ()
@@ -205,7 +211,7 @@ the label information is recompiled on next use."
       (when changed
         (put reftex-docstruct-symbol 'reftex-label-alist-style list)))))
 ;;;###autoload
-(defalias 'reftex-add-to-label-alist 'reftex-add-label-environments)
+(defalias 'reftex-add-to-label-alist #'reftex-add-label-environments)
 
 ;;;###autoload
 (defun reftex-add-section-levels (entry-list)
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index 5579e40..650d11d 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -1,4 +1,4 @@
-;;; reftex-cite.el --- creating citations with RefTeX
+;;; reftex-cite.el --- creating citations with RefTeX  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
 
@@ -310,11 +310,11 @@ Return list with entries."
     ;; Sorting
     (cond
      ((eq 'author reftex-sort-bibtex-matches)
-      (sort found-list 'reftex-bib-sort-author))
+      (sort found-list #'reftex-bib-sort-author))
      ((eq 'year   reftex-sort-bibtex-matches)
-      (sort found-list 'reftex-bib-sort-year))
+      (sort found-list #'reftex-bib-sort-year))
      ((eq 'reverse-year reftex-sort-bibtex-matches)
-      (sort found-list 'reftex-bib-sort-year-reverse))
+      (sort found-list #'reftex-bib-sort-year-reverse))
      (t found-list))))
 
 (defun reftex-bib-sort-author (e1 e2)
@@ -390,7 +390,7 @@ The environment should be located in FILES."
              (when (and start end)
                (setq entries
                      (append entries
-                             (mapcar 'reftex-parse-bibitem
+                             (mapcar #'reftex-parse-bibitem
                                      (delete ""
                                              (split-string
                                               (buffer-substring-no-properties
@@ -533,7 +533,7 @@ If FORMAT is non-nil `format' entry accordingly."
   "Format a BibTeX ENTRY so that it is nice to look at."
   (let*
       ((auth-list (reftex-get-bib-names "author" entry))
-       (authors (mapconcat 'identity auth-list ", "))
+       (authors (mapconcat #'identity auth-list ", "))
        (year      (reftex-get-bib-field "year" entry))
        (title     (reftex-get-bib-field "title" entry))
        (type      (reftex-get-bib-field "&type" entry))
@@ -607,7 +607,7 @@ If FORMAT is non-nil `format' entry accordingly."
         (push (substring text 0 (+ 60 (match-beginning 0))) lines)
         (setq text (substring text (+ 61 (match-beginning 0)))))
     (push text lines)
-    (setq text (mapconcat 'identity (nreverse lines) "\n     "))
+    (setq text (mapconcat #'identity (nreverse lines) "\n     "))
 
     (when (reftex-use-fonts)
       (put-text-property 0 (length text) 'face reftex-bib-author-face text))
@@ -676,7 +676,7 @@ While entering the regexp, completion on knows citation 
keys is possible.
       ;; All keys go into a single command - we need to trick a little
       ;; FIXME: Unfortunately, this means that commenting does not work right.
       (pop selected-entries)
-      (let ((concat-keys (mapconcat 'car selected-entries
+      (let ((concat-keys (mapconcat #'car selected-entries
                                    reftex-cite-key-separator)))
         (setq insert-entries
               (list (list concat-keys (cons "&key" concat-keys))))))
@@ -726,7 +726,7 @@ While entering the regexp, completion on knows citation 
keys is possible.
       (when (and reftex-mode
                  (fboundp 'LaTeX-add-bibitems)
                  reftex-plug-into-AUCTeX)
-        (apply 'LaTeX-add-bibitems (mapcar 'car selected-entries)))
+        (apply #'LaTeX-add-bibitems (mapcar #'car selected-entries)))
 
       ;; Produce the cite-view strings
       (when (and reftex-mode reftex-cache-cite-echo cite-view)
@@ -749,7 +749,7 @@ While entering the regexp, completion on knows citation 
keys is possible.
         (forward-char 1)))
 
     ;; Return the citation key
-    (mapcar 'car selected-entries)))
+    (mapcar #'car selected-entries)))
 
 (defun reftex-figure-out-cite-format (arg &optional no-insert format-key)
   "Check if there is already a cite command at point and change cite format
@@ -815,15 +815,16 @@ in order to only add another reference in the same cite 
command."
   (reftex-citation nil ?t))
 
 (defvar reftex-select-bib-map)
+(defvar reftex--found-list)
 (defun reftex-offer-bib-menu ()
   "Offer bib menu and return list of selected items."
   (let ((bibtype (reftex-bib-or-thebib))
-        found-list rtn key data selected-entries)
+        reftex--found-list rtn key data selected-entries)
     (while
         (not
          (catch 'done
            ;; Scan bibtex files
-           (setq found-list
+           (setq reftex--found-list
               (cond
                ((eq bibtype 'bib)
 ;              ((assq 'bib (symbol-value reftex-docstruct-symbol))
@@ -834,7 +835,7 @@ in order to only add another reference in the same cite 
command."
                 ;; using thebibliography environment.
                 (reftex-extract-bib-entries-from-thebibliography
                  (reftex-uniquify
-                  (mapcar 'cdr
+                  (mapcar #'cdr
                           (reftex-all-assq
                            'thebib (symbol-value reftex-docstruct-symbol))))))
                (reftex-default-bibliography
@@ -842,7 +843,7 @@ in order to only add another reference in the same cite 
command."
                 (reftex-extract-bib-entries (reftex-default-bibliography)))
                (t (error "No valid bibliography in this document, and no 
default available"))))
 
-           (unless found-list
+           (unless reftex--found-list
              (error "Sorry, no matches found"))
 
           ;; Remember where we came from
@@ -854,11 +855,11 @@ in order to only add another reference in the same cite 
command."
             (delete-other-windows)
             (reftex-kill-buffer "*RefTeX Select*")
             (switch-to-buffer-other-window "*RefTeX Select*")
-            (unless (eq major-mode 'reftex-select-bib-mode)
+            (unless (derived-mode-p 'reftex-select-bib-mode)
               (reftex-select-bib-mode))
-            (let ((buffer-read-only nil))
+            (let ((inhibit-read-only t))
               (erase-buffer)
-              (reftex-insert-bib-matches found-list))
+              (reftex-insert-bib-matches reftex--found-list))
             (setq buffer-read-only t)
             (if (= 0 (buffer-size))
                 (error "No matches found"))
@@ -881,34 +882,36 @@ in order to only add another reference in the same cite 
command."
                 (throw 'done nil))
                ((eq key ?r)
                 ;; Restrict with new regular expression
-                (setq found-list (reftex-restrict-bib-matches found-list))
+                (setq reftex--found-list
+                      (reftex-restrict-bib-matches reftex--found-list))
                 (let ((buffer-read-only nil))
                   (erase-buffer)
-                  (reftex-insert-bib-matches found-list))
+                  (reftex-insert-bib-matches reftex--found-list))
                 (goto-char 1))
                ((eq key ?A)
                 ;; Take all (marked)
                 (setq selected-entries
                       (if reftex-select-marked
-                          (mapcar 'car (nreverse reftex-select-marked))
-                        found-list))
+                          (mapcar #'car (nreverse reftex-select-marked))
+                        reftex--found-list))
                 (throw 'done t))
                ((eq key ?a)
                 ;; Take all (marked), and push the symbol 'concat
                 (setq selected-entries
                       (cons 'concat
                             (if reftex-select-marked
-                                (mapcar 'car (nreverse reftex-select-marked))
-                              found-list)))
+                                (mapcar #'car (nreverse reftex-select-marked))
+                              reftex--found-list)))
                 (throw 'done t))
                ((eq key ?e)
                 ;; Take all (marked), and push the symbol 'concat
-                (reftex-extract-bib-file found-list reftex-select-marked)
+                (reftex-extract-bib-file reftex--found-list
+                                         reftex-select-marked)
                 (setq selected-entries "BibTeX database file created")
                 (throw 'done t))
                ((eq key ?E)
                 ;; Take all (marked), and push the symbol 'concat
-                (reftex-extract-bib-file found-list reftex-select-marked
+                (reftex-extract-bib-file reftex--found-list 
reftex-select-marked
                                          'complement)
                 (setq selected-entries "BibTeX database file created")
                 (throw 'done t))
@@ -918,7 +921,7 @@ in order to only add another reference in the same cite 
command."
                 (setq selected-entries
                       (if reftex-select-marked
                           (cons 'concat
-                                (mapcar 'car (nreverse reftex-select-marked)))
+                                (mapcar #'car (nreverse reftex-select-marked)))
                         (if data (list data) nil)))
                 (throw 'done t))
                ((stringp key)
@@ -971,7 +974,7 @@ in order to only add another reference in the same cite 
command."
                              nil)
                          (cdr (assoc "&entry" x))))
                      all)))
-    (insert (mapconcat 'identity all "\n\n"))
+    (insert (mapconcat #'identity all "\n\n"))
     (save-buffer)
     (goto-char (point-min))))
 
@@ -1004,7 +1007,7 @@ in order to only add another reference in the same cite 
command."
             last (nth (1- n) namelist))
       (setcdr (nthcdr (- n 2) namelist) nil)
       (concat
-       (mapconcat 'identity namelist (nth 0 reftex-cite-punctuation))
+       (mapconcat #'identity namelist (nth 0 reftex-cite-punctuation))
        (nth 1 reftex-cite-punctuation)
        last)))))
 
@@ -1100,7 +1103,7 @@ in order to only add another reference in the same cite 
command."
         (put reftex-docstruct-symbol 'modified t)))
     string))
 
-(defun reftex-bibtex-selection-callback (data ignore no-revisit)
+(defun reftex-bibtex-selection-callback (data _ignore no-revisit)
   "Callback function to be called from the BibTeX selection, in
 order to display context.  This function is relatively slow and not
 recommended for follow mode.  It works OK for individual lookups."
@@ -1119,7 +1122,7 @@ recommended for follow mode.  It works OK for individual 
lookups."
 ;        ((assq 'thebib (symbol-value reftex-docstruct-symbol))
           (setq bibfile-list
                 (reftex-uniquify
-                 (mapcar 'cdr
+                 (mapcar #'cdr
                          (reftex-all-assq
                           'thebib (symbol-value reftex-docstruct-symbol))))
                 item t))
@@ -1163,7 +1166,7 @@ recommended for follow mode.  It works OK for individual 
lookups."
   "Return a list of BibTeX @string references that appear as values in ALIST."
   (reftex-remove-if (lambda (x) (string-match "^\\([\"{]\\|[0-9]+$\\)" x))
                    ;; get list of values, discard keys
-                   (mapcar 'cdr
+                   (mapcar #'cdr
                            ;; remove &key and &type entries
                            (reftex-remove-if (lambda (pair)
                                                (string-match "^&" (car pair)))
@@ -1186,7 +1189,7 @@ created files in the variables 
`reftex-create-bibtex-header' or
   (interactive "FNew BibTeX file: ")
   (let ((keys (reftex-all-used-citation-keys))
         (files (reftex-get-bibfile-list))
-        file key entries beg end entry string-keys string-entries)
+        key entries beg end entry string-keys string-entries)
     (save-current-buffer
       (dolist (file files)
         (set-buffer (reftex-get-file-buffer-force file 'mark))
@@ -1252,9 +1255,9 @@ created files in the variables 
`reftex-create-bibtex-header' or
           (error "Abort")))
     (erase-buffer)
     (if reftex-create-bibtex-header (insert reftex-create-bibtex-header 
"\n\n"))
-    (insert (mapconcat 'identity (reverse string-entries) "\n\n"))
+    (insert (mapconcat #'identity (reverse string-entries) "\n\n"))
     (if string-entries (insert "\n\n\n"))
-    (insert (mapconcat 'identity (reverse entries) "\n\n"))
+    (insert (mapconcat #'identity (reverse entries) "\n\n"))
     (if reftex-create-bibtex-footer (insert "\n\n" 
reftex-create-bibtex-footer))
     (goto-char (point-min))
     (save-buffer)
diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el
index e517cea..a21dd33 100644
--- a/lisp/textmodes/reftex-dcr.el
+++ b/lisp/textmodes/reftex-dcr.el
@@ -1,4 +1,4 @@
-;;; reftex-dcr.el --- viewing cross references and citations with RefTeX
+;;; reftex-dcr.el --- viewing cross references and citations with RefTeX  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
 
@@ -132,7 +132,7 @@ to the functions `reftex-view-cr-cite' and 
`reftex-view-cr-ref'."
      ((eq bibtype 'thebib)
       (setq item t
             files (reftex-uniquify
-                   (mapcar 'cdr
+                   (mapcar #'cdr
                            (reftex-all-assq
                             'thebib (symbol-value reftex-docstruct-symbol))))))
      (reftex-default-bibliography
@@ -161,10 +161,10 @@ to the functions `reftex-view-cr-cite' and 
`reftex-view-cr-ref'."
           (shrink-window (1- (- (window-height) size)))
           (recenter 0))
         ;; Arrange restoration
-        (add-hook 'pre-command-hook 'reftex-restore-window-conf))
+        (add-hook 'pre-command-hook #'reftex-restore-window-conf))
 
         ;; Normal display in other window
-      (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
+      (add-hook 'pre-command-hook #'reftex-highlight-shall-die)
       (setq pop-win (selected-window))
       (select-window win)
       (goto-char pos)
@@ -212,13 +212,13 @@ to the functions `reftex-view-cr-cite' and 
`reftex-view-cr-ref'."
           (error (set-window-configuration window-conf)
                  (message "ref: Label %s not found" label)
                  (error "ref: Label %s not found" label)))) ;; 2nd is line OK
-      (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
+      (add-hook 'pre-command-hook #'reftex-highlight-shall-die)
 
       (when (eq how 'tmp-window)
         ;; Resize window and arrange restoration
         (shrink-window (1- (- (window-height) 9)))
         (recenter '(4))
-        (add-hook 'pre-command-hook 'reftex-restore-window-conf))
+        (add-hook 'pre-command-hook #'reftex-restore-window-conf))
       (setq pop-win (selected-window))
       (select-window win)
       (goto-char pos)
@@ -266,7 +266,7 @@ With argument, actually select the window showing the cross 
reference."
 (defun reftex-restore-window-conf ()
   (set-window-configuration (get 'reftex-auto-view-crossref 'last-window-conf))
   (put 'reftex-auto-view-crossref 'last-window-conf nil)
-  (remove-hook 'pre-command-hook 'reftex-restore-window-conf))
+  (remove-hook 'pre-command-hook #'reftex-restore-window-conf))
 
 (defun reftex-echo-ref (label entry docstruct)
   ;; Display crossref info in echo area.
@@ -320,10 +320,6 @@ With argument, actually select the window showing the 
cross reference."
       (with-current-buffer buf
         (run-hooks 'reftex-display-copied-context-hook)))))
 
-(defvar reftex-use-itimer-in-xemacs nil
-  "Non-nil means use the idle timers in XEmacs for crossref display.
-Currently, idle timer restart is broken and we use the post-command-hook.")
-
 ;;;###autoload
 (defun reftex-toggle-auto-view-crossref ()
   "Toggle the automatic display of crossref information in the echo area.
@@ -332,36 +328,16 @@ will display info in the echo area."
   (interactive)
   (if reftex-auto-view-crossref-timer
       (progn
-        (if (featurep 'xemacs)
-            (if reftex-use-itimer-in-xemacs
-                (delete-itimer reftex-auto-view-crossref-timer)
-              (remove-hook 'post-command-hook 'reftex-start-itimer-once))
-          (cancel-timer reftex-auto-view-crossref-timer))
+        (cancel-timer reftex-auto-view-crossref-timer)
         (setq reftex-auto-view-crossref-timer nil)
         (message "Automatic display of crossref information was turned off"))
     (setq reftex-auto-view-crossref-timer
-          (if (featurep 'xemacs)
-              (if reftex-use-itimer-in-xemacs
-                  (start-itimer "RefTeX Idle Timer"
-                                'reftex-view-crossref-when-idle
-                                reftex-idle-time reftex-idle-time t)
-                (add-hook 'post-command-hook 'reftex-start-itimer-once)
-                t)
-            (run-with-idle-timer
-             reftex-idle-time t 'reftex-view-crossref-when-idle)))
+          (run-with-idle-timer
+           reftex-idle-time t #'reftex-view-crossref-when-idle))
     (unless reftex-auto-view-crossref
       (setq reftex-auto-view-crossref t))
     (message "Automatic display of crossref information was turned on")))
 
-(defun reftex-start-itimer-once ()
-   (and (featurep 'xemacs)
-       reftex-mode
-        (not (itimer-live-p reftex-auto-view-crossref-timer))
-        (setq reftex-auto-view-crossref-timer
-              (start-itimer "RefTeX Idle Timer"
-                            'reftex-view-crossref-when-idle
-                            reftex-idle-time nil t))))
-
 ;;;###autoload
 (defun reftex-view-crossref-from-bibtex (&optional arg)
   "View location in a LaTeX document which cites the BibTeX entry at point.
@@ -431,7 +407,7 @@ Calling this function several times find successive 
citation locations."
           (put 'reftex-view-regexp-match :cnt (cl-incf cnt))
           (reftex-highlight 0 (match-beginning highlight-group)
                             (match-end highlight-group))
-          (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
+          (add-hook 'pre-command-hook #'reftex-highlight-shall-die)
           (setq pop-window (selected-window)))
       (put 'reftex-view-regexp-match :props nil)
       (or cont (set-window-configuration window-conf)))
diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el
index 4d02160..3b7518e 100644
--- a/lisp/textmodes/reftex-global.el
+++ b/lisp/textmodes/reftex-global.el
@@ -1,4 +1,4 @@
-;;; reftex-global.el --- operations on entire documents with RefTeX
+;;; reftex-global.el --- operations on entire documents with RefTeX  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
 
@@ -39,7 +39,7 @@ The TAGS file is also immediately visited with 
`visit-tags-table'."
   (reftex-access-scan-info current-prefix-arg)
   (let* ((master (reftex-TeX-master-file))
          (files  (reftex-all-document-files))
-         (cmd    (format "etags %s" (mapconcat 'shell-quote-argument
+         (cmd    (format "etags %s" (mapconcat #'shell-quote-argument
                                               files " "))))
     (with-current-buffer (reftex-get-file-buffer-force master)
       (message "Running etags to create TAGS file...")
@@ -65,7 +65,7 @@ No active TAGS table is required."
   (let* ((files  (reftex-all-document-files t))
          (cmd    (format
                   "%s %s" grep-cmd
-                  (mapconcat 'identity files " "))))
+                  (mapconcat #'identity files " "))))
     (grep cmd)))
 
 ;;;###autoload
@@ -160,7 +160,7 @@ No active TAGS table is required."
       (when (and (car (car dlist))
                  (cdr (car dlist)))
         (cl-incf cnt)
-        (insert (mapconcat 'identity (car dlist) "\n    ") "\n"))
+        (insert (mapconcat #'identity (car dlist) "\n    ") "\n"))
       (pop dlist))
     (goto-char (point-min))
     (when (= cnt 0)
@@ -208,7 +208,7 @@ one with the `xr' package."
       (error "Abort"))
   ;; Make the translation list
   (let* ((re-core (concat "\\("
-                          (mapconcat 'cdr reftex-typekey-to-prefix-alist "\\|")
+                          (mapconcat #'cdr reftex-typekey-to-prefix-alist 
"\\|")
                           "\\)"))
          (label-re (concat "\\`" re-core "\\([0-9]+\\)\\'"))
          (search-re (concat "[{,]\\(" re-core "\\([0-9]+\\)\\)[,}]"))
@@ -326,7 +326,7 @@ labels."
         file buffer)
     (save-current-buffer
       (while (setq file (pop files))
-        (setq buffer (reftex-get-buffer-visiting file))
+        (setq buffer (find-buffer-visiting file))
         (when buffer
           (set-buffer buffer)
           (save-buffer))))))
@@ -344,7 +344,7 @@ Also checks if buffers visiting the files are in read-only 
mode."
         (ding)
         (or (y-or-n-p (format "No write access to %s. Continue? " file))
             (error "Abort")))
-      (when (and (setq buf (reftex-get-buffer-visiting file))
+      (when (and (setq buf (find-buffer-visiting file))
                  (with-current-buffer buf
                    buffer-read-only))
         (ding)
@@ -366,10 +366,10 @@ Also checks if buffers visiting the files are in 
read-only mode."
   (goto-char (if isearch-forward (point-min) (point-max))))
 
 (defun reftex-isearch-push-state-function ()
-  `(lambda (cmd)
-     (reftex-isearch-pop-state-function cmd ,(current-buffer))))
+  (let ((buf (current-buffer)))
+    (lambda (cmd) (reftex-isearch-pop-state-function cmd buf))))
 
-(defun reftex-isearch-pop-state-function (cmd buffer)
+(defun reftex-isearch-pop-state-function (_cmd buffer)
   (switch-to-buffer buffer))
 
 (defun reftex-isearch-isearch-search (string bound noerror)
@@ -451,17 +451,17 @@ With no argument, this command toggles
                  (if (boundp 'multi-isearch-next-buffer-function)
                      (set (make-local-variable
                            'multi-isearch-next-buffer-function)
-                          'reftex-isearch-switch-to-next-file)
+                          #'reftex-isearch-switch-to-next-file)
                    (set (make-local-variable 'isearch-wrap-function)
-                        'reftex-isearch-wrap-function)
+                        #'reftex-isearch-wrap-function)
                    (set (make-local-variable 'isearch-search-fun-function)
-                        (lambda () 'reftex-isearch-isearch-search))
+                        (lambda () #'reftex-isearch-isearch-search))
                    (set (make-local-variable 'isearch-push-state-function)
-                        'reftex-isearch-push-state-function)
+                        #'reftex-isearch-push-state-function)
                    (set (make-local-variable 'isearch-next-buffer-function)
-                        'reftex-isearch-switch-to-next-file))
+                        #'reftex-isearch-switch-to-next-file))
                  (setq reftex-isearch-minor-mode t))))
-           (add-hook 'reftex-mode-hook 'reftex-isearch-minor-mode))
+           (add-hook 'reftex-mode-hook #'reftex-isearch-minor-mode))
        (dolist (crt-buf (buffer-list))
          (with-current-buffer crt-buf
            (when reftex-mode
@@ -472,7 +472,7 @@ With no argument, this command toggles
                (kill-local-variable 'isearch-push-state-function)
                (kill-local-variable 'isearch-next-buffer-function))
              (setq reftex-isearch-minor-mode nil))))
-       (remove-hook 'reftex-mode-hook 'reftex-isearch-minor-mode)))
+       (remove-hook 'reftex-mode-hook #'reftex-isearch-minor-mode)))
     ;; Force mode line redisplay.
     (set-buffer-modified-p (buffer-modified-p))))
 
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el
index 5049ffb..28cc7db 100644
--- a/lisp/textmodes/reftex-index.el
+++ b/lisp/textmodes/reftex-index.el
@@ -1,4 +1,4 @@
-;;; reftex-index.el --- index support with RefTeX
+;;; reftex-index.el --- index support with RefTeX  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
 
@@ -30,8 +30,6 @@
 (require 'reftex)
 
 ;; START remove for XEmacs release
-(defvar mark-active)
-(defvar transient-mark-mode)
 (defvar TeX-master)
 ;; END remove for XEmacs release
 
@@ -49,7 +47,7 @@ which is part of AUCTeX, the string is first processed with 
the
   (interactive "P")
   (let* ((use-default (not (equal arg '(16))))  ; check for double prefix
          ;; check if we have an active selection
-         (active (reftex-region-active-p))
+         (active (region-active-p))
          (beg (if active
                   (region-beginning)
                 (save-excursion
@@ -89,7 +87,7 @@ which is part of AUCTeX, the string is first processed with 
the
         (reftex-index def-char full-entry def-tag sel)))))
 
 ;;;###autoload
-(defun reftex-index (&optional char key tag sel no-insert)
+(defun reftex-index (&optional char key tag sel _no-insert)
   "Query for an index macro and insert it along with its arguments.
 The index macros available are those defined in `reftex-index-macro' or
 by a call to `reftex-add-index-macros', typically from an AUCTeX style file.
@@ -178,7 +176,7 @@ will prompt for other arguments."
                                                  (format "default %s" default))
                                        "")))
                           ": ")))
-        (tag (completing-read prompt (mapcar 'list index-tags))))
+        (tag (completing-read prompt (mapcar #'list index-tags))))
     (if (and default (equal tag "")) (setq tag default))
     (reftex-update-default-index tag)
     tag))
@@ -239,7 +237,7 @@ will prompt for other arguments."
                           (format "[^M]  %s (the default)\n" default)
                         "")
                       (mapconcat (lambda(x)
-                                   (apply 'format "[%c]   %s" x))
+                                   (apply #'format "[%c]   %s" x))
                                  tag-alist "\n")))
         ;; Query the user for an index-tag
         (setq rpl (reftex-select-with-char prompt help 3 t))
@@ -278,56 +276,57 @@ will prompt for other arguments."
 (defvar reftex-index-mode-map
   (let ((map (make-sparse-keymap)))
     ;; Index map
-    (define-key map (if (featurep 'xemacs) [(button2)] [(mouse-2)])
-      'reftex-index-mouse-goto-line-and-hide)
+    (define-key map [(mouse-2)] #'reftex-index-mouse-goto-line-and-hide)
     (define-key map [follow-link] 'mouse-face)
 
     (substitute-key-definition
-     'next-line 'reftex-index-next map global-map)
+     #'next-line #'reftex-index-next map global-map)
     (substitute-key-definition
-     'previous-line 'reftex-index-previous map global-map)
-
-    (define-key map "n" 'reftex-index-next)
-    (define-key map "p" 'reftex-index-previous)
-    (define-key map "?" 'reftex-index-show-help)
-    (define-key map " " 'reftex-index-view-entry)
-    (define-key map "\C-m" 'reftex-index-goto-entry-and-hide)
-    (define-key map "\C-i" 'reftex-index-goto-entry)
-    (define-key map "\C-k" 'reftex-index-kill)
-    (define-key map "r" 'reftex-index-rescan)
-    (define-key map "R" 'reftex-index-Rescan)
-    (define-key map "g" 'revert-buffer)
-    (define-key map "q" 'reftex-index-quit)
-    (define-key map "k" 'reftex-index-quit-and-kill)
-    (define-key map "f" 'reftex-index-toggle-follow)
-    (define-key map "s" 'reftex-index-switch-index-tag)
-    (define-key map "e" 'reftex-index-edit)
-    (define-key map "^" 'reftex-index-level-up)
-    (define-key map "_" 'reftex-index-level-down)
-    (define-key map "}" 'reftex-index-restrict-to-section)
-    (define-key map "{" 'reftex-index-widen)
-    (define-key map ">" 'reftex-index-restriction-forward)
-    (define-key map "<" 'reftex-index-restriction-backward)
-    (define-key map "(" 'reftex-index-toggle-range-beginning)
-    (define-key map ")" 'reftex-index-toggle-range-end)
-    (define-key map "|" 'reftex-index-edit-attribute)
-    (define-key map "@" 'reftex-index-edit-visual)
-    (define-key map "*" 'reftex-index-edit-key)
-    (define-key map "\C-c=" 'reftex-index-goto-toc)
-    (define-key map "c" 'reftex-index-toggle-context)
+     #'previous-line #'reftex-index-previous map global-map)
+
+    (define-key map "n" #'reftex-index-next)
+    (define-key map "p" #'reftex-index-previous)
+    (define-key map "?" #'reftex-index-show-help)
+    (define-key map " " #'reftex-index-view-entry)
+    (define-key map "\C-m" #'reftex-index-goto-entry-and-hide)
+    (define-key map "\C-i" #'reftex-index-goto-entry)
+    (define-key map "\C-k" #'reftex-index-kill)
+    (define-key map "r" #'reftex-index-rescan)
+    (define-key map "R" #'reftex-index-Rescan)
+    (define-key map "g" #'revert-buffer)
+    (define-key map "q" #'reftex-index-quit)
+    (define-key map "k" #'reftex-index-quit-and-kill)
+    (define-key map "f" #'reftex-index-toggle-follow)
+    (define-key map "s" #'reftex-index-switch-index-tag)
+    (define-key map "e" #'reftex-index-edit)
+    (define-key map "^" #'reftex-index-level-up)
+    (define-key map "_" #'reftex-index-level-down)
+    (define-key map "}" #'reftex-index-restrict-to-section)
+    (define-key map "{" #'reftex-index-widen)
+    (define-key map ">" #'reftex-index-restriction-forward)
+    (define-key map "<" #'reftex-index-restriction-backward)
+    (define-key map "(" #'reftex-index-toggle-range-beginning)
+    (define-key map ")" #'reftex-index-toggle-range-end)
+    (define-key map "|" #'reftex-index-edit-attribute)
+    (define-key map "@" #'reftex-index-edit-visual)
+    (define-key map "*" #'reftex-index-edit-key)
+    (define-key map "\C-c=" #'reftex-index-goto-toc)
+    (define-key map "c" #'reftex-index-toggle-context)
 
     ;; The capital letters and the exclamation mark
-    (cl-loop for key across (concat "!" reftex-index-section-letters) do
-             (define-key map (vector (list key))
-               (list 'lambda '() '(interactive)
-                     (list 'reftex-index-goto-letter key))))
+    (mapc (lambda (key)
+            (define-key map (vector (list key))
+              (lambda () (interactive)
+                (reftex-index-goto-letter key))))
+          (concat "!" reftex-index-section-letters))
 
     (easy-menu-define reftex-index-menu map
       "Menu for Index buffer"
       '("Index"
         ["Goto section A-Z"
          (message "To go to a section, just press any of: !%s"
-                  reftex-index-section-letters) t]
+                  reftex-index-section-letters)
+         t]
         ["Show Entry" reftex-index-view-entry t]
         ["Go To Entry" reftex-index-goto-entry t]
         ["Exit & Go To Entry" reftex-index-goto-entry-and-hide t]
@@ -394,7 +393,7 @@ Press `?' for a summary of important key bindings, or check 
the menu.
 Here are all local bindings.
 
 \\{reftex-index-mode-map}"
-  (set (make-local-variable 'revert-buffer-function) 'reftex-index-revert)
+  (set (make-local-variable 'revert-buffer-function) #'reftex-index-revert)
   (set (make-local-variable 'reftex-index-restriction-data) nil)
   (set (make-local-variable 'reftex-index-restriction-indicator) nil)
   (setq mode-line-format
@@ -403,15 +402,9 @@ Here are all local bindings.
               "  R<" 'reftex-index-restriction-indicator ">"
               " -%-"))
   (setq truncate-lines t)
-  (when (featurep 'xemacs)
-    ;; XEmacs needs the call to make-local-hook
-    (make-local-hook 'post-command-hook)
-    (make-local-hook 'pre-command-hook))
   (make-local-variable 'reftex-last-follow-point)
-  (when (featurep 'xemacs)
-    (easy-menu-add reftex-index-menu reftex-index-mode-map))
-  (add-hook 'post-command-hook 'reftex-index-post-command-hook nil t)
-  (add-hook 'pre-command-hook  'reftex-index-pre-command-hook nil t))
+  (add-hook 'post-command-hook #'reftex-index-post-command-hook nil t)
+  (add-hook 'pre-command-hook  #'reftex-index-pre-command-hook nil t))
 
 (defconst reftex-index-help
 "                      AVAILABLE KEYS IN INDEX BUFFER
@@ -450,7 +443,7 @@ _ ^        Add/Remove parent key (to make this item a 
subitem).
          (match
           (cond
            ((or (not no-revisit)
-                (reftex-get-buffer-visiting file))
+                (find-buffer-visiting file))
             (switch-to-buffer-other-window
              (reftex-get-file-buffer-force file nil))
             (goto-char (or pos (point-min)))
@@ -567,7 +560,7 @@ SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan 
[f]ollow [?]Help
       (run-hooks 'reftex-display-copied-context-hook)
       (message "Building %s buffer...done." buffer-name)
       (setq buffer-read-only t))
-    (and locations (apply 'reftex-find-start-point (point) locations))
+    (and locations (apply #'reftex-find-start-point (point) locations))
     (if reftex-index-restriction-indicator
         (message "Index restricted: <%s>" 
reftex-index-restriction-indicator))))
 
@@ -582,7 +575,7 @@ SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan 
[f]ollow [?]Help
          (indent "   ")
          (context reftex-index-include-context)
          (context-indent (concat indent "  "))
-         (section-chars (mapcar 'identity reftex-index-section-letters))
+         (section-chars (mapcar #'identity reftex-index-section-letters))
          (this-section-char 0)
          (font (reftex-use-fonts))
          (bor (car reftex-index-restriction-data))
@@ -733,9 +726,9 @@ SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan 
[f]ollow [?]Help
   (if reftex-index-follow-mode
       (setq reftex-index-follow-mode 1)))
 
-(defun reftex-index-next (&optional arg)
+(defun reftex-index-next (&optional _arg)
   "Move to next selectable item."
-  (interactive "p")
+  (interactive "^")
   (setq reftex-callback-fwd t)
   (or (eobp) (forward-char 1))
   (goto-char (or (next-single-property-change (point) :data)
@@ -743,9 +736,9 @@ SPC=view TAB=goto RET=goto+hide [e]dit [q]uit [r]escan 
[f]ollow [?]Help
   (unless (get-text-property (point) :data)
     (goto-char (or (next-single-property-change (point) :data)
                    (point)))))
-(defun reftex-index-previous (&optional arg)
+(defun reftex-index-previous (&optional _arg)
   "Move to previous selectable item."
-  (interactive "p")
+  (interactive "^")
   (setq reftex-callback-fwd nil)
   (goto-char (or (previous-single-property-change (point) :data)
                  (point)))
@@ -793,7 +786,7 @@ Label context is only displayed when the labels are there 
as well."
   (or (one-window-p) (delete-window))
   (switch-to-buffer (marker-buffer reftex-index-return-marker))
   (goto-char (or (marker-position reftex-index-return-marker) (point))))
-(defun reftex-index-goto-toc (&rest ignore)
+(defun reftex-index-goto-toc (&rest _ignore)
   "Switch to the table of contents of the current document.
 The function will go to the section where the entry at point was defined."
   (interactive)
@@ -802,7 +795,7 @@ The function will go to the section where the entry at 
point was defined."
     (switch-to-buffer (marker-buffer reftex-index-return-marker)))
   (delete-other-windows)
   (reftex-toc))
-(defun reftex-index-rescan (&rest ignore)
+(defun reftex-index-rescan (&rest _ignore)
   "Regenerate the *Index* buffer after reparsing file of section at point."
   (interactive)
   (let ((index-tag reftex-index-tag))
@@ -818,7 +811,7 @@ The function will go to the section where the entry at 
point was defined."
             (reftex-display-index index-tag nil 'redo line)))
       (reftex-index-Rescan))
     (reftex-kill-temporary-buffers)))
-(defun reftex-index-Rescan (&rest ignore)
+(defun reftex-index-Rescan (&rest _ignore)
   "Regenerate the *Index* buffer after reparsing the entire document."
   (interactive)
   (let ((index-tag reftex-index-tag)
@@ -827,7 +820,7 @@ The function will go to the section where the entry at 
point was defined."
      (reftex-get-file-buffer-force reftex-last-index-file))
     (setq current-prefix-arg '(16))
     (reftex-display-index index-tag nil 'redo line)))
-(defun reftex-index-revert (&rest ignore)
+(defun reftex-index-revert (&rest _ignore)
   "Regenerate the *Index* from the internal lists.  No reparsing os done."
   (interactive)
   (let ((buf (current-buffer))
@@ -840,7 +833,7 @@ The function will go to the section where the entry at 
point was defined."
     (setq current-prefix-arg nil
           reftex-last-follow-point 1)
     (reftex-display-index index-tag nil 'redo data line)))
-(defun reftex-index-switch-index-tag (&rest ignore)
+(defun reftex-index-switch-index-tag (&rest _ignore)
   "Switch to a different index of the same document."
   (interactive)
   (switch-to-buffer
@@ -865,14 +858,14 @@ The function will go to the section where the entry at 
point was defined."
             reftex-index-restriction-indicator (nth 6 bor) )))
   (reftex-index-revert))
 
-(defun reftex-index-widen (&rest ignore)
+(defun reftex-index-widen (&rest _ignore)
   "Show the unrestricted index (all entries)."
   (interactive)
   (setq reftex-index-restriction-indicator nil
         reftex-index-restriction-data nil)
   (reftex-index-revert)
   (message "Index widened"))
-(defun reftex-index-restriction-forward (&rest ignore)
+(defun reftex-index-restriction-forward (&rest _ignore)
   "Restrict to previous section.
 When index is currently unrestricted, restrict it to a section.
 When index is restricted, select the next section as restriction criterion."
@@ -888,7 +881,7 @@ When index is restricted, select the next section as 
restriction criterion."
                   (car (memq (assq 'toc (cdr (memq bor docstruct)))
                              docstruct))))
       (reftex-index-revert))))
-(defun reftex-index-restriction-backward (&rest ignore)
+(defun reftex-index-restriction-backward (&rest _ignore)
   "Restrict to next section.
 When index is currently unrestricted, restrict it to a section.
 When index is restricted, select the previous section as restriction 
criterion."
@@ -986,7 +979,7 @@ When index is restricted, select the previous section as 
restriction criterion."
     (setq analyze (reftex-index-analyze-entry data)
           attr (nth 2 analyze))
     (setf (nth 2 analyze) (if (string= attr bor) "" bor))
-    (setq new (apply 'concat analyze))
+    (setq new (apply #'concat analyze))
     (reftex-index-change-entry
      new (if (string= (nth 2 analyze) bor)
              "Entry is now START-OF-PAGE-RANGE"
@@ -1002,7 +995,7 @@ When index is restricted, select the previous section as 
restriction criterion."
     (setq analyze (reftex-index-analyze-entry data)
           attr (nth 2 analyze))
     (setf (nth 2 analyze) (if (string= attr eor) "" eor))
-    (setq new (apply 'concat analyze))
+    (setq new (apply #'concat analyze))
     (reftex-index-change-entry
      new (if (string= (nth 2 analyze) eor)
              "Entry is now END-OF-PAGE-RANGE"
@@ -1043,7 +1036,7 @@ When index is restricted, select the previous section as 
restriction criterion."
                (error "Invalid value")
              (setf (nth n analyze) npart)))
           (t (setf (nth n analyze) (concat initial npart))))
-    (setq new (apply 'concat analyze))
+    (setq new (apply #'concat analyze))
     ;; Change the entry and insert the changed version into the index.
     (reftex-index-change-entry
      new (if (string= npart "")
@@ -1180,27 +1173,50 @@ This gets refreshed in every phrases command.")
 (defvar reftex-index-phrases-files nil
   "List of document files relevant for the phrases file.")
 
-(defvar reftex-index-phrases-font-lock-keywords nil
-  "Font lock keywords for reftex-index-phrases-mode.")
-(defvar reftex-index-phrases-font-lock-defaults nil
-  "Font lock defaults for reftex-index-phrases-mode.")
+(defvar reftex-index-phrases-font-lock-keywords
+  (list
+   (cons reftex-index-phrases-comment-regexp 'font-lock-comment-face)
+   (list reftex-index-phrases-macrodef-regexp
+         '(1 font-lock-type-face)
+         '(2 font-lock-keyword-face)
+         '(3 'secondary-selection)
+         '(4 font-lock-function-name-face)
+         '(5 'secondary-selection)
+         '(6 font-lock-string-face))
+   (list reftex-index-phrases-phrase-regexp1
+         '(1 font-lock-keyword-face)
+         '(2 'secondary-selection)
+         '(3 font-lock-string-face)
+         '(4 'secondary-selection))
+   (list reftex-index-phrases-phrase-regexp2
+         '(1 font-lock-keyword-face)
+         '(2 'secondary-selection)
+         '(3 font-lock-string-face)
+         '(4 'secondary-selection)
+         '(5 font-lock-function-name-face))
+   '("^\t$" . 'secondary-selection))
+  "Font lock keywords for `reftex-index-phrases-mode'.")
+(defvar reftex-index-phrases-font-lock-defaults
+  '((reftex-index-phrases-font-lock-keywords)
+    nil t nil beginning-of-line)
+  "Font lock defaults for `reftex-index-phrases-mode'.")
 (define-obsolete-variable-alias
   'reftex-index-phrases-map 'reftex-index-phrases-mode-map "24.1")
 (defvar reftex-index-phrases-mode-map
   (let ((map (make-sparse-keymap)))
     ;; Keybindings and Menu for phrases buffer
-    (define-key map "\C-c\C-c" 'reftex-index-phrases-save-and-return)
-    (define-key map "\C-c\C-x" 'reftex-index-this-phrase)
-    (define-key map "\C-c\C-f" 'reftex-index-next-phrase)
-    (define-key map "\C-c\C-r" 'reftex-index-region-phrases)
-    (define-key map "\C-c\C-a" 'reftex-index-all-phrases)
-    (define-key map "\C-c\C-d" 'reftex-index-remaining-phrases)
-    (define-key map "\C-c\C-s" 'reftex-index-sort-phrases)
-    (define-key map "\C-c\C-n" 'reftex-index-new-phrase)
-    (define-key map "\C-c\C-m" 'reftex-index-phrases-set-macro-key)
-    (define-key map "\C-c\C-i" 'reftex-index-phrases-info)
-    (define-key map "\C-c\C-t" 'reftex-index-find-next-conflict-phrase)
-    (define-key map "\C-i" 'self-insert-command)
+    (define-key map "\C-c\C-c" #'reftex-index-phrases-save-and-return)
+    (define-key map "\C-c\C-x" #'reftex-index-this-phrase)
+    (define-key map "\C-c\C-f" #'reftex-index-next-phrase)
+    (define-key map "\C-c\C-r" #'reftex-index-region-phrases)
+    (define-key map "\C-c\C-a" #'reftex-index-all-phrases)
+    (define-key map "\C-c\C-d" #'reftex-index-remaining-phrases)
+    (define-key map "\C-c\C-s" #'reftex-index-sort-phrases)
+    (define-key map "\C-c\C-n" #'reftex-index-new-phrase)
+    (define-key map "\C-c\C-m" #'reftex-index-phrases-set-macro-key)
+    (define-key map "\C-c\C-i" #'reftex-index-phrases-info)
+    (define-key map "\C-c\C-t" #'reftex-index-find-next-conflict-phrase)
+    (define-key map "\C-i" #'self-insert-command)
 
     (easy-menu-define reftex-index-phrases-menu map
       "Menu for Phrases buffer"
@@ -1295,7 +1311,7 @@ If the buffer is non-empty, delete the old header first."
                                       reftex-key-to-index-macro-alist)))
          (macro-alist
           (sort (copy-sequence reftex-index-macro-alist)
-                (lambda (a b) (equal (car a) default-macro))))
+                (lambda (a _b) (equal (car a) default-macro))))
          macro entry key repeat)
 
     (if master (set (make-local-variable 'TeX-master)
@@ -1311,9 +1327,7 @@ If the buffer is non-empty, delete the old header first."
           (beginning-of-line 2))
       (while (looking-at "^[ \t]*$")
           (beginning-of-line 2))
-      (if (featurep 'xemacs)
-         (zmacs-activate-region)
-       (setq mark-active t))
+      (activate-mark)
       (if (yes-or-no-p "Delete and rebuild header? ")
           (delete-region (point-min) (point))))
 
@@ -1336,7 +1350,6 @@ If the buffer is non-empty, delete the old header first."
                       (if repeat "t" "nil"))))
     (insert 
"%---------------------------------------------------------------------\n\n\n")))
 
-(defvar TeX-master)
 (defun reftex-index-phrase-tex-master (&optional dir)
   "Return the name of the master file associated with a phrase buffer."
   (if (and (boundp 'TeX-master)
@@ -1387,41 +1400,8 @@ Here are all local bindings.
   :syntax-table reftex-index-phrases-syntax-table
   (set (make-local-variable 'font-lock-defaults)
        reftex-index-phrases-font-lock-defaults)
-  (when (featurep 'xemacs)
-    (easy-menu-add reftex-index-phrases-menu reftex-index-phrases-mode-map))
   (set (make-local-variable 'reftex-index-phrases-marker) (make-marker)))
-;; (add-hook 'reftex-index-phrases-mode-hook 'turn-on-font-lock)
-
-;; Font Locking stuff
-(let ((ss (if (featurep 'xemacs) 'secondary-selection ''secondary-selection)))
-  (setq reftex-index-phrases-font-lock-keywords
-        (list
-         (cons reftex-index-phrases-comment-regexp 'font-lock-comment-face)
-         (list reftex-index-phrases-macrodef-regexp
-               '(1 font-lock-type-face)
-               '(2 font-lock-keyword-face)
-               (list 3 ss)
-               '(4 font-lock-function-name-face)
-               (list 5 ss)
-               '(6 font-lock-string-face))
-         (list reftex-index-phrases-phrase-regexp1
-               '(1 font-lock-keyword-face)
-               (list 2 ss)
-               '(3 font-lock-string-face)
-               (list 4 ss))
-         (list reftex-index-phrases-phrase-regexp2
-               '(1 font-lock-keyword-face)
-               (list 2 ss)
-               '(3 font-lock-string-face)
-               (list 4 ss)
-               '(5 font-lock-function-name-face))
-         (cons "^\t$" ss)))
-  (setq reftex-index-phrases-font-lock-defaults
-        '((reftex-index-phrases-font-lock-keywords)
-          nil t nil beginning-of-line))
-  (put 'reftex-index-phrases-mode 'font-lock-defaults
-       reftex-index-phrases-font-lock-defaults) ; XEmacs
-  )
+;; (add-hook 'reftex-index-phrases-mode-hook #'turn-on-font-lock)
 
 (defun reftex-index-next-phrase (&optional arg)
   "Index the next ARG phrases in the phrases buffer."
@@ -1561,9 +1541,7 @@ index the new part without having to go over the 
unchanged parts again."
       (unwind-protect
           (progn
             ;; Hide the region highlighting
-            (if (featurep 'xemacs)
-               (zmacs-deactivate-region)
-             (deactivate-mark))
+           (deactivate-mark)
             (delete-other-windows)
             (reftex-index-visit-phrases-buffer)
             (reftex-index-all-phrases))
@@ -1593,7 +1571,7 @@ index the new part without having to go over the 
unchanged parts again."
   (if (and text (stringp text))
       (insert text)))
 
-(defun reftex-index-find-next-conflict-phrase (&optional arg)
+(defun reftex-index-find-next-conflict-phrase (&optional _arg)
   "Find the next a phrase which is has conflicts in the phrase buffer.
 The command helps to find possible conflicts in the phrase indexing process.
 It searches downward from point for a phrase which is repeated elsewhere
@@ -1601,7 +1579,7 @@ in the buffer, or which is a subphrase of another phrase. 
 If such a
 phrase is found, the phrase info is displayed.
 To check the whole buffer, start at the beginning and continue by calling
 this function repeatedly."
-  (interactive "P")
+  (interactive)
   (if (catch 'exit
         (while (re-search-forward reftex-index-phrases-phrase-regexp12 nil t)
           (goto-char (match-beginning 3))
@@ -1743,6 +1721,8 @@ information about the currently selected macro."
                      (if repeat "with" "without")))
         (error "Abort")))))
 
+(defvar reftex--chars-first)
+
 (defun reftex-index-sort-phrases (&optional chars-first)
   "Sort the phrases lines in the buffer alphabetically.
 Normally, this looks only at the phrases.  With a prefix arg CHARS-FIRST,
@@ -1762,19 +1742,18 @@ it first compares the macro identifying chars and then 
the phrases."
     (if end (setq end (progn (goto-char end) (end-of-line) (point))))
     ;; Take the lines, sort them and re-insert.
     (if (and beg end)
-        (progn
+        (let ((reftex--chars-first chars-first))
           (message "Sorting lines...")
           (let* ((lines (split-string (buffer-substring beg end) "\n"))
-                 (lines1 (sort lines 'reftex-compare-phrase-lines)))
+                 (lines1 (sort lines #'reftex-compare-phrase-lines)))
             (message "Sorting lines...done")
             (let ((inhibit-quit t))  ;; make sure we do not lose lines
               (delete-region beg end)
-              (insert (mapconcat 'identity lines1 "\n"))))
+              (insert (mapconcat #'identity lines1 "\n"))))
           (goto-char (point-max))
           (re-search-backward (concat "^" (regexp-quote line) "$") nil t))
       (error "Cannot find phrases lines to sort"))))
 
-(defvar chars-first)
 (defun reftex-compare-phrase-lines (a b)
   "The comparison function used for sorting."
   (let (ca cb pa pb c-p p-p)
@@ -1798,7 +1777,7 @@ it first compares the macro identifying chars and then 
the phrases."
                       p-p (string< pa pb))
                 ;; Do the right comparison, based on the value of `chars-first'
                 ;; `chars-first' is bound locally in the calling function
-                (if chars-first
+                (if reftex--chars-first
                     (if (string= ca cb) p-p c-p)
                   (if (string= pa pb) c-p p-p)))))
       ;; If line a does not match, the answer we return determines
@@ -1830,14 +1809,14 @@ With optional arg ALLOW-NEWLINE, allow single newline 
between words."
 
 (defun reftex-index-simplify-phrase (phrase)
   "Make phrase single spaces and single line."
-  (mapconcat 'identity (split-string phrase) " "))
+  (mapconcat #'identity (split-string phrase) " "))
 
 (defun reftex-index-phrases-find-dup-re (phrase &optional sub)
   "Return a regexp which matches variations of PHRASE (with additional space).
 When SUB ins non-nil, the regexp will also match when PHRASE is a subphrase
 of another phrase.  The regexp works lonly in the phrase buffer."
   (concat (if sub "^\\S-?\t\\([^\t\n]*" "^\\S-?\t")
-          (mapconcat 'regexp-quote (split-string phrase) " +")
+          (mapconcat #'regexp-quote (split-string phrase) " +")
           (if sub "[^\t\n]*\\)\\([\t\n]\\|$\\)" " *\\([\t\n]\\|$\\)")))
 
 (defun reftex-index-make-replace-string (macro-fmt match index-key
@@ -1870,7 +1849,7 @@ Treats the logical `and' for index phrases."
                   (unless (stringp reftex-index-phrases-restrict-file)
                     (widen))
                   (goto-char (point-min))
-                  (apply 'reftex-query-index-phrase args))))))
+                  (apply #'reftex-query-index-phrase args))))))
       (reftex-unhighlight 0)
       (set-window-configuration win-conf))))
 
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el
index 98c61f5..0157f84 100644
--- a/lisp/textmodes/reftex-parse.el
+++ b/lisp/textmodes/reftex-parse.el
@@ -1,4 +1,4 @@
-;;; reftex-parse.el --- parser functions for RefTeX
+;;; reftex-parse.el --- parser functions for RefTeX  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
 
@@ -143,7 +143,7 @@ When allowed, do only a partial scan from FILE."
                       (car (push (list 'is-multi is-multi) docstruct)))))
       (setcdr entry (cons is-multi nil)))
     (and reftex--index-tags
-         (setq reftex--index-tags (sort reftex--index-tags 'string<)))
+         (setq reftex--index-tags (sort reftex--index-tags #'string<)))
     (let ((index-tag-cell (assq 'index-tags docstruct)))
       (if index-tag-cell
           (setcdr index-tag-cell reftex--index-tags)
@@ -160,10 +160,10 @@ When allowed, do only a partial scan from FILE."
                          nil))
                      allxr))
              (alist (delq nil alist))
-             (allprefix (delq nil (mapcar 'car alist)))
+             (allprefix (delq nil (mapcar #'car alist)))
              (regexp (if allprefix
                          (concat "\\`\\("
-                                 (mapconcat 'identity allprefix "\\|")
+                                 (mapconcat #'identity allprefix "\\|")
                                  "\\)")
                        "\\\\\\\\\\\\")))   ; this will never match
         (push (list 'xr alist regexp) docstruct)))
@@ -209,7 +209,7 @@ of master file."
     (catch 'exit
       (setq file-found (reftex-locate-file file "tex" master-dir))
       (if (and (not file-found)
-               (setq buf (reftex-get-buffer-visiting file)))
+               (setq buf (find-buffer-visiting file)))
           (setq file-found (buffer-file-name buf)))
 
       (unless file-found
@@ -384,8 +384,9 @@ of master file."
                     (concat
                      ;;           "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
                      "\\(^\\)[^%\n\r]*\\\\\\("
-                     (mapconcat 'identity reftex-bibliography-commands "\\|")
-                     "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)") nil t))
+                     (mapconcat #'identity reftex-bibliography-commands "\\|")
+                     "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)")
+                    nil t))
          (setq files
                (append files
                        (split-string (reftex-match-string 4)
@@ -532,7 +533,7 @@ Careful: This function expects the match-data to be still 
in place!"
 
            (key (if prefix (concat prefix rawkey) rawkey))
            (sortkey (downcase key))
-           (showkey (mapconcat 'identity
+           (showkey (mapconcat #'identity
                                (split-string key reftex-index-level-re)
                                " ! ")))
       (goto-char end-of-args)
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index 439c02f..611102e 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -1,4 +1,4 @@
-;;; reftex-ref.el --- code to create labels and references with RefTeX
+;;; reftex-ref.el --- code to create labels and references with RefTeX  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
 
@@ -84,10 +84,12 @@ If optional BOUND is an integer, limit backward searches to 
that point."
 
           (if (or (re-search-forward
                    (format reftex-find-label-regexp-format
-                           (regexp-quote label)) nil t)
+                           (regexp-quote label))
+                   nil t)
                   (re-search-forward
                    (format reftex-find-label-regexp-format2
-                           (regexp-quote label)) nil t))
+                           (regexp-quote label))
+                   nil t))
 
               (progn
                 (backward-char 1)
@@ -248,13 +250,13 @@ This function is controlled by the settings of 
reftex-insert-label-flags."
                        ""
                      "POSITION UNCERTAIN.  RESCAN TO FIX."))
              (file (buffer-file-name))
-             (text nil)
+             ;; (text nil)
              (tail (memq here-I-am (symbol-value reftex-docstruct-symbol))))
 
         (or (cdr here-I-am-info) (setq rescan-is-useful t))
 
         (when tail
-          (push (list label typekey text file nil note) (cdr tail))
+          (push (list label typekey nil file nil note) (cdr tail))
           (put reftex-docstruct-symbol 'modified t)))
 
       ;; Insert the label into the buffer
@@ -286,7 +288,7 @@ also applies `reftex-translate-to-ascii-function' to the 
string."
   (when (and reftex-translate-to-ascii-function
              (fboundp reftex-translate-to-ascii-function))
     (setq string (funcall reftex-translate-to-ascii-function string)))
-  (apply 'reftex-convert-string string
+  (apply #'reftex-convert-string string
          "[-~ \t\n\r,;]+" reftex-label-illegal-re nil nil
          reftex-derive-label-parameters))
 
@@ -402,6 +404,8 @@ also applies `reftex-translate-to-ascii-function' to the 
string."
  a / A      Put all marked entries into one/many \\ref commands.
  q / RET    Quit without referencing / Accept current label (also on 
mouse-2).")
 
+(defvar reftex-refstyle)
+
 ;;;###autoload
 (defun reftex-reference (&optional type no-insert cut)
   "Make a LaTeX reference.  Look only for labels of a certain TYPE.
@@ -473,7 +477,7 @@ When called with 2 C-u prefix args, disable magic word 
recognition."
     ;; If the first entry is the symbol 'concat, concat all labels.
     ;; We keep the cdr of the first label for typekey etc information.
     (if (eq (car labels) 'concat)
-        (setq labels (list (list (mapconcat 'car (cdr labels) ",")
+        (setq labels (list (list (mapconcat #'car (cdr labels) ",")
                                  (cdr (nth 1 labels))))))
     (setq type (nth 1 (car labels))
           form (or (cdr (assoc type reftex-typekey-to-format-alist))
@@ -502,7 +506,7 @@ When called with 2 C-u prefix args, disable magic word 
recognition."
           (setq form (substring form 1)))
         ;; do we have a special format?
        (unless (string= reftex-refstyle "\\ref")
-         (setq reftex-format-ref-function 'reftex-format-special))
+         (setq reftex-format-ref-function #'reftex-format-special))
         ;; ok, insert the reference
         (if sep1 (insert sep1))
         (insert
@@ -744,7 +748,7 @@ When called with 2 C-u prefix args, disable magic word 
recognition."
       ;; Goto the file in another window
       (setq buffer
             (if no-revisit
-                (reftex-get-buffer-visiting file)
+                (find-buffer-visiting file)
               (reftex-get-file-buffer-force
                file (not reftex-keep-temporary-buffers))))
       (if buffer
@@ -826,14 +830,16 @@ When called with 2 C-u prefix args, disable magic word 
recognition."
     (dolist (item (nth 2 elt))
       (let ((macro (car item))
            (package (nth 1 elt)))
-       (eval `(defun ,(intern (format "reftex-%s-%s" package
-                                      (substring macro 1 (length macro)))) ()
-                ,(format "Insert a reference using the `%s' macro from the %s \
+       (defalias (intern (format "reftex-%s-%s" package
+                                 (substring macro 1 (length macro))))
+         (lambda ()
+           (:documentation
+            (format "Insert a reference using the `%s' macro from the %s \
 package.\n\nThis is a generated function."
-                         macro package)
-                (interactive)
-                (let ((reftex-refstyle ,macro))
-                  (reftex-reference))))))))
+                    macro package))
+           (interactive)
+           (let ((reftex-refstyle macro))
+             (reftex-reference))))))))
 
 (defun reftex-format-special (label fmt refstyle)
   "Apply selected reference style to format FMT and add LABEL.
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el
index d2e9974..b0a8ebf 100644
--- a/lisp/textmodes/reftex-sel.el
+++ b/lisp/textmodes/reftex-sel.el
@@ -1,4 +1,4 @@
-;;; reftex-sel.el --- the selection modes for RefTeX
+;;; reftex-sel.el --- the selection modes for RefTeX  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 1997-2021 Free Software Foundation, Inc.
 
@@ -34,31 +34,29 @@
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map special-mode-map)
     (substitute-key-definition
-     'next-line 'reftex-select-next                      map global-map)
+     #'next-line #'reftex-select-next                      map global-map)
     (substitute-key-definition
-     'previous-line 'reftex-select-previous              map global-map)
+     #'previous-line #'reftex-select-previous              map global-map)
     (substitute-key-definition
-     'keyboard-quit 'reftex-select-keyboard-quit         map global-map)
+     #'keyboard-quit #'reftex-select-keyboard-quit         map global-map)
     (substitute-key-definition
-     'newline 'reftex-select-accept                      map global-map)
-
-    (define-key map " " 'reftex-select-callback)
-    (define-key map "n" 'reftex-select-next)
-    (define-key map [(down)] 'reftex-select-next)
-    (define-key map "p" 'reftex-select-previous)
-    (define-key map [(up)] 'reftex-select-previous)
-    (define-key map "f" 'reftex-select-toggle-follow)
-    (define-key map "\C-m" 'reftex-select-accept)
-    (define-key map [(return)] 'reftex-select-accept)
-    (define-key map "q" 'reftex-select-quit)
-    (define-key map "." 'reftex-select-show-insertion-point)
-    (define-key map "?" 'reftex-select-help)
+     #'newline #'reftex-select-accept                      map global-map)
+
+    (define-key map " " #'reftex-select-callback)
+    (define-key map "n" #'reftex-select-next)
+    (define-key map [(down)] #'reftex-select-next)
+    (define-key map "p" #'reftex-select-previous)
+    (define-key map [(up)] #'reftex-select-previous)
+    (define-key map "f" #'reftex-select-toggle-follow)
+    (define-key map "\C-m" #'reftex-select-accept)
+    (define-key map [(return)] #'reftex-select-accept)
+    (define-key map "q" #'reftex-select-quit)
+    (define-key map "." #'reftex-select-show-insertion-point)
+    (define-key map "?" #'reftex-select-help)
 
     ;; The mouse-2 binding
-    (if (featurep 'xemacs)
-        (define-key map [(button2)] 'reftex-select-mouse-accept)
-      (define-key map [(mouse-2)] 'reftex-select-mouse-accept)
-      (define-key map [follow-link] 'mouse-face))
+    (define-key map [(mouse-2)] #'reftex-select-mouse-accept)
+    (define-key map [follow-link] 'mouse-face)
     map))
 
 (define-obsolete-variable-alias
@@ -67,25 +65,26 @@
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map reftex-select-shared-map)
 
-    (cl-loop for key across "aAcgFlrRstx#%" do
-             (define-key map (vector (list key))
-               (list 'lambda '()
-                     "Press `?' during selection to find out about this key."
-                     '(interactive) (list 'throw '(quote myexit) key))))
-
-    (define-key map "b" 'reftex-select-jump-to-previous)
-    (define-key map "z" 'reftex-select-jump)
-    (define-key map "v" 'reftex-select-cycle-ref-style-forward)
-    (define-key map "V" 'reftex-select-cycle-ref-style-backward)
-    (define-key map "m" 'reftex-select-mark)
-    (define-key map "u" 'reftex-select-unmark)
-    (define-key map "," 'reftex-select-mark-comma)
-    (define-key map "-" 'reftex-select-mark-to)
-    (define-key map "+" 'reftex-select-mark-and)
-    (define-key map [(tab)] 'reftex-select-read-label)
-    (define-key map "\C-i" 'reftex-select-read-label)
-    (define-key map "\C-c\C-n" 'reftex-select-next-heading)
-    (define-key map "\C-c\C-p" 'reftex-select-previous-heading)
+    (mapc (lambda (key)
+            (define-key map (vector (list key))
+              (lambda ()
+                "Press `?' during selection to find out about this key."
+                (interactive) (throw 'myexit key))))
+          "aAcgFlrRstx#%")
+
+    (define-key map "b" #'reftex-select-jump-to-previous)
+    (define-key map "z" #'reftex-select-jump)
+    (define-key map "v" #'reftex-select-cycle-ref-style-forward)
+    (define-key map "V" #'reftex-select-cycle-ref-style-backward)
+    (define-key map "m" #'reftex-select-mark)
+    (define-key map "u" #'reftex-select-unmark)
+    (define-key map "," #'reftex-select-mark-comma)
+    (define-key map "-" #'reftex-select-mark-to)
+    (define-key map "+" #'reftex-select-mark-and)
+    (define-key map [(tab)] #'reftex-select-read-label)
+    (define-key map "\C-i" #'reftex-select-read-label)
+    (define-key map "\C-c\C-n" #'reftex-select-next-heading)
+    (define-key map "\C-c\C-p" #'reftex-select-previous-heading)
 
     map)
   "Keymap used for *RefTeX Select* buffer, when selecting a label.
@@ -104,10 +103,6 @@ Press `?' for a summary of important key bindings.
 During a selection process, these are the local bindings.
 
 \\{reftex-select-label-mode-map}"
-  (when (featurep 'xemacs)
-    ;; XEmacs needs the call to make-local-hook
-    (make-local-hook 'pre-command-hook)
-    (make-local-hook 'post-command-hook))
   (set (make-local-variable 'reftex-select-marked) nil)
   (when (syntax-table-p reftex-latex-syntax-table)
     (set-syntax-table reftex-latex-syntax-table))
@@ -120,16 +115,17 @@ During a selection process, these are the local bindings.
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map reftex-select-shared-map)
 
-    (cl-loop for key across "grRaAeE" do
-             (define-key map (vector (list key))
-               (list 'lambda '()
-                     "Press `?' during selection to find out about this key."
-                     '(interactive) (list 'throw '(quote myexit) key))))
+    (mapc (lambda (key)
+            (define-key map (vector (list key))
+              (lambda ()
+                "Press `?' during selection to find out about this key."
+                (interactive) (throw 'myexit key))))
+          "grRaAeE")
 
-    (define-key map "\C-i" 'reftex-select-read-cite)
-    (define-key map [(tab)] 'reftex-select-read-cite)
-    (define-key map "m" 'reftex-select-mark)
-    (define-key map "u" 'reftex-select-unmark)
+    (define-key map "\C-i" #'reftex-select-read-cite)
+    (define-key map [(tab)] #'reftex-select-read-cite)
+    (define-key map "m" #'reftex-select-mark)
+    (define-key map "u" #'reftex-select-unmark)
 
     map)
   "Keymap used for *RefTeX Select* buffer, when selecting a BibTeX entry.
@@ -148,10 +144,6 @@ Press `?' for a summary of important key bindings.
 During a selection process, these are the local bindings.
 
 \\{reftex-select-label-mode-map}"
-  (when (featurep 'xemacs)
-    ;; XEmacs needs the call to make-local-hook
-    (make-local-hook 'pre-command-hook)
-    (make-local-hook 'post-command-hook))
   (set (make-local-variable 'reftex-select-marked) nil)
   ;; We do not set a local map - reftex-select-item does this.
   )
@@ -432,12 +424,21 @@ During a selection process, these are the local bindings.
 (defvar reftex-last-data nil)
 (defvar reftex-last-line nil)
 (defvar reftex-select-marked nil)
+(defvar reftex-refstyle)
+
+;; The following variables are all bound dynamically in `reftex-select-item'.
+
+(defvar reftex-select-data)
+(defvar reftex-select-prompt)
+(defvar reftex--cb-flag)
+(defvar reftex--last-data)
+(defvar reftex--call-back)
+(defvar reftex--help-string)
 
 ;;;###autoload
-(defun reftex-select-item (reftex-select-prompt help-string keymap
-                                  &optional offset
-                                  call-back cb-flag)
-  ;; Select an item, using REFTEX-SELECT-PROMPT.
+(defun reftex-select-item ( prompt help-string keymap
+                            &optional offset call-back cb-flag)
+  ;; Select an item, using PROMPT.
   ;; The function returns a key indicating an exit status, along with a
   ;; data structure indicating which item was selected.
   ;; HELP-STRING contains help.  KEYMAP is a keymap with the available
@@ -448,7 +449,12 @@ During a selection process, these are the local bindings.
   ;; When CALL-BACK is given, it is a function which is called with the index
   ;; of the element.
   ;; CB-FLAG is the initial value of that flag.
-  (let (ev reftex-select-data last-data (selection-buffer (current-buffer)))
+  (let ((reftex-select-prompt prompt)
+        (reftex--help-string help-string)
+        (reftex--call-back call-back)
+        (reftex--cb-flag cb-flag)
+        ev reftex-select-data reftex--last-data
+        (selection-buffer (current-buffer)))
 
     (setq reftex-select-marked nil)
 
@@ -466,43 +472,29 @@ During a selection process, these are the local bindings.
       (unwind-protect
           (progn
             (use-local-map keymap)
-            (add-hook 'pre-command-hook 'reftex-select-pre-command-hook nil t)
-            (add-hook 'post-command-hook 'reftex-select-post-command-hook nil 
t)
+            (add-hook 'pre-command-hook #'reftex-select-pre-command-hook nil t)
+            (add-hook 'post-command-hook #'reftex-select-post-command-hook nil 
t)
             (princ reftex-select-prompt)
             (set-marker reftex-recursive-edit-marker (point))
-            ;; XEmacs does not run post-command-hook here
-            (and (featurep 'xemacs) (run-hooks 'post-command-hook))
             (recursive-edit))
 
         (set-marker reftex-recursive-edit-marker nil)
         (with-current-buffer selection-buffer
           (use-local-map nil)
-          (remove-hook 'pre-command-hook 'reftex-select-pre-command-hook t)
+          (remove-hook 'pre-command-hook #'reftex-select-pre-command-hook t)
           (remove-hook 'post-command-hook
-                       'reftex-select-post-command-hook t))
+                       #'reftex-select-post-command-hook t))
         ;; Kill the mark overlays
-        (mapc (lambda (c) (reftex-delete-overlay (nth 1 c)))
+        (mapc (lambda (c) (delete-overlay (nth 1 c)))
               reftex-select-marked)))))
 
     (set (make-local-variable 'reftex-last-line)
          (+ (count-lines (point-min) (point)) (if (bolp) 1 0)))
-    (set (make-local-variable 'reftex-last-data) last-data)
+    (set (make-local-variable 'reftex-last-data) reftex--last-data)
     (reftex-kill-buffer "*RefTeX Help*")
     (setq reftex-callback-fwd (not reftex-callback-fwd)) ;; ;-)))
     (message "")
-    (list ev reftex-select-data last-data)))
-
-;; The following variables are all bound dynamically in `reftex-select-item'.
-;; The defvars are here only to silence the byte compiler.
-
-(defvar found-list)
-(defvar cb-flag)
-(defvar reftex-select-data)
-(defvar reftex-select-prompt)
-(defvar last-data)
-(defvar call-back)
-(defvar help-string)
-(defvar reftex-refstyle)
+    (list ev reftex-select-data reftex--last-data)))
 
 ;; The selection commands
 
@@ -513,12 +505,12 @@ During a selection process, these are the local bindings.
 (defun reftex-select-post-command-hook ()
   (let (b e)
     (setq reftex-select-data (get-text-property (point) :data))
-    (setq last-data (or reftex-select-data last-data))
+    (setq reftex--last-data (or reftex-select-data reftex--last-data))
 
-    (when (and reftex-select-data cb-flag
+    (when (and reftex-select-data reftex--cb-flag
                (not (equal reftex-last-follow-point (point))))
       (setq reftex-last-follow-point (point))
-      (funcall call-back reftex-select-data reftex-callback-fwd
+      (funcall reftex--call-back reftex-select-data reftex-callback-fwd
                (not reftex-revisit-to-follow)))
     (if reftex-select-data
         (setq b (or (previous-single-property-change
@@ -594,7 +586,7 @@ Useful for large TOC's."
   "Toggle follow mode:  Other window follows with full context."
   (interactive)
   (setq reftex-last-follow-point -1)
-  (setq cb-flag (not cb-flag)))
+  (setq reftex--cb-flag (not reftex--cb-flag)))
 
 (defun reftex-select-cycle-ref-style-internal (&optional reverse)
   "Cycle through macros used for referencing.
@@ -632,7 +624,9 @@ Cycle in reverse order if optional argument REVERSE is 
non-nil."
 (defun reftex-select-callback ()
   "Show full context in another window."
   (interactive)
-  (if reftex-select-data (funcall call-back reftex-select-data 
reftex-callback-fwd nil) (ding)))
+  (if reftex-select-data
+      (funcall reftex--call-back reftex-select-data reftex-callback-fwd nil)
+    (ding)))
 (defun reftex-select-accept ()
   "Accept the currently selected item."
   (interactive)
@@ -642,7 +636,7 @@ Cycle in reverse order if optional argument REVERSE is 
non-nil."
   (interactive "e")
   (mouse-set-point ev)
   (setq reftex-select-data (get-text-property (point) :data))
-  (setq last-data (or reftex-select-data last-data))
+  (setq reftex--last-data (or reftex-select-data reftex--last-data))
   (throw 'myexit 'return))
 (defun reftex-select-read-label ()
   "Use minibuffer to read a label to reference, with completion."
@@ -652,16 +646,19 @@ Cycle in reverse order if optional argument REVERSE is 
non-nil."
                 nil nil reftex-prefix)))
     (unless (or (equal label "") (equal label reftex-prefix))
       (throw 'myexit label))))
+
+(defvar reftex--found-list)
+
 (defun reftex-select-read-cite ()
   "Use minibuffer to read a citation key with completion."
   (interactive)
-  (let* ((key (completing-read "Citation key: " found-list))
-         (entry (assoc key found-list)))
+  (let* ((key (completing-read "Citation key: " reftex--found-list))
+         (entry (assoc key reftex--found-list)))
     (cond
      ((or (null key) (equal key "")))
      (entry
       (setq reftex-select-data entry)
-      (setq last-data reftex-select-data)
+      (setq reftex--last-data reftex-select-data)
       (throw 'myexit 'return))
      (t (throw 'myexit key)))))
 
@@ -676,14 +673,14 @@ Cycle in reverse order if optional argument REVERSE is 
non-nil."
     (setq boe (or (previous-single-property-change (1+ (point)) :data)
                   (point-min))
           eoe (or (next-single-property-change (point) :data) (point-max)))
-    (setq ovl (reftex-make-overlay boe eoe))
+    (setq ovl (make-overlay boe eoe))
     (push (list data ovl separator) reftex-select-marked)
-    (reftex-overlay-put ovl 'font-lock-face reftex-select-mark-face)
-    (reftex-overlay-put ovl 'before-string
-                        (if separator
-                            (format "*%c%d* " separator
-                                    (length reftex-select-marked))
-                          (format "*%d*  " (length reftex-select-marked))))
+    (overlay-put ovl 'font-lock-face reftex-select-mark-face)
+    (overlay-put ovl 'before-string
+                 (if separator
+                     (format "*%c%d* " separator
+                             (length reftex-select-marked))
+                   (format "*%d*  " (length reftex-select-marked))))
     (message "Entry has mark no. %d" (length reftex-select-marked))))
 
 (defun reftex-select-mark-comma ()
@@ -709,15 +706,15 @@ Cycle in reverse order if optional argument REVERSE is 
non-nil."
          sep)
     (unless cell
       (error "No marked entry at point"))
-    (and ovl (reftex-delete-overlay ovl))
+    (and ovl (delete-overlay ovl))
     (setq reftex-select-marked (delq cell reftex-select-marked))
     (setq cnt (1+ (length reftex-select-marked)))
     (mapc (lambda (c)
             (setq sep (nth 2 c))
-            (reftex-overlay-put (nth 1 c) 'before-string
-                                (if sep
-                                    (format "*%c%d* " sep (cl-decf cnt))
-                                  (format "*%d*  " (cl-decf cnt)))))
+            (overlay-put (nth 1 c) 'before-string
+                         (if sep
+                             (format "*%c%d* " sep (cl-decf cnt))
+                           (format "*%d*  " (cl-decf cnt)))))
           reftex-select-marked)
     (message "Entry no longer marked")))
 
@@ -725,7 +722,7 @@ Cycle in reverse order if optional argument REVERSE is 
non-nil."
   "Display a summary of the special key bindings."
   (interactive)
   (with-output-to-temp-buffer "*RefTeX Help*"
-    (princ help-string))
+    (princ reftex--help-string))
   (reftex-enlarge-to-fit "*RefTeX Help*" t))
 
 (provide 'reftex-sel)
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index 3b9f970..b564349 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -1,4 +1,4 @@
-;;; reftex-toc.el --- RefTeX's table of contents mode
+;;; reftex-toc.el --- RefTeX's table of contents mode  -*- lexical-binding: t; 
-*-
 
 ;; Copyright (C) 1997-2000, 2003-2021 Free Software Foundation, Inc.
 
@@ -32,8 +32,7 @@
 (defvar reftex-toc-mode-map
   (let ((map (make-sparse-keymap)))
 
-    (define-key map (if (featurep 'xemacs) [(button2)] [(mouse-2)])
-      'reftex-toc-mouse-goto-line-and-hide)
+    (define-key map [(mouse-2)] #'reftex-toc-mouse-goto-line-and-hide)
     (define-key map [follow-link] 'mouse-face)
 
     (substitute-key-definition
@@ -41,34 +40,34 @@
     (substitute-key-definition
      'previous-line 'reftex-toc-previous map global-map)
 
-    (define-key map "n" 'reftex-toc-next)
-    (define-key map "p" 'reftex-toc-previous)
-    (define-key map "?" 'reftex-toc-show-help)
-    (define-key map " " 'reftex-toc-view-line)
-    (define-key map "\C-m" 'reftex-toc-goto-line-and-hide)
-    (define-key map "\C-i" 'reftex-toc-goto-line)
-    (define-key map "\C-c>" 'reftex-toc-display-index)
-    (define-key map "r" 'reftex-toc-rescan)
-    (define-key map "R" 'reftex-toc-Rescan)
-    (define-key map "q" 'reftex-toc-quit) ;
-    (define-key map "k" 'reftex-toc-quit-and-kill)
-    (define-key map "f" 'reftex-toc-toggle-follow) ;
-    (define-key map "a" 'reftex-toggle-auto-toc-recenter)
-    (define-key map "d" 'reftex-toc-toggle-dedicated-frame)
-    (define-key map "F" 'reftex-toc-toggle-file-boundary)
-    (define-key map "i" 'reftex-toc-toggle-index)
-    (define-key map "l" 'reftex-toc-toggle-labels)
-    (define-key map "t" 'reftex-toc-max-level)
-    (define-key map "c" 'reftex-toc-toggle-context)
-    ;; (define-key map "%" 'reftex-toc-toggle-commented)
-    (define-key map "\M-%" 'reftex-toc-rename-label)
-    (define-key map "x" 'reftex-toc-external)
-    (define-key map "z" 'reftex-toc-jump)
-    (define-key map "." 'reftex-toc-show-calling-point)
-    (define-key map "\C-c\C-n" 'reftex-toc-next-heading)
-    (define-key map "\C-c\C-p" 'reftex-toc-previous-heading)
-    (define-key map ">" 'reftex-toc-demote)
-    (define-key map "<" 'reftex-toc-promote)
+    (define-key map "n" #'reftex-toc-next)
+    (define-key map "p" #'reftex-toc-previous)
+    (define-key map "?" #'reftex-toc-show-help)
+    (define-key map " " #'reftex-toc-view-line)
+    (define-key map "\C-m" #'reftex-toc-goto-line-and-hide)
+    (define-key map "\C-i" #'reftex-toc-goto-line)
+    (define-key map "\C-c>" #'reftex-toc-display-index)
+    (define-key map "r" #'reftex-toc-rescan)
+    (define-key map "R" #'reftex-toc-Rescan)
+    (define-key map "q" #'reftex-toc-quit) ;
+    (define-key map "k" #'reftex-toc-quit-and-kill)
+    (define-key map "f" #'reftex-toc-toggle-follow) ;
+    (define-key map "a" #'reftex-toggle-auto-toc-recenter)
+    (define-key map "d" #'reftex-toc-toggle-dedicated-frame)
+    (define-key map "F" #'reftex-toc-toggle-file-boundary)
+    (define-key map "i" #'reftex-toc-toggle-index)
+    (define-key map "l" #'reftex-toc-toggle-labels)
+    (define-key map "t" #'reftex-toc-max-level)
+    (define-key map "c" #'reftex-toc-toggle-context)
+    ;; (define-key map "%" #'reftex-toc-toggle-commented)
+    (define-key map "\M-%" #'reftex-toc-rename-label)
+    (define-key map "x" #'reftex-toc-external)
+    (define-key map "z" #'reftex-toc-jump)
+    (define-key map "." #'reftex-toc-show-calling-point)
+    (define-key map "\C-c\C-n" #'reftex-toc-next-heading)
+    (define-key map "\C-c\C-p" #'reftex-toc-previous-heading)
+    (define-key map ">" #'reftex-toc-demote)
+    (define-key map "<" #'reftex-toc-promote)
 
     (easy-menu-define
       reftex-toc-menu map
@@ -130,9 +129,7 @@ Here are all local bindings.
 
 \\{reftex-toc-mode-map}"
   (set (make-local-variable 'transient-mark-mode) t)
-  (when (featurep 'xemacs)
-    (set (make-local-variable 'zmacs-regions) t))
-  (set (make-local-variable 'revert-buffer-function) 'reftex-toc-revert)
+  (set (make-local-variable 'revert-buffer-function) #'reftex-toc-revert)
   (set (make-local-variable 'reftex-toc-include-labels-indicator) "")
   (set (make-local-variable 'reftex-toc-max-level-indicator)
        (if (= reftex-toc-max-level 100)
@@ -146,15 +143,9 @@ Here are all local bindings.
               "  T<" 'reftex-toc-max-level-indicator ">"
               " -%-"))
   (setq truncate-lines t)
-  (when (featurep 'xemacs)
-    ;; XEmacs needs the call to make-local-hook
-    (make-local-hook 'post-command-hook)
-    (make-local-hook 'pre-command-hook))
   (make-local-variable 'reftex-last-follow-point)
-  (add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t)
-  (add-hook 'pre-command-hook  'reftex-toc-pre-command-hook nil t)
-  (when (featurep 'xemacs)
-    (easy-menu-add reftex-toc-menu reftex-toc-mode-map)))
+  (add-hook 'post-command-hook #'reftex-toc-post-command-hook nil t)
+  (add-hook 'pre-command-hook  #'reftex-toc-pre-command-hook nil t))
 
 (defvar reftex-last-toc-file nil
   "Stores the file name from which `reftex-toc' was called.  For redo 
command.")
@@ -420,7 +411,6 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels 
[f]ollow [x]r [?]Help
 (defun reftex-toc-next (&optional _arg)
   "Move to next selectable item."
   (interactive)
-  (when (featurep 'xemacs) (setq zmacs-region-stays t))
   (setq reftex-callback-fwd t)
   (or (eobp) (forward-char 1))
   (goto-char (or (next-single-property-change (point) :data)
@@ -428,21 +418,18 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels 
[f]ollow [x]r [?]Help
 (defun reftex-toc-previous (&optional _arg)
   "Move to previous selectable item."
   (interactive)
-  (when (featurep 'xemacs) (setq zmacs-region-stays t))
   (setq reftex-callback-fwd nil)
   (goto-char (or (previous-single-property-change (point) :data)
                  (point))))
 (defun reftex-toc-next-heading (&optional arg)
   "Move to next table of contents line."
   (interactive "p")
-  (when (featurep 'xemacs) (setq zmacs-region-stays t))
   (end-of-line)
   (re-search-forward "^ " nil t arg)
   (beginning-of-line))
 (defun reftex-toc-previous-heading (&optional arg)
   "Move to previous table of contents line."
   (interactive "p")
-  (when (featurep 'xemacs) (setq zmacs-region-stays t))
   (re-search-backward "^ " nil t arg))
 (defun reftex-toc-toggle-follow ()
   "Toggle follow (other window follows with context)."
@@ -662,7 +649,7 @@ point."
   (let* ((reftex--start-line (+ (count-lines (point-min) (point))
                                 (if (bolp) 1 0)))
         (reftex--mark-line
-          (if (reftex-region-active-p)
+          (if (region-active-p)
               (save-excursion (goto-char (mark))
                               (+ (count-lines (point-min) (point))
                                  (if (bolp) 1 0)))))
@@ -671,7 +658,7 @@ point."
          beg end entries data sections nsec msg)
     (setq msg
           (catch 'exit
-            (if (reftex-region-active-p)
+            (if (region-active-p)
                 ;; A region is dangerous, check if we have a brand new scan,
                 ;; to make sure we are not missing any section statements.
                 (if (not (reftex-toc-check-docstruct))
@@ -712,7 +699,7 @@ point."
                 nil              ; we have permission, do nothing
               (error "Abort"))   ; abort, we don't have permission
             ;; Do the changes
-            (mapc 'reftex-toc-promote-action entries)
+            (mapc #'reftex-toc-promote-action entries)
             ;; Rescan the document and rebuilt the toc buffer
             (save-window-excursion
               (reftex-toc-Rescan))
@@ -734,10 +721,8 @@ point."
       (forward-line (1- point-line)))
     (when mpos
       (set-mark mpos)
-      (if (featurep 'xemacs)
-          (zmacs-activate-region)
-        (setq mark-active t
-              deactivate-mark nil)))))
+      (setq mark-active t
+            deactivate-mark nil))))
 
 (defun reftex-toc-promote-prepare (x delta)
   "Look at a TOC entry and see if we could pro/demote it.
@@ -918,7 +903,7 @@ label prefix determines the wording of a reference."
       (setq match
             (let ((where (car toc))
                   (file (nth 1 toc)))
-              (if (or (not no-revisit) (reftex-get-buffer-visiting file))
+              (if (or (not no-revisit) (find-buffer-visiting file))
                   (progn
                     (switch-to-buffer-other-window
                      (reftex-get-file-buffer-force file nil))
@@ -981,7 +966,7 @@ label prefix determines the wording of a reference."
                                              reftex-section-levels-all)))
                                     "[[{]?"))))
            ((or (not no-revisit)
-                (reftex-get-buffer-visiting file))
+                (find-buffer-visiting file))
             ;; Marker is lost.  Use the backup method.
             (switch-to-buffer-other-window
              (reftex-get-file-buffer-force file nil))
@@ -1035,18 +1020,12 @@ section."
   (interactive)
   (if reftex-toc-auto-recenter-timer
       (progn
-        (if (featurep 'xemacs)
-            (delete-itimer reftex-toc-auto-recenter-timer)
-          (cancel-timer reftex-toc-auto-recenter-timer))
+        (cancel-timer reftex-toc-auto-recenter-timer)
         (setq reftex-toc-auto-recenter-timer nil)
         (message "Automatic recentering of TOC window was turned off"))
     (setq reftex-toc-auto-recenter-timer
-          (if (featurep 'xemacs)
-              (start-itimer "RefTeX Idle Timer for recenter"
-                            'reftex-recenter-toc-when-idle
-                            reftex-idle-time reftex-idle-time t)
-            (run-with-idle-timer
-             reftex-idle-time t 'reftex-recenter-toc-when-idle)))
+          (run-with-idle-timer
+           reftex-idle-time t #'reftex-recenter-toc-when-idle))
     (message "Automatic recentering of TOC window was turned on")))
 
 (defun reftex-toc-toggle-dedicated-frame ()
@@ -1090,15 +1069,12 @@ always show the current section in connection with the 
option
       (switch-to-buffer "*toc*")
       (select-frame current-frame)
       (cond ((fboundp 'x-focus-frame)
-             (x-focus-frame current-frame))
-            ((and (featurep 'xemacs) ; `focus-frame' is a nop in Emacs.
-                  (fboundp 'focus-frame))
-             (focus-frame current-frame)))
+             (x-focus-frame current-frame)))
       (select-window current-window)
       (when (eq reftex-auto-recenter-toc 'frame)
         (unless reftex-toc-auto-recenter-timer
           (reftex-toggle-auto-toc-recenter))
-        (add-hook 'delete-frame-functions 'reftex-toc-delete-frame-hook)))))
+        (add-hook 'delete-frame-functions #'reftex-toc-delete-frame-hook)))))
 
 (defun reftex-toc-delete-frame-hook (frame)
   (if (and reftex-toc-auto-recenter-timer
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el
index 5b1e8bd..a65772d 100644
--- a/lisp/textmodes/reftex-vars.el
+++ b/lisp/textmodes/reftex-vars.el
@@ -1,4 +1,4 @@
-;;; reftex-vars.el --- configuration variables for RefTeX
+;;; reftex-vars.el --- configuration variables for RefTeX  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1997-1999, 2001-2021 Free Software Foundation, Inc.
 
@@ -282,7 +282,7 @@ distribution.  Mixed-case symbols are convenience aliases.")
 The file name is expected after the command, either in braces or separated
 by whitespace."
   :group 'reftex-table-of-contents-browser
-  :set 'reftex-set-dirty
+  :set #'reftex-set-dirty
   :type '(repeat string))
 
 (defcustom reftex-max-section-depth 12
@@ -319,7 +319,7 @@ commands, promotion only works correctly if this list is 
sorted first
 by set, then within each set by level.  The promotion commands always
 select the nearest entry with the correct new level."
   :group 'reftex-table-of-contents-browser
-  :set 'reftex-set-dirty
+  :set #'reftex-set-dirty
   :type '(repeat
           (cons (string :tag "sectioning macro" "")
                 (choice
@@ -463,7 +463,7 @@ The value of this variable is a list of symbols with 
associations in the
 constant `reftex-label-alist-builtin'.  Check that constant for a full list
 of options."
   :group 'reftex-defining-label-environments
-  :set   'reftex-set-dirty
+  :set   #'reftex-set-dirty
   :type `(set
           :indent 4
           :inline t
@@ -611,7 +611,7 @@ Any list entry may also be a symbol.  If that has an 
association in
 list.  However, builtin defaults should normally be set with the variable
 `reftex-default-label-alist-entries'."
   :group 'reftex-defining-label-environments
-  :set 'reftex-set-dirty
+  :set #'reftex-set-dirty
   :type
   `(repeat
     (choice :tag "Package or Detailed   "
@@ -1198,7 +1198,7 @@ File names matched by these regexps will not be parsed by 
RefTeX.
 Intended for files which contain only `@string' macro definitions and the
 like, which are ignored by RefTeX anyway."
   :group 'reftex-citation-support
-  :set 'reftex-set-dirty
+  :set #'reftex-set-dirty
   :type '(repeat (regexp)))
 
 (defcustom reftex-default-bibliography nil
@@ -1460,7 +1460,7 @@ Note that AUCTeX sets these things internally for RefTeX 
as well, so
 with a sufficiently new version of AUCTeX, you should not set the
 package here."
   :group 'reftex-index-support
-  :set 'reftex-set-dirty
+  :set #'reftex-set-dirty
   :type `(list
           (repeat
            :inline t
@@ -1728,7 +1728,7 @@ Multiple directories can be separated by the system 
dependent `path-separator'.
 Directories ending in `//' or `!!' will be expanded recursively.
 See also `reftex-use-external-file-finders'."
   :group 'reftex-finding-files
-  :set 'reftex-set-dirty
+  :set #'reftex-set-dirty
   :type '(repeat (string :tag "Specification")))
 
 (defcustom reftex-bibpath-environment-variables '("BIBINPUTS" "TEXBIB")
@@ -1744,7 +1744,7 @@ Directories ending in `//' or `!!' will be expanded 
recursively.
 See also `reftex-use-external-file-finders'."
   :group 'reftex-citation-support
   :group 'reftex-finding-files
-  :set 'reftex-set-dirty
+  :set #'reftex-set-dirty
   :type '(repeat (string :tag "Specification")))
 
 (defcustom reftex-file-extensions '(("tex" . (".tex" ".ltx"))
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 269d676..c732299 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -1,4 +1,4 @@
-;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX
+;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX  
-*- lexical-binding: t; -*-
 ;; Copyright (C) 1997-2000, 2003-2021 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
@@ -38,9 +38,8 @@
 ;;
 ;;     https://www.gnu.org/software/auctex/manual/reftex.index.html
 ;;
-;; RefTeX is bundled with Emacs and available as a plug-in package for
-;; XEmacs 21.x.  If you need to install it yourself, you can find a
-;; distribution at
+;; RefTeX is bundled with Emacs.
+;; If you need to install it yourself, you can find a distribution at
 ;;
 ;;    https://www.gnu.org/software/auctex/reftex.html
 ;;
@@ -100,37 +99,34 @@
 (defvar reftex-mode-map
   (let ((map (make-sparse-keymap)))
     ;; The default bindings in the mode map.
-    (define-key map "\C-c=" 'reftex-toc)
-    (define-key map "\C-c-" 'reftex-toc-recenter)
-    (define-key map "\C-c(" 'reftex-label)
-    (define-key map "\C-c)" 'reftex-reference)
-    (define-key map "\C-c[" 'reftex-citation)
-    (define-key map "\C-c<" 'reftex-index)
-    (define-key map "\C-c>" 'reftex-display-index)
-    (define-key map "\C-c/" 'reftex-index-selection-or-word)
-    (define-key map "\C-c\\" 'reftex-index-phrase-selection-or-word)
-    (define-key map "\C-c|" 'reftex-index-visit-phrases-buffer)
-    (define-key map "\C-c&" 'reftex-view-crossref)
+    (define-key map "\C-c=" #'reftex-toc)
+    (define-key map "\C-c-" #'reftex-toc-recenter)
+    (define-key map "\C-c(" #'reftex-label)
+    (define-key map "\C-c)" #'reftex-reference)
+    (define-key map "\C-c[" #'reftex-citation)
+    (define-key map "\C-c<" #'reftex-index)
+    (define-key map "\C-c>" #'reftex-display-index)
+    (define-key map "\C-c/" #'reftex-index-selection-or-word)
+    (define-key map "\C-c\\" #'reftex-index-phrase-selection-or-word)
+    (define-key map "\C-c|" #'reftex-index-visit-phrases-buffer)
+    (define-key map "\C-c&" #'reftex-view-crossref)
 
     ;; Bind `reftex-mouse-view-crossref' only when the key is still free
-    (if (featurep 'xemacs)
-        (unless (key-binding [(shift button2)])
-          (define-key map [(shift button2)] 'reftex-mouse-view-crossref))
-      (unless (key-binding [(shift mouse-2)])
-        (define-key map [(shift mouse-2)] 'reftex-mouse-view-crossref)))
+    (unless (key-binding [(shift mouse-2)])
+      (define-key map [(shift mouse-2)] #'reftex-mouse-view-crossref))
 
     ;; For most of these commands there are already bindings in place.
     ;; Setting `reftex-extra-bindings' really is only there to spare users
     ;; the hassle of defining bindings in the user space themselves.  This
     ;; is why they violate the key binding recommendations.
     (when reftex-extra-bindings
-      (define-key map "\C-ct" 'reftex-toc)
-      (define-key map "\C-cl" 'reftex-label)
-      (define-key map "\C-cr" 'reftex-reference)
-      (define-key map "\C-cc" 'reftex-citation)
-      (define-key map "\C-cv" 'reftex-view-crossref)
-      (define-key map "\C-cg" 'reftex-grep-document)
-      (define-key map "\C-cs" 'reftex-search-document))
+      (define-key map "\C-ct" #'reftex-toc)
+      (define-key map "\C-cl" #'reftex-label)
+      (define-key map "\C-cr" #'reftex-reference)
+      (define-key map "\C-cc" #'reftex-citation)
+      (define-key map "\C-cv" #'reftex-view-crossref)
+      (define-key map "\C-cg" #'reftex-grep-document)
+      (define-key map "\C-cs" #'reftex-search-document))
 
     map)
   "Keymap for RefTeX mode.")
@@ -204,8 +200,6 @@ on the menu bar.
   (if reftex-mode
       (progn
         ;; Mode was turned on
-        (when (featurep 'xemacs)
-          (easy-menu-add reftex-mode-menu))
         (and reftex-plug-into-AUCTeX
              (reftex-plug-into-AUCTeX))
         (unless (get 'reftex-auto-view-crossref 'initialized)
@@ -220,10 +214,7 @@ on the menu bar.
         ;; Prepare the special syntax tables.
        (reftex--prepare-syntax-tables)
 
-        (run-hooks 'reftex-mode-hook))
-    ;; Mode was turned off
-    (when (featurep 'xemacs)
-      (easy-menu-remove reftex-mode-menu))))
+        (run-hooks 'reftex-mode-hook))))
 
 (defvar reftex-docstruct-symbol)
 (defun reftex-kill-buffer-hook ()
@@ -391,11 +382,11 @@ If the symbols for the current master file do not exist, 
they are created."
      ((null master)
       (error "Need a filename for this buffer, please save it first"))
      ((or (file-exists-p (concat master ".tex"))
-          (reftex-get-buffer-visiting (concat master ".tex")))
+          (find-buffer-visiting (concat master ".tex")))
       ;; Ahh, an extra .tex was missing...
       (setq master (concat master ".tex")))
      ((or (file-exists-p master)
-          (reftex-get-buffer-visiting master))
+          (find-buffer-visiting master))
       ;; We either see the file, or have a buffer on it.  OK.
       )
      (t
@@ -890,7 +881,7 @@ This enforces rescanning the buffer on next use."
         ;; Are the magic words regular expressions?  Quote normal words.
         (if (eq (car wordlist) 'regexp)
             (setq wordlist (cdr wordlist))
-          (setq wordlist (mapcar 'regexp-quote wordlist)))
+          (setq wordlist (mapcar #'regexp-quote wordlist)))
         ;; Remember the first association of each word.
         (while (stringp (setq word (pop wordlist)))
           (or (assoc word reftex-words-to-typekey-alist)
@@ -1017,11 +1008,11 @@ This enforces rescanning the buffer on next use."
            (wbol "\\(^\\)%?[ \t]*") ; Need to keep the empty group because
                                     ; match numbers are hard coded
            (label-re (concat "\\(?:"
-                            (mapconcat 'identity reftex-label-regexps "\\|")
+                            (mapconcat #'identity reftex-label-regexps "\\|")
                             "\\)"))
            (include-re (concat wbol
                                "\\\\\\("
-                               (mapconcat 'identity
+                               (mapconcat #'identity
                                           reftex-include-file-commands "\\|")
                                "\\)[{ \t]+\\([^} \t\n\r]+\\)"))
            (section-re
@@ -1033,23 +1024,24 @@ This enforces rescanning the buffer on next use."
            (macro-re
             (if macros-with-labels
                 (concat "\\("
-                        (mapconcat 'regexp-quote macros-with-labels "\\|")
+                        (mapconcat #'regexp-quote macros-with-labels "\\|")
                         "\\)[[{]")
               ""))
            (index-re
             (concat "\\("
-                    (mapconcat 'regexp-quote reftex-macros-with-index "\\|")
+                    (mapconcat #'regexp-quote reftex-macros-with-index "\\|")
                     "\\)[[{]"))
            (find-index-re-format
             (concat "\\("
-                    (mapconcat 'regexp-quote reftex-macros-with-index "\\|")
+                    (mapconcat #'regexp-quote reftex-macros-with-index "\\|")
                     "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]"))
            (find-label-re-format
             (concat "\\("
                    "label[[:space:]]*=[[:space:]]*"
                    "\\|"
-                    (mapconcat 'regexp-quote (append '("\\label")
-                                                     macros-with-labels) "\\|")
+                    (mapconcat #'regexp-quote (append '("\\label")
+                                                      macros-with-labels)
+                               "\\|")
                     "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]"))
            (index-level-re
             (regexp-quote (nth 0 reftex-index-special-chars)))
@@ -1081,7 +1073,7 @@ This enforces rescanning the buffer on next use."
             "\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]")
       (message "Compiling label environment definitions...done")))
   (put reftex-docstruct-symbol 'reftex-cache
-       (mapcar 'symbol-value reftex-cache-variables)))
+       (mapcar #'symbol-value reftex-cache-variables)))
 
 (defun reftex-parse-args (macro)
   ;; Return a list of macro name, nargs, arg-nr which is label and a list of
@@ -1277,8 +1269,8 @@ Valid actions are: readable, restore, read, kill, write."
       (- 1 xr-index))
      (t
       (save-excursion
-        (let* ((length (apply 'max (mapcar
-                                    (lambda(x) (length (car x))) xr-alist)))
+        (let* ((length (apply #'max (mapcar
+                                     (lambda(x) (length (car x))) xr-alist)))
                (fmt (format " [%%c]  %%-%ds  %%s\n" length))
                (n (1- ?0)))
           (setq key
@@ -1312,7 +1304,7 @@ When DIE is non-nil, throw an error if file not found."
          (extensions (cdr (assoc type reftex-file-extensions)))
          (def-ext (car extensions))
          (ext-re (concat "\\("
-                         (mapconcat 'regexp-quote extensions "\\|")
+                         (mapconcat #'regexp-quote extensions "\\|")
                          "\\)\\'"))
          (files (if (string-match ext-re file)
                     (cons file nil)
@@ -1354,7 +1346,7 @@ When DIE is non-nil, throw an error if file not found."
         out)
     (if (string-match "%f" prg)
         (setq prg (replace-match file t t prg)))
-    (setq out (apply 'reftex-process-string (split-string prg)))
+    (setq out (apply #'reftex-process-string (split-string prg)))
     (if (string-match "[ \t\n]+\\'" out)     ; chomp
         (setq out (replace-match "" nil nil out)))
     (cond ((equal out "") nil)
@@ -1367,7 +1359,7 @@ When DIE is non-nil, throw an error if file not found."
     (with-output-to-string
       (with-current-buffer standard-output
         (let ((default-directory calling-dir)) ; set default directory
-          (apply 'call-process program nil '(t nil) nil args))))))
+          (apply #'call-process program nil '(t nil) nil args))))))
 
 (defun reftex-access-search-path (type &optional recurse master-dir file)
   ;; Access path from environment variables.  TYPE is either "tex" or "bib".
@@ -1386,7 +1378,7 @@ When DIE is non-nil, throw an error if file not found."
              (mapconcat
               (lambda(x)
                 (if (string-match "^!" x)
-                    (apply 'reftex-process-string
+                    (apply #'reftex-process-string
                            (split-string (substring x 1)))
                   (or (getenv x) x)))
               ;; For consistency, the next line should look like this:
@@ -1531,12 +1523,7 @@ When DIE is non-nil, throw an error if file not found."
   (when (match-beginning n)
     (buffer-substring-no-properties (match-beginning n) (match-end n))))
 
-(defun reftex-region-active-p ()
-  "Should we operate on an active region?"
-  (if (fboundp 'use-region-p)
-      (use-region-p)
-    ;; For XEmacs.
-    (region-active-p)))
+(define-obsolete-function-alias 'reftex-region-active-p #'use-region-p "28.1")
 
 (defun reftex-kill-buffer (buffer)
   ;; Kill buffer if it exists.
@@ -1745,26 +1732,12 @@ When DIE is non-nil, throw an error if file not found."
       (setq string (replace-match "[\n\r]" nil t string)))
     string))
 
-(defun reftex-get-buffer-visiting (file)
-  ;; return a buffer visiting FILE
-  (cond
-   ((boundp 'find-file-compare-truenames) ; XEmacs
-    (let ((find-file-compare-truenames t))
-      (get-file-buffer file)))
-   ((fboundp 'find-buffer-visiting)       ; Emacs
-    (find-buffer-visiting file))
-   (t (error "This should not happen (reftex-get-buffer-visiting)"))))
-
-;; Define `current-message' for compatibility with XEmacs prior to 20.4
-(defvar message-stack)
-(if (and (featurep 'xemacs)
-         (not (fboundp 'current-message)))
-    (defun current-message (&optional _frame)
-      (cdr (car message-stack))))
+(define-obsolete-function-alias 'reftex-get-buffer-visiting
+  #'find-buffer-visiting "28.1")
 
 (defun reftex-visited-files (list)
   ;; Takes a list of filenames and returns the buffers of those already visited
-  (delq nil (mapcar (lambda (x) (if (reftex-get-buffer-visiting x) x nil))
+  (delq nil (mapcar (lambda (x) (if (find-buffer-visiting x) x nil))
                     list)))
 
 (defun reftex-get-file-buffer-force (file &optional mark-to-kill)
@@ -1774,7 +1747,7 @@ When DIE is non-nil, throw an error if file not found."
   ;; initializations according to `reftex-initialize-temporary-buffers',
   ;; and mark the buffer to be killed after use.
 
-  (let ((buf (reftex-get-buffer-visiting file)))
+  (let ((buf (find-buffer-visiting file)))
 
     (cond (buf
            ;; We have it already as a buffer - just return it
@@ -1866,7 +1839,7 @@ When DIE is non-nil, throw an error if file not found."
   (setq list (copy-sequence list))
   (if sort
       (progn
-       (setq list (sort list 'string<))
+       (setq list (sort list #'string<))
        (let ((p list))
          (while (cdr p)
            (if (string= (car p) (car (cdr p)))
@@ -2003,7 +1976,7 @@ IGNORE-WORDS List of words which should be removed from 
the string."
         (setcdr (nthcdr (1- nwords) words) nil))
 
     ;; First, try to use all words
-    (setq string (mapconcat 'identity words sep))
+    (setq string (mapconcat #'identity words sep))
 
     ;; Abbreviate words if enforced by user settings or string length
     (if (or (eq t abbrev)
@@ -2017,7 +1990,7 @@ IGNORE-WORDS List of words which should be removed from 
the string."
                                  (match-string 1 w))
                              w))
                words)
-              string (mapconcat 'identity words sep)))
+              string (mapconcat #'identity words sep)))
 
     ;; Shorten if still to long
     (setq string
@@ -2081,24 +2054,11 @@ IGNORE-WORDS List of words which should be removed from 
the string."
         (progn
           ;; Rename buffer temporarily to start w/o space (because of 
font-lock)
           (rename-buffer newname t)
-          (cond
-           ((fboundp 'font-lock-default-fontify-region)
-            ;; Good: we have the indirection functions
-            (set (make-local-variable 'font-lock-fontify-region-function)
-                 'reftex-select-font-lock-fontify-region)
-            (let ((major-mode 'latex-mode))
-              (font-lock-mode 1)))
-           ((fboundp 'font-lock-set-defaults-1)
-            ;; Looks like the XEmacs font-lock stuff.
-            ;; FIXME: this is still kind of a hack, but it works.
-            (set (make-local-variable 'font-lock-keywords) nil)
-            (let ((major-mode 'latex-mode)
-                  (font-lock-defaults-computed nil))
-              (font-lock-set-defaults-1)
-              (reftex-select-font-lock-fontify-region (point-min) 
(point-max))))
-           (t
-            ;; Oops?
-            (message "Sorry: cannot refontify RefTeX Select buffer."))))
+          ;; Good: we have the indirection functions
+          (set (make-local-variable 'font-lock-fontify-region-function)
+               #'reftex-select-font-lock-fontify-region)
+          (let ((major-mode 'latex-mode))
+            (font-lock-mode 1)))
       (rename-buffer oldname))))
 
 (defun reftex-select-font-lock-fontify-region (beg end &optional _loudly)
@@ -2123,46 +2083,39 @@ IGNORE-WORDS List of words which should be removed from 
the string."
   (let (face)
     (catch 'exit
       (while (setq face (pop faces))
-        (if (featurep 'xemacs)
-            (if (find-face face) (throw 'exit face))
-          (if (facep face) (throw 'exit face)))))))
-
-;; Highlighting uses overlays.  For XEmacs, we use extends.
-(defalias 'reftex-make-overlay
-  (if (featurep 'xemacs) 'make-extent 'make-overlay))
-(defalias 'reftex-overlay-put
-  (if (featurep 'xemacs) 'set-extent-property 'overlay-put))
-(defalias 'reftex-move-overlay
-  (if (featurep 'xemacs) 'set-extent-endpoints 'move-overlay))
-(defalias 'reftex-delete-overlay
-  (if (featurep 'xemacs) 'detach-extent 'delete-overlay))
+        (if (facep face) (throw 'exit face))))))
+
+(define-obsolete-function-alias 'reftex-make-overlay #'make-overlay "28.1")
+(define-obsolete-function-alias 'reftex-overlay-put #'overlay-put "28.1")
+(define-obsolete-function-alias 'reftex-move-overlay #'move-overlay "28.1")
+(define-obsolete-function-alias 'reftex-delete-overlay #'delete-overlay "28.1")
 
 ;; We keep a vector with several different overlays to do our highlighting.
 (defvar reftex-highlight-overlays [nil nil nil])
 
 ;; Initialize the overlays
-(aset reftex-highlight-overlays 0 (reftex-make-overlay 1 1))
-(reftex-overlay-put (aref reftex-highlight-overlays 0)
+(aset reftex-highlight-overlays 0 (make-overlay 1 1))
+(overlay-put (aref reftex-highlight-overlays 0)
              'face 'highlight)
-(aset reftex-highlight-overlays 1 (reftex-make-overlay 1 1))
-(reftex-overlay-put (aref reftex-highlight-overlays 1)
+(aset reftex-highlight-overlays 1 (make-overlay 1 1))
+(overlay-put (aref reftex-highlight-overlays 1)
              'face reftex-cursor-selected-face)
-(aset reftex-highlight-overlays 2 (reftex-make-overlay 1 1))
-(reftex-overlay-put (aref reftex-highlight-overlays 2)
+(aset reftex-highlight-overlays 2 (make-overlay 1 1))
+(overlay-put (aref reftex-highlight-overlays 2)
              'face reftex-cursor-selected-face)
 
 ;; Two functions for activating and deactivation highlight overlays
 (defun reftex-highlight (index begin end &optional buffer)
   "Highlight a region with overlay INDEX."
-  (reftex-move-overlay (aref reftex-highlight-overlays index)
+  (move-overlay (aref reftex-highlight-overlays index)
                 begin end (or buffer (current-buffer))))
 (defun reftex-unhighlight (index)
   "Detach overlay INDEX."
-  (reftex-delete-overlay (aref reftex-highlight-overlays index)))
+  (delete-overlay (aref reftex-highlight-overlays index)))
 
 (defun reftex-highlight-shall-die ()
   ;; Function used in pre-command-hook to remove highlights.
-  (remove-hook 'pre-command-hook 'reftex-highlight-shall-die)
+  (remove-hook 'pre-command-hook #'reftex-highlight-shall-die)
   (reftex-unhighlight 0))
 
 ;;; =========================================================================
@@ -2174,7 +2127,7 @@ IGNORE-WORDS List of words which should be removed from 
the string."
 ;; Bind `reftex-view-crossref-from-bibtex' in BibTeX mode map
 (eval-after-load
  "bibtex"
- '(define-key bibtex-mode-map "\C-c&" 'reftex-view-crossref-from-bibtex))
+ '(define-key bibtex-mode-map "\C-c&" #'reftex-view-crossref-from-bibtex))
 
 ;;; =========================================================================
 ;;;
@@ -2379,9 +2332,9 @@ Your bug report will be posted to the AUCTeX bug 
reporting list.
 
 ;;; Install the kill-buffer and kill-emacs hooks ------------------------------
 
-(add-hook 'kill-buffer-hook 'reftex-kill-buffer-hook)
+(add-hook 'kill-buffer-hook #'reftex-kill-buffer-hook)
 (unless noninteractive
-  (add-hook 'kill-emacs-hook  'reftex-kill-emacs-hook))
+  (add-hook 'kill-emacs-hook #'reftex-kill-emacs-hook))
 
 ;;; Run Hook ------------------------------------------------------------------
 
diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el
index 6a72ebb..b731c12 100644
--- a/lisp/textmodes/remember.el
+++ b/lisp/textmodes/remember.el
@@ -1,4 +1,4 @@
-;;; remember --- a mode for quickly jotting down things to remember
+;;; remember --- a mode for quickly jotting down things to remember  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1999-2001, 2003-2021 Free Software Foundation, Inc.
 
@@ -270,12 +270,13 @@ With a prefix or a visible region, use the region as 
INITIAL."
            (buffer-substring (region-beginning) (region-end)))))
   (funcall (if remember-in-new-frame
                #'frameset-to-register
-             #'window-configuration-to-register) remember-register)
+             #'window-configuration-to-register)
+           remember-register)
   (let* ((annotation
           (if remember-run-all-annotation-functions-flag
-              (mapconcat 'identity
+              (mapconcat #'identity
                          (delq nil
-                               (mapcar 'funcall remember-annotation-functions))
+                               (mapcar #'funcall 
remember-annotation-functions))
                          "\n")
             (run-hook-with-args-until-success
              'remember-annotation-functions)))
@@ -283,7 +284,8 @@ With a prefix or a visible region, use the region as 
INITIAL."
     (run-hooks 'remember-before-remember-hook)
     (funcall (if remember-in-new-frame
                  #'switch-to-buffer-other-frame
-               #'switch-to-buffer-other-window) buf)
+               #'switch-to-buffer-other-window)
+             buf)
     (if remember-in-new-frame
         (set-window-dedicated-p
          (get-buffer-window (current-buffer) (selected-frame)) t))
@@ -384,7 +386,7 @@ exists) might be changed."
              (with-current-buffer buf
                (set-visited-file-name
                 (expand-file-name remember-data-file))))))
-  :initialize 'custom-initialize-default)
+  :initialize #'custom-initialize-default)
 
 (defcustom remember-leader-text "** "
   "The text used to begin each remember item."
@@ -541,7 +543,7 @@ If this is nil, then `diary-file' will be used instead."
       (while (re-search-forward remember-diary-regexp nil t)
         (push (remember-diary-convert-entry (match-string 1)) list))
       (when list
-        (diary-make-entry (mapconcat 'identity list "\n")
+        (diary-make-entry (mapconcat #'identity list "\n")
                           nil remember-diary-file)
         (when remember-save-after-remembering
           (with-current-buffer (find-buffer-visiting (or remember-diary-file
@@ -553,9 +555,9 @@ If this is nil, then `diary-file' will be used instead."
 
 (defvar remember-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "\C-x\C-s" 'remember-finalize)
-    (define-key map "\C-c\C-c" 'remember-finalize)
-    (define-key map "\C-c\C-k" 'remember-destroy)
+    (define-key map "\C-x\C-s" #'remember-finalize)
+    (define-key map "\C-c\C-c" #'remember-finalize)
+    (define-key map "\C-c\C-k" #'remember-destroy)
     map)
   "Keymap used in `remember-mode'.")
 
@@ -601,7 +603,7 @@ If this is nil, use `initial-major-mode'."
 
 (defvar remember-notes-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "\C-c\C-c" 'remember-notes-save-and-bury-buffer)
+    (define-key map "\C-c\C-c" #'remember-notes-save-and-bury-buffer)
     map)
   "Keymap used in `remember-notes-mode'.")
 
diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el
index 60122b2..a9f066c 100644
--- a/lisp/textmodes/table.el
+++ b/lisp/textmodes/table.el
@@ -1306,17 +1306,16 @@ the last cache point coordinate."
   (let ((func-symbol (intern (format "*table--cell-%s" command)))
         (doc-string (format "Table remapped function for `%s'." command)))
     (defalias func-symbol
-      `(lambda
-         (&rest args)
-         ,doc-string
-         (interactive)
-         (let ((table-inhibit-update t)
-               (deactivate-mark nil))
-           (table--finish-delayed-tasks)
-           (table-recognize-cell 'force)
-           (table-with-cache-buffer
-             (call-interactively ',command)
-             (setq table-inhibit-auto-fill-paragraph t)))))
+      (lambda (&rest _args)
+        (:documentation doc-string)
+        (interactive)
+        (let ((table-inhibit-update t)
+              (deactivate-mark nil))
+          (table--finish-delayed-tasks)
+          (table-recognize-cell 'force)
+          (table-with-cache-buffer
+           (call-interactively command)
+           (setq table-inhibit-auto-fill-paragraph t)))))
     (push (cons command func-symbol)
           table-command-remap-alist)))
 
@@ -1338,17 +1337,16 @@ the last cache point coordinate."
   (let ((func-symbol (intern (format "*table--cell-%s" command)))
         (doc-string (format "Table remapped function for `%s'." command)))
     (defalias func-symbol
-      `(lambda
-         (&rest args)
-         ,doc-string
-         (interactive)
-         (table--finish-delayed-tasks)
-         (table-recognize-cell 'force)
-         (table-with-cache-buffer
-           (table--remove-cell-properties (point-min) (point-max))
-           (table--remove-eol-spaces (point-min) (point-max))
-           (call-interactively ',command))
-         (table--finish-delayed-tasks)))
+      (lambda (&rest _args)
+        (:documentation doc-string)
+        (interactive)
+        (table--finish-delayed-tasks)
+        (table-recognize-cell 'force)
+        (table-with-cache-buffer
+         (table--remove-cell-properties (point-min) (point-max))
+         (table--remove-eol-spaces (point-min) (point-max))
+         (call-interactively command))
+        (table--finish-delayed-tasks)))
     (push (cons command func-symbol)
           table-command-remap-alist)))
 
@@ -1360,19 +1358,18 @@ the last cache point coordinate."
            insert))
   (let ((func-symbol (intern (format "*table--cell-%s" command)))
         (doc-string (format "Table remapped function for `%s'." command)))
-    (fset func-symbol
-          `(lambda
-             (&rest args)
-             ,doc-string
-             (interactive)
-             (table--finish-delayed-tasks)
-             (table-recognize-cell 'force)
-             (table-with-cache-buffer
-               (call-interactively ',command)
-               (table--untabify (point-min) (point-max))
-               (table--fill-region (point-min) (point-max))
-               (setq table-inhibit-auto-fill-paragraph t))
-             (table--finish-delayed-tasks)))
+    (defalias func-symbol
+      (lambda (&rest _args)
+        (:documentation doc-string)
+        (interactive)
+        (table--finish-delayed-tasks)
+        (table-recognize-cell 'force)
+        (table-with-cache-buffer
+         (call-interactively command)
+         (table--untabify (point-min) (point-max))
+         (table--fill-region (point-min) (point-max))
+         (setq table-inhibit-auto-fill-paragraph t))
+        (table--finish-delayed-tasks)))
     (push (cons command func-symbol)
           table-command-remap-alist)))
 
@@ -1384,18 +1381,17 @@ the last cache point coordinate."
            fill-paragraph))
   (let ((func-symbol (intern (format "*table--cell-%s" command)))
         (doc-string (format "Table remapped function for `%s'." command)))
-    (fset func-symbol
-          `(lambda
-             (&rest args)
-             ,doc-string
-             (interactive)
-             (table--finish-delayed-tasks)
-             (table-recognize-cell 'force)
-             (table-with-cache-buffer
-               (let ((fill-column table-cell-info-width))
-                 (call-interactively ',command))
-               (setq table-inhibit-auto-fill-paragraph t))
-             (table--finish-delayed-tasks)))
+    (defalias func-symbol
+      (lambda (&rest _args)
+        (:documentation doc-string)
+        (interactive)
+        (table--finish-delayed-tasks)
+        (table-recognize-cell 'force)
+        (table-with-cache-buffer
+         (let ((fill-column table-cell-info-width))
+           (call-interactively command))
+         (setq table-inhibit-auto-fill-paragraph t))
+        (table--finish-delayed-tasks)))
     (push (cons command func-symbol)
           table-command-remap-alist)))
 
@@ -2975,8 +2971,8 @@ CALS (DocBook DTD):
                (setq col-list (cons (car lu-coordinate) col-list)))
              (unless (memq (cdr lu-coordinate) row-list)
                (setq row-list (cons (cdr lu-coordinate) row-list))))))
-       (setq col-list (sort col-list '<))
-       (setq row-list (sort row-list '<))
+       (setq col-list (sort col-list #'<))
+       (setq row-list (sort row-list #'<))
        (message "Generating source...")
        ;; clear the source generation property list
        (setplist 'table-source-info-plist nil)
@@ -3023,7 +3019,7 @@ CALS (DocBook DTD):
                "")))
      ((eq language 'latex)
       (insert (format "%% This LaTeX table template is generated by emacs 
%s\n" emacs-version)
-             "\\begin{tabular}{|" (apply 'concat (make-list (length col-list) 
"l|")) "}\n"
+             "\\begin{tabular}{|" (apply #'concat (make-list (length col-list) 
"l|")) "}\n"
              "\\hline\n"))
      ((eq language 'cals)
       (insert (format "<!-- This CALS table template is generated by emacs %s 
-->\n" emacs-version)
@@ -3054,7 +3050,7 @@ CALS (DocBook DTD):
       (set-marker-insertion-type (table-get-source-info 'colspec-marker) t) ;; 
insert before
       (save-excursion
        (goto-char (table-get-source-info 'colspec-marker))
-       (dolist (col (sort (table-get-source-info 'colnum-list) '<))
+       (dolist (col (sort (table-get-source-info 'colnum-list) #'<))
           (insert (format "    <colspec colnum=\"%d\" colname=\"c%d\"/>\n" col 
col))))
       (insert (format "    </%s>\n  </tgroup>\n</table>\n" 
(table-get-source-info 'row-type))))
      ((eq language 'mediawiki)
@@ -3852,7 +3848,7 @@ converts a table into plain text without frames.  It is a 
companion to
 
 ;; Create the keymap after running the user init file so that the user
 ;; modification to the global-map is accounted.
-(add-hook 'after-init-hook 'table--make-cell-map t)
+(add-hook 'after-init-hook #'table--make-cell-map t)
 
 (defun *table--cell-self-insert-command ()
   "Table cell version of `self-insert-command'."
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index d5a79ad..fb57b9b 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -857,11 +857,11 @@ START is the position of the \\ and DELIM is the 
delimiter char."
 
 (defun tex-define-common-keys (keymap)
   "Define the keys that we want defined both in TeX mode and in the TeX shell."
-  (define-key keymap "\C-c\C-k" 'tex-kill-job)
-  (define-key keymap "\C-c\C-l" 'tex-recenter-output-buffer)
-  (define-key keymap "\C-c\C-q" 'tex-show-print-queue)
-  (define-key keymap "\C-c\C-p" 'tex-print)
-  (define-key keymap "\C-c\C-v" 'tex-view)
+  (define-key keymap "\C-c\C-k" #'tex-kill-job)
+  (define-key keymap "\C-c\C-l" #'tex-recenter-output-buffer)
+  (define-key keymap "\C-c\C-q" #'tex-show-print-queue)
+  (define-key keymap "\C-c\C-p" #'tex-print)
+  (define-key keymap "\C-c\C-v" #'tex-view)
 
   (define-key keymap [menu-bar tex] (cons "TeX" (make-sparse-keymap "TeX")))
 
@@ -884,27 +884,27 @@ START is the position of the \\ and DELIM is the 
delimiter char."
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map text-mode-map)
     (tex-define-common-keys map)
-    (define-key map "\"" 'tex-insert-quote)
-    (define-key map "\n" 'tex-handle-newline)
-    (define-key map "\M-\r" 'latex-insert-item)
-    (define-key map "\C-c}" 'up-list)
-    (define-key map "\C-c{" 'tex-insert-braces)
-    (define-key map "\C-c\C-r" 'tex-region)
-    (define-key map "\C-c\C-b" 'tex-buffer)
-    (define-key map "\C-c\C-f" 'tex-file)
-    (define-key map "\C-c\C-c" 'tex-compile)
-    (define-key map "\C-c\C-i" 'tex-bibtex-file)
-    (define-key map "\C-c\C-o" 'latex-insert-block)
+    (define-key map "\"" #'tex-insert-quote)
+    (define-key map "\n" #'tex-handle-newline)
+    (define-key map "\M-\r" #'latex-insert-item)
+    (define-key map "\C-c}" #'up-list)
+    (define-key map "\C-c{" #'tex-insert-braces)
+    (define-key map "\C-c\C-r" #'tex-region)
+    (define-key map "\C-c\C-b" #'tex-buffer)
+    (define-key map "\C-c\C-f" #'tex-file)
+    (define-key map "\C-c\C-c" #'tex-compile)
+    (define-key map "\C-c\C-i" #'tex-bibtex-file)
+    (define-key map "\C-c\C-o" #'latex-insert-block)
 
     ;; Redundant keybindings, for consistency with SGML mode.
-    (define-key map "\C-c\C-t" 'latex-insert-block)
-    (define-key map "\C-c]" 'latex-close-block)
-    (define-key map "\C-c/" 'latex-close-block)
-
-    (define-key map "\C-c\C-e" 'latex-close-block)
-    (define-key map "\C-c\C-u" 'tex-goto-last-unclosed-latex-block)
-    (define-key map "\C-c\C-m" 'tex-feed-input)
-    (define-key map [(control return)] 'tex-feed-input)
+    (define-key map "\C-c\C-t" #'latex-insert-block)
+    (define-key map "\C-c]" #'latex-close-block)
+    (define-key map "\C-c/" #'latex-close-block)
+
+    (define-key map "\C-c\C-e" #'latex-close-block)
+    (define-key map "\C-c\C-u" #'tex-goto-last-unclosed-latex-block)
+    (define-key map "\C-c\C-m" #'tex-feed-input)
+    (define-key map [(control return)] #'tex-feed-input)
     (define-key map [menu-bar tex tex-bibtex-file]
       '("BibTeX File" . tex-bibtex-file))
     (define-key map [menu-bar tex tex-validate-region]
@@ -922,7 +922,7 @@ START is the position of the \\ and DELIM is the delimiter 
char."
 (defvar latex-mode-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map tex-mode-map)
-    (define-key map "\C-c\C-s" 'latex-split-block)
+    (define-key map "\C-c\C-s" #'latex-split-block)
     map)
   "Keymap for `latex-mode'.  See also `tex-mode-map'.")
 
@@ -1033,11 +1033,11 @@ says which mode to use."
 ;; received them from someone using AUCTeX).
 
 ;;;###autoload
-(defalias 'TeX-mode 'tex-mode)
+(defalias 'TeX-mode #'tex-mode)
 ;;;###autoload
-(defalias 'plain-TeX-mode 'plain-tex-mode)
+(defalias 'plain-TeX-mode #'plain-tex-mode)
 ;;;###autoload
-(defalias 'LaTeX-mode 'latex-mode)
+(defalias 'LaTeX-mode #'latex-mode)
 
 ;;;###autoload
 (define-derived-mode plain-tex-mode tex-mode "TeX"
@@ -1560,7 +1560,7 @@ the name of the environment and SKEL-ELEM is an element 
to use in
 a skeleton (see `skeleton-insert').")
 
 ;; Like tex-insert-braces, but for LaTeX.
-(defalias 'tex-latex-block 'latex-insert-block)
+(defalias 'tex-latex-block #'latex-insert-block)
 (define-skeleton latex-insert-block
   "Create a matching pair of lines \\begin{NAME} and \\end{NAME} at point.
 Puts point on a blank line between them."
@@ -1866,7 +1866,7 @@ Mark is left at original location."
        (with-syntax-table tex-mode-syntax-table
          (forward-sexp))))))
 
-(defalias 'tex-close-latex-block 'latex-close-block)
+(defalias 'tex-close-latex-block #'latex-close-block)
 (define-skeleton latex-close-block
   "Create an \\end{...} to match the last unclosed \\begin{...}."
   (save-excursion
@@ -2008,7 +2008,7 @@ Mark is left at original location."
        ;; Specify an interactive shell, to make sure it prompts.
        "-i")
     (let ((proc (get-process "tex-shell")))
-      (set-process-sentinel proc 'tex-shell-sentinel)
+      (set-process-sentinel proc #'tex-shell-sentinel)
       (set-process-query-on-exit-flag proc nil)
       (tex-shell)
       (while (zerop (buffer-size))
@@ -2063,7 +2063,7 @@ evaluates to a command string.
 
 Return the process in which TeX is running."
   (save-excursion
-    (let* ((cmd (eval command))
+    (let* ((cmd (eval command t))
           (proc (tex-shell-proc))
           (buf (process-buffer proc))
            (star (string-match "\\*" cmd))
@@ -2313,7 +2313,7 @@ FILE is typically the output DVI or PDF file."
             executable))))))
 
 (defun tex-command-executable (cmd)
-  (let ((s (if (stringp cmd) cmd (eval (car cmd)))))
+  (let ((s (if (stringp cmd) cmd (eval (car cmd) t))))
     (substring s 0 (string-match "[ \t]\\|\\'" s))))
 
 (defun tex-command-active-p (cmd fspec)
@@ -2400,7 +2400,7 @@ Only applies the FSPEC to the args part of FORMAT."
                (setq latest (nth 1 cmd) cmds (list cmd)))))))
     ;; Expand the command spec into the actual text.
     (dolist (cmd (prog1 cmds (setq cmds nil)))
-      (push (cons (eval (car cmd)) (cdr cmd)) cmds))
+      (push (cons (eval (car cmd) t) (cdr cmd)) cmds))
     ;; Select the favorite command from the history.
     (let ((hist tex-compile-history)
          re hist-cmd)
@@ -2446,7 +2446,7 @@ Only applies the FSPEC to the args part of FORMAT."
           (completing-read
            (format "Command [%s]: " (tex-summarize-command default))
            (mapcar (lambda (x)
-                     (list (tex-format-cmd (eval (car x)) fspec)))
+                     (list (tex-format-cmd (eval (car x) t) fspec)))
                    tex-compile-commands)
            nil nil nil 'tex-compile-history default))))
   (save-some-buffers (not compilation-ask-about-save) nil)
@@ -2740,7 +2740,7 @@ because there is no standard value that would generally 
work."
   ;; Restart the TeX shell if necessary.
   (or (tex-shell-running)
       (tex-start-shell))
-  (let ((tex-dvi-print-command (eval tex-dvi-view-command)))
+  (let ((tex-dvi-print-command (eval tex-dvi-view-command t)))
     (tex-print)))
 
 (defun tex-append (file-name suffix)
diff --git a/lisp/textmodes/texinfmt.el b/lisp/textmodes/texinfmt.el
index fe052e3..a797df9 100644
--- a/lisp/textmodes/texinfmt.el
+++ b/lisp/textmodes/texinfmt.el
@@ -1,4 +1,4 @@
-;;; texinfmt.el --- format Texinfo files into Info files
+;;; texinfmt.el --- format Texinfo files into Info files  -*- lexical-binding: 
t; -*-
 
 ;; Copyright (C) 1985-1986, 1988, 1990-1998, 2000-2021 Free Software
 ;; Foundation, Inc.
@@ -186,6 +186,7 @@ containing the Texinfo file.")
 ;; These come from tex-mode.el.
 (defvar tex-start-of-header)
 (defvar tex-end-of-header)
+(defvar texinfo-example-start)
 
 ;;;###autoload
 (defun texinfo-format-region (region-beginning region-end)
@@ -211,7 +212,7 @@ converted to Info is stored in a temporary buffer."
         texinfo-last-node
         texinfo-node-names
         (texinfo-footnote-number 0)
-        last-input-buffer
+        ;; last-input-buffer
         (fill-column-for-info fill-column)
         (input-buffer (current-buffer))
         (input-directory default-directory)
@@ -405,7 +406,7 @@ if large.  You can use `Info-split' to do this manually."
         texinfo-stack
         texinfo-node-names
         (texinfo-footnote-number 0)
-        last-input-buffer
+        ;; last-input-buffer
         outfile
         (fill-column-for-info fill-column)
         (input-buffer (current-buffer))
@@ -924,7 +925,7 @@ commands."
          (error "Unterminated @%s" (car (car texinfo-stack)))))
 
   ;; Remove excess whitespace
-  (let ((whitespace-silent t))
+  (dlet ((whitespace-silent t))
     (whitespace-cleanup)))
 
 (defvar texinfo-copying-text ""
@@ -1032,18 +1033,18 @@ Leave point after argument."
 (defun texinfo-optional-braces-discard ()
   "Discard braces following command, if any."
   (goto-char texinfo-command-end)
-  (let ((start (point)))
-    (cond ((looking-at "[ \t]*\n"))     ; do nothing
-          ((looking-at "{")             ; remove braces, if any
-           (forward-list 1)
-           (setq texinfo-command-end (point)))
-          (t
-           (error
-            "Invalid `texinfo-optional-braces-discard' format (need 
braces?)")))
-    (delete-region texinfo-command-start texinfo-command-end)))
+  ;; (let ((start (point)))
+  (cond ((looking-at "[ \t]*\n"))       ; do nothing
+        ((looking-at "{")               ; remove braces, if any
+         (forward-list 1)
+         (setq texinfo-command-end (point)))
+        (t
+         (error
+          "Invalid `texinfo-optional-braces-discard' format (need braces?)")))
+  (delete-region texinfo-command-start texinfo-command-end)) ;;)
 
 (defun texinfo-format-parse-line-args ()
-  (let ((start (1- (point)))
+  (let (;; (start (1- (point)))
         next beg end
         args)
     (skip-chars-forward " ")
@@ -1064,7 +1065,7 @@ Leave point after argument."
     (nreverse args)))
 
 (defun texinfo-format-parse-args ()
-  (let ((start (1- (point)))
+  (let (;; (start (1- (point)))
         next beg end
         args)
     (search-forward "{")
@@ -2007,26 +2008,26 @@ commands that are defined in texinfo.tex for printed 
output.
      ;;
      ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
      ((looking-at "{")
-      (let ((start-of-templates (point)))
-        (while (not (eolp))
-          (skip-chars-forward " \t")
-          (let* ((start-of-template (1+ (point)))
-                 (end-of-template
-                 ;; forward-sexp works with braces in Texinfo mode
-                  (progn (forward-sexp 1) (1- (point)))))
-            (push (- end-of-template start-of-template)
-                  texinfo-multitable-width-list)
-            ;; Remove carriage return from within a template, if any.
-            ;; This helps those who want to use more than
-            ;; one line's worth of words in @multitable line.
-            (narrow-to-region start-of-template end-of-template)
-            (goto-char (point-min))
-            (while (search-forward "
+      ;; (let ((start-of-templates (point)))
+      (while (not (eolp))
+        (skip-chars-forward " \t")
+        (let* ((start-of-template (1+ (point)))
+               (end-of-template
+                ;; forward-sexp works with braces in Texinfo mode
+                (progn (forward-sexp 1) (1- (point)))))
+          (push (- end-of-template start-of-template)
+                texinfo-multitable-width-list)
+          ;; Remove carriage return from within a template, if any.
+          ;; This helps those who want to use more than
+          ;; one line's worth of words in @multitable line.
+          (narrow-to-region start-of-template end-of-template)
+          (goto-char (point-min))
+          (while (search-forward "
 " nil t)
-              (delete-char -1))
-            (goto-char (point-max))
-            (widen)
-            (forward-char 1)))))
+            (delete-char -1))
+          (goto-char (point-max))
+          (widen)
+          (forward-char 1)))) ;; )
      ;;
      ;; Case 3: Trouble
      (t
@@ -2040,7 +2041,7 @@ commands that are defined in texinfo.tex for printed 
output.
             ;; additional between column spaces, if any
             texinfo-extra-inter-column-width
             ;; sum of spaces for each entry
-            (apply '+ texinfo-multitable-width-list))))
+            (apply #'+ texinfo-multitable-width-list))))
       (if (> desired-columns fill-column)
           (error
            "Multi-column table width, %d chars, is greater than page width, %d 
chars."
@@ -2171,9 +2172,9 @@ This command is executed when texinfmt sees @item inside 
@multitable."
       (while (< column-number total-number-of-columns)
         (setq here (point))
         (insert-rectangle
-         (eval (intern
-                (concat texinfo-multitable-rectangle-name
-                        (int-to-string column-number)))))
+         (symbol-value (intern
+                        (concat texinfo-multitable-rectangle-name
+                                (int-to-string column-number)))))
         (goto-char here)
         (end-of-line)
         (setq column-number (1+ column-number))))
@@ -2396,8 +2397,8 @@ Use only the FILENAME arg; for Info, ignore the other 
arguments to @image."
 
 (put 'alias 'texinfo-format 'texinfo-alias)
 (defun texinfo-alias ()
-  (let ((start (1- (point)))
-        args)
+  (let (;; (start (1- (point))
+        ) ;; args
     (skip-chars-forward " ")
     (setq texinfo-command-end (line-end-position))
     (if (not (looking-at "\\([^=]+\\)=\\(.*\\)"))
@@ -3410,7 +3411,7 @@ Default is to leave paragraph indentation as is."
     (while args
       (insert " "
               (if (or (= ?& (aref (car args) 0))
-                      (eq (eval (car texinfo-defun-type)) 'deftp-type))
+                      (eq (car texinfo-defun-type) 'deftp-type))
                   (car args)
                 (upcase (car args))))
       (setq args (cdr args)))))
@@ -3775,80 +3776,80 @@ Default is to leave paragraph indentation as is."
 (put 'deffn 'texinfo-format 'texinfo-format-defun)
 (put 'deffnx 'texinfo-format 'texinfo-format-defunx)
 (put 'deffn 'texinfo-end 'texinfo-end-defun)
-(put 'deffn 'texinfo-defun-type '('deffn-type nil))
-(put 'deffnx 'texinfo-defun-type '('deffn-type nil))
+(put 'deffn 'texinfo-defun-type '(deffn-type nil))
+(put 'deffnx 'texinfo-defun-type '(deffn-type nil))
 (put 'deffn 'texinfo-defun-index 'texinfo-findex)
 (put 'deffnx 'texinfo-defun-index 'texinfo-findex)
 
 (put 'defun 'texinfo-format 'texinfo-format-defun)
 (put 'defunx 'texinfo-format 'texinfo-format-defunx)
 (put 'defun 'texinfo-end 'texinfo-end-defun)
-(put 'defun 'texinfo-defun-type '('defun-type "Function"))
-(put 'defunx 'texinfo-defun-type '('defun-type "Function"))
+(put 'defun 'texinfo-defun-type '(defun-type "Function"))
+(put 'defunx 'texinfo-defun-type '(defun-type "Function"))
 (put 'defun 'texinfo-defun-index 'texinfo-findex)
 (put 'defunx 'texinfo-defun-index 'texinfo-findex)
 
 (put 'defmac 'texinfo-format 'texinfo-format-defun)
 (put 'defmacx 'texinfo-format 'texinfo-format-defunx)
 (put 'defmac 'texinfo-end 'texinfo-end-defun)
-(put 'defmac 'texinfo-defun-type '('defun-type "Macro"))
-(put 'defmacx 'texinfo-defun-type '('defun-type "Macro"))
+(put 'defmac 'texinfo-defun-type '(defun-type "Macro"))
+(put 'defmacx 'texinfo-defun-type '(defun-type "Macro"))
 (put 'defmac 'texinfo-defun-index 'texinfo-findex)
 (put 'defmacx 'texinfo-defun-index 'texinfo-findex)
 
 (put 'defspec 'texinfo-format 'texinfo-format-defun)
 (put 'defspecx 'texinfo-format 'texinfo-format-defunx)
 (put 'defspec 'texinfo-end 'texinfo-end-defun)
-(put 'defspec 'texinfo-defun-type '('defun-type "Special form"))
-(put 'defspecx 'texinfo-defun-type '('defun-type "Special form"))
+(put 'defspec 'texinfo-defun-type '(defun-type "Special form"))
+(put 'defspecx 'texinfo-defun-type '(defun-type "Special form"))
 (put 'defspec 'texinfo-defun-index 'texinfo-findex)
 (put 'defspecx 'texinfo-defun-index 'texinfo-findex)
 
 (put 'defvr 'texinfo-format 'texinfo-format-defun)
 (put 'defvrx 'texinfo-format 'texinfo-format-defunx)
 (put 'defvr 'texinfo-end 'texinfo-end-defun)
-(put 'defvr 'texinfo-defun-type '('deffn-type nil))
-(put 'defvrx 'texinfo-defun-type '('deffn-type nil))
+(put 'defvr 'texinfo-defun-type '(deffn-type nil))
+(put 'defvrx 'texinfo-defun-type '(deffn-type nil))
 (put 'defvr 'texinfo-defun-index 'texinfo-vindex)
 (put 'defvrx 'texinfo-defun-index 'texinfo-vindex)
 
 (put 'defvar 'texinfo-format 'texinfo-format-defun)
 (put 'defvarx 'texinfo-format 'texinfo-format-defunx)
 (put 'defvar 'texinfo-end 'texinfo-end-defun)
-(put 'defvar 'texinfo-defun-type '('defun-type "Variable"))
-(put 'defvarx 'texinfo-defun-type '('defun-type "Variable"))
+(put 'defvar 'texinfo-defun-type '(defun-type "Variable"))
+(put 'defvarx 'texinfo-defun-type '(defun-type "Variable"))
 (put 'defvar 'texinfo-defun-index 'texinfo-vindex)
 (put 'defvarx 'texinfo-defun-index 'texinfo-vindex)
 
 (put 'defconst 'texinfo-format 'texinfo-format-defun)
 (put 'defconstx 'texinfo-format 'texinfo-format-defunx)
 (put 'defconst 'texinfo-end 'texinfo-end-defun)
-(put 'defconst 'texinfo-defun-type '('defun-type "Constant"))
-(put 'defconstx 'texinfo-defun-type '('defun-type "Constant"))
+(put 'defconst 'texinfo-defun-type '(defun-type "Constant"))
+(put 'defconstx 'texinfo-defun-type '(defun-type "Constant"))
 (put 'defconst 'texinfo-defun-index 'texinfo-vindex)
 (put 'defconstx 'texinfo-defun-index 'texinfo-vindex)
 
 (put 'defcmd 'texinfo-format 'texinfo-format-defun)
 (put 'defcmdx 'texinfo-format 'texinfo-format-defunx)
 (put 'defcmd 'texinfo-end 'texinfo-end-defun)
-(put 'defcmd 'texinfo-defun-type '('defun-type "Command"))
-(put 'defcmdx 'texinfo-defun-type '('defun-type "Command"))
+(put 'defcmd 'texinfo-defun-type '(defun-type "Command"))
+(put 'defcmdx 'texinfo-defun-type '(defun-type "Command"))
 (put 'defcmd 'texinfo-defun-index 'texinfo-findex)
 (put 'defcmdx 'texinfo-defun-index 'texinfo-findex)
 
 (put 'defopt 'texinfo-format 'texinfo-format-defun)
 (put 'defoptx 'texinfo-format 'texinfo-format-defunx)
 (put 'defopt 'texinfo-end 'texinfo-end-defun)
-(put 'defopt 'texinfo-defun-type '('defun-type "User Option"))
-(put 'defoptx 'texinfo-defun-type '('defun-type "User Option"))
+(put 'defopt 'texinfo-defun-type '(defun-type "User Option"))
+(put 'defoptx 'texinfo-defun-type '(defun-type "User Option"))
 (put 'defopt 'texinfo-defun-index 'texinfo-vindex)
 (put 'defoptx 'texinfo-defun-index 'texinfo-vindex)
 
 (put 'deftp 'texinfo-format 'texinfo-format-defun)
 (put 'deftpx 'texinfo-format 'texinfo-format-defunx)
 (put 'deftp 'texinfo-end 'texinfo-end-defun)
-(put 'deftp 'texinfo-defun-type '('deftp-type nil))
-(put 'deftpx 'texinfo-defun-type '('deftp-type nil))
+(put 'deftp 'texinfo-defun-type '(deftp-type nil))
+(put 'deftpx 'texinfo-defun-type '(deftp-type nil))
 (put 'deftp 'texinfo-defun-index 'texinfo-tindex)
 (put 'deftpx 'texinfo-defun-index 'texinfo-tindex)
 
@@ -3857,32 +3858,32 @@ Default is to leave paragraph indentation as is."
 (put 'defop 'texinfo-format 'texinfo-format-defun)
 (put 'defopx 'texinfo-format 'texinfo-format-defunx)
 (put 'defop 'texinfo-end 'texinfo-end-defun)
-(put 'defop 'texinfo-defun-type '('defop-type nil))
-(put 'defopx 'texinfo-defun-type '('defop-type nil))
+(put 'defop 'texinfo-defun-type '(defop-type nil))
+(put 'defopx 'texinfo-defun-type '(defop-type nil))
 (put 'defop 'texinfo-defun-index 'texinfo-findex)
 (put 'defopx 'texinfo-defun-index 'texinfo-findex)
 
 (put 'defmethod 'texinfo-format 'texinfo-format-defun)
 (put 'defmethodx 'texinfo-format 'texinfo-format-defunx)
 (put 'defmethod 'texinfo-end 'texinfo-end-defun)
-(put 'defmethod 'texinfo-defun-type '('defmethod-type "Method"))
-(put 'defmethodx 'texinfo-defun-type '('defmethod-type "Method"))
+(put 'defmethod 'texinfo-defun-type '(defmethod-type "Method"))
+(put 'defmethodx 'texinfo-defun-type '(defmethod-type "Method"))
 (put 'defmethod 'texinfo-defun-index 'texinfo-findex)
 (put 'defmethodx 'texinfo-defun-index 'texinfo-findex)
 
 (put 'defcv 'texinfo-format 'texinfo-format-defun)
 (put 'defcvx 'texinfo-format 'texinfo-format-defunx)
 (put 'defcv 'texinfo-end 'texinfo-end-defun)
-(put 'defcv 'texinfo-defun-type '('defop-type nil))
-(put 'defcvx 'texinfo-defun-type '('defop-type nil))
+(put 'defcv 'texinfo-defun-type '(defop-type nil))
+(put 'defcvx 'texinfo-defun-type '(defop-type nil))
 (put 'defcv 'texinfo-defun-index 'texinfo-vindex)
 (put 'defcvx 'texinfo-defun-index 'texinfo-vindex)
 
 (put 'defivar 'texinfo-format 'texinfo-format-defun)
 (put 'defivarx 'texinfo-format 'texinfo-format-defunx)
 (put 'defivar 'texinfo-end 'texinfo-end-defun)
-(put 'defivar 'texinfo-defun-type '('defmethod-type "Instance variable"))
-(put 'defivarx 'texinfo-defun-type '('defmethod-type "Instance variable"))
+(put 'defivar 'texinfo-defun-type '(defmethod-type "Instance variable"))
+(put 'defivarx 'texinfo-defun-type '(defmethod-type "Instance variable"))
 (put 'defivar 'texinfo-defun-index 'texinfo-vindex)
 (put 'defivarx 'texinfo-defun-index 'texinfo-vindex)
 
@@ -3891,32 +3892,32 @@ Default is to leave paragraph indentation as is."
 (put 'deftypefn 'texinfo-format 'texinfo-format-defun)
 (put 'deftypefnx 'texinfo-format 'texinfo-format-defunx)
 (put 'deftypefn 'texinfo-end 'texinfo-end-defun)
-(put 'deftypefn 'texinfo-defun-type '('deftypefn-type nil))
-(put 'deftypefnx 'texinfo-defun-type '('deftypefn-type nil))
+(put 'deftypefn 'texinfo-defun-type '(deftypefn-type nil))
+(put 'deftypefnx 'texinfo-defun-type '(deftypefn-type nil))
 (put 'deftypefn 'texinfo-defun-index 'texinfo-findex)
 (put 'deftypefnx 'texinfo-defun-index 'texinfo-findex)
 
 (put 'deftypefun 'texinfo-format 'texinfo-format-defun)
 (put 'deftypefunx 'texinfo-format 'texinfo-format-defunx)
 (put 'deftypefun 'texinfo-end 'texinfo-end-defun)
-(put 'deftypefun 'texinfo-defun-type '('deftypefun-type "Function"))
-(put 'deftypefunx 'texinfo-defun-type '('deftypefun-type "Function"))
+(put 'deftypefun 'texinfo-defun-type '(deftypefun-type "Function"))
+(put 'deftypefunx 'texinfo-defun-type '(deftypefun-type "Function"))
 (put 'deftypefun 'texinfo-defun-index 'texinfo-findex)
 (put 'deftypefunx 'texinfo-defun-index 'texinfo-findex)
 
 (put 'deftypevr 'texinfo-format 'texinfo-format-defun)
 (put 'deftypevrx 'texinfo-format 'texinfo-format-defunx)
 (put 'deftypevr 'texinfo-end 'texinfo-end-defun)
-(put 'deftypevr 'texinfo-defun-type '('deftypefn-type nil))
-(put 'deftypevrx 'texinfo-defun-type '('deftypefn-type nil))
+(put 'deftypevr 'texinfo-defun-type '(deftypefn-type nil))
+(put 'deftypevrx 'texinfo-defun-type '(deftypefn-type nil))
 (put 'deftypevr 'texinfo-defun-index 'texinfo-vindex)
 (put 'deftypevrx 'texinfo-defun-index 'texinfo-vindex)
 
 (put 'deftypevar 'texinfo-format 'texinfo-format-defun)
 (put 'deftypevarx 'texinfo-format 'texinfo-format-defunx)
 (put 'deftypevar 'texinfo-end 'texinfo-end-defun)
-(put 'deftypevar 'texinfo-defun-type '('deftypevar-type "Variable"))
-(put 'deftypevarx 'texinfo-defun-type '('deftypevar-type "Variable"))
+(put 'deftypevar 'texinfo-defun-type '(deftypevar-type "Variable"))
+(put 'deftypevarx 'texinfo-defun-type '(deftypevar-type "Variable"))
 (put 'deftypevar 'texinfo-defun-index 'texinfo-vindex)
 (put 'deftypevarx 'texinfo-defun-index 'texinfo-vindex)
 
@@ -3943,7 +3944,8 @@ Default is to leave paragraph indentation as is."
   "Clear the value of the flag."
   (let* ((arg (texinfo-parse-arg-discard))
          (flag (car (read-from-string arg)))
-         (value (substring arg (cdr (read-from-string arg)))))
+         ;; (value (substring arg (cdr (read-from-string arg))))
+         )
     (put flag 'texinfo-whether-setp 'flag-cleared)
     (put flag 'texinfo-set-value "")))
 
@@ -4043,7 +4045,7 @@ the @ifeq command."
   (goto-char texinfo-command-end)
   (let* ((case-fold-search t)
          (stop (save-excursion (forward-sexp 1) (point)))
-        start end
+        start ;; end
         ;; @ifeq{arg1, arg2, @command{optional-args}}
         (arg1
          (progn
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el
index 278cd0c..750a33d 100644
--- a/lisp/textmodes/texinfo.el
+++ b/lisp/textmodes/texinfo.el
@@ -1,4 +1,4 @@
-;;; texinfo.el --- major mode for editing Texinfo files
+;;; texinfo.el --- major mode for editing Texinfo files  -*- lexical-binding: 
t; -*-
 
 ;; Copyright (C) 1985, 1988-1993, 1996-1997, 2000-2021 Free Software
 ;; Foundation, Inc.
@@ -373,7 +373,7 @@ Subexpression 1 is what goes into the corresponding `@end' 
statement.")
     ("@\\(end\\|itemx?\\) +\\(.+\\)" 2 font-lock-keyword-face keep)
     ;; (,texinfo-environment-regexp
     ;;  1 (texinfo-clone-environment (match-beginning 1) (match-end 1)) keep)
-    (,(concat "^@" (regexp-opt (mapcar 'car texinfo-section-list) t)
+    (,(concat "^@" (regexp-opt (mapcar #'car texinfo-section-list) t)
               ".*\n")
      0 'texinfo-heading t))
   "Additional expressions to highlight in Texinfo mode.")
@@ -400,19 +400,21 @@ Subexpression 1 is what goes into the corresponding 
`@end' statement.")
 
 ;;; Keys common both to Texinfo mode and to TeX shell.
 
+(declare-function tex-show-print-queue "tex-mode" ())
+
 (defun texinfo-define-common-keys (keymap)
   "Define the keys both in Texinfo mode and in the texinfo-tex-shell."
-  (define-key keymap "\C-c\C-t\C-k"    'tex-kill-job)
-  (define-key keymap "\C-c\C-t\C-x"    'texinfo-quit-job)
-  (define-key keymap "\C-c\C-t\C-l"    'tex-recenter-output-buffer)
-  (define-key keymap "\C-c\C-t\C-d"    'texinfo-delete-from-print-queue)
-  (define-key keymap "\C-c\C-t\C-q"    'tex-show-print-queue)
-  (define-key keymap "\C-c\C-t\C-p"    'texinfo-tex-print)
-  (define-key keymap "\C-c\C-t\C-v"    'texinfo-tex-view)
-  (define-key keymap "\C-c\C-t\C-i"    'texinfo-texindex)
-
-  (define-key keymap "\C-c\C-t\C-r"    'texinfo-tex-region)
-  (define-key keymap "\C-c\C-t\C-b"    'texinfo-tex-buffer))
+  (define-key keymap "\C-c\C-t\C-k"    #'tex-kill-job)
+  (define-key keymap "\C-c\C-t\C-x"    #'texinfo-quit-job)
+  (define-key keymap "\C-c\C-t\C-l"    #'tex-recenter-output-buffer)
+  (define-key keymap "\C-c\C-t\C-d"    #'texinfo-delete-from-print-queue)
+  (define-key keymap "\C-c\C-t\C-q"    #'tex-show-print-queue)
+  (define-key keymap "\C-c\C-t\C-p"    #'texinfo-tex-print)
+  (define-key keymap "\C-c\C-t\C-v"    #'texinfo-tex-view)
+  (define-key keymap "\C-c\C-t\C-i"    #'texinfo-texindex)
+
+  (define-key keymap "\C-c\C-t\C-r"    #'texinfo-tex-region)
+  (define-key keymap "\C-c\C-t\C-b"    #'texinfo-tex-buffer))
 
 ;; Mode documentation displays commands in reverse order
 ;; from how they are listed in the texinfo-mode-map.
@@ -423,68 +425,68 @@ Subexpression 1 is what goes into the corresponding 
`@end' statement.")
     ;; bindings for `texnfo-tex.el'
     (texinfo-define-common-keys map)
 
-    (define-key map "\"" 'texinfo-insert-quote)
+    (define-key map "\"" #'texinfo-insert-quote)
 
     ;; bindings for `makeinfo.el'
-    (define-key map "\C-c\C-m\C-k" 'kill-compilation)
+    (define-key map "\C-c\C-m\C-k" #'kill-compilation)
     (define-key map "\C-c\C-m\C-l"
-      'makeinfo-recenter-compilation-buffer)
-    (define-key map "\C-c\C-m\C-r" 'makeinfo-region)
-    (define-key map "\C-c\C-m\C-b" 'makeinfo-buffer)
+      #'makeinfo-recenter-compilation-buffer)
+    (define-key map "\C-c\C-m\C-r" #'makeinfo-region)
+    (define-key map "\C-c\C-m\C-b" #'makeinfo-buffer)
 
     ;; bindings for `texinfmt.el'
-    (define-key map "\C-c\C-e\C-r"    'texinfo-format-region)
-    (define-key map "\C-c\C-e\C-b"    'texinfo-format-buffer)
+    (define-key map "\C-c\C-e\C-r"    #'texinfo-format-region)
+    (define-key map "\C-c\C-e\C-b"    #'texinfo-format-buffer)
 
     ;; AUCTeX-like bindings
-    (define-key map "\e\r"             'texinfo-insert-@item)
+    (define-key map "\e\r"             #'texinfo-insert-@item)
 
     ;; bindings for updating nodes and menus
 
-    (define-key map "\C-c\C-um"   'texinfo-master-menu)
+    (define-key map "\C-c\C-um"   #'texinfo-master-menu)
 
-    (define-key map "\C-c\C-u\C-m"   'texinfo-make-menu)
-    (define-key map "\C-c\C-u\C-n"   'texinfo-update-node)
-    (define-key map "\C-c\C-u\C-e"   'texinfo-every-node-update)
-    (define-key map "\C-c\C-u\C-a"   'texinfo-all-menus-update)
+    (define-key map "\C-c\C-u\C-m"   #'texinfo-make-menu)
+    (define-key map "\C-c\C-u\C-n"   #'texinfo-update-node)
+    (define-key map "\C-c\C-u\C-e"   #'texinfo-every-node-update)
+    (define-key map "\C-c\C-u\C-a"   #'texinfo-all-menus-update)
 
-    (define-key map "\C-c\C-s"     'texinfo-show-structure)
+    (define-key map "\C-c\C-s"     #'texinfo-show-structure)
 
-    (define-key map "\C-c}"          'up-list)
+    (define-key map "\C-c}"          #'up-list)
     ;; FIXME: This is often used for "close block" aka texinfo-insert-@end.
-    (define-key map "\C-c]"          'up-list)
-    (define-key map "\C-c/"         'texinfo-insert-@end)
-    (define-key map "\C-c{"            'texinfo-insert-braces)
+    (define-key map "\C-c]"          #'up-list)
+    (define-key map "\C-c/"         #'texinfo-insert-@end)
+    (define-key map "\C-c{"            #'texinfo-insert-braces)
 
     ;; bindings for inserting strings
-    (define-key map "\C-c\C-o"     'texinfo-insert-block)
-    (define-key map "\C-c\C-c\C-d" 'texinfo-start-menu-description)
-    (define-key map "\C-c\C-c\C-s" 'texinfo-insert-@strong)
-    (define-key map "\C-c\C-c\C-e" 'texinfo-insert-@emph)
-
-    (define-key map "\C-c\C-cv"    'texinfo-insert-@var)
-    (define-key map "\C-c\C-cu"    'texinfo-insert-@uref)
-    (define-key map "\C-c\C-ct"    'texinfo-insert-@table)
-    (define-key map "\C-c\C-cs"    'texinfo-insert-@samp)
-    (define-key map "\C-c\C-cr"    'texinfo-insert-dwim-@ref)
-    (define-key map "\C-c\C-cq"    'texinfo-insert-@quotation)
-    (define-key map "\C-c\C-co"    'texinfo-insert-@noindent)
-    (define-key map "\C-c\C-cn"    'texinfo-insert-@node)
-    (define-key map "\C-c\C-cm"    'texinfo-insert-@email)
-    (define-key map "\C-c\C-ck"    'texinfo-insert-@kbd)
-    (define-key map "\C-c\C-ci"    'texinfo-insert-@item)
-    (define-key map "\C-c\C-cf"    'texinfo-insert-@file)
-    (define-key map "\C-c\C-cx"    'texinfo-insert-@example)
-    (define-key map "\C-c\C-ce"    'texinfo-insert-@end)
-    (define-key map "\C-c\C-cd"    'texinfo-insert-@dfn)
-    (define-key map "\C-c\C-cc"    'texinfo-insert-@code)
+    (define-key map "\C-c\C-o"     #'texinfo-insert-block)
+    (define-key map "\C-c\C-c\C-d" #'texinfo-start-menu-description)
+    (define-key map "\C-c\C-c\C-s" #'texinfo-insert-@strong)
+    (define-key map "\C-c\C-c\C-e" #'texinfo-insert-@emph)
+
+    (define-key map "\C-c\C-cv"    #'texinfo-insert-@var)
+    (define-key map "\C-c\C-cu"    #'texinfo-insert-@uref)
+    (define-key map "\C-c\C-ct"    #'texinfo-insert-@table)
+    (define-key map "\C-c\C-cs"    #'texinfo-insert-@samp)
+    (define-key map "\C-c\C-cr"    #'texinfo-insert-dwim-@ref)
+    (define-key map "\C-c\C-cq"    #'texinfo-insert-@quotation)
+    (define-key map "\C-c\C-co"    #'texinfo-insert-@noindent)
+    (define-key map "\C-c\C-cn"    #'texinfo-insert-@node)
+    (define-key map "\C-c\C-cm"    #'texinfo-insert-@email)
+    (define-key map "\C-c\C-ck"    #'texinfo-insert-@kbd)
+    (define-key map "\C-c\C-ci"    #'texinfo-insert-@item)
+    (define-key map "\C-c\C-cf"    #'texinfo-insert-@file)
+    (define-key map "\C-c\C-cx"    #'texinfo-insert-@example)
+    (define-key map "\C-c\C-ce"    #'texinfo-insert-@end)
+    (define-key map "\C-c\C-cd"    #'texinfo-insert-@dfn)
+    (define-key map "\C-c\C-cc"    #'texinfo-insert-@code)
 
     ;; bindings for environment movement
-    (define-key map "\C-c."        'texinfo-to-environment-bounds)
-    (define-key map "\C-c\C-c\C-f" 'texinfo-next-environment-end)
-    (define-key map "\C-c\C-c\C-b" 'texinfo-previous-environment-end)
-    (define-key map "\C-c\C-c\C-n" 'texinfo-next-environment-start)
-    (define-key map "\C-c\C-c\C-p" 'texinfo-previous-environment-start)
+    (define-key map "\C-c."        #'texinfo-to-environment-bounds)
+    (define-key map "\C-c\C-c\C-f" #'texinfo-next-environment-end)
+    (define-key map "\C-c\C-c\C-b" #'texinfo-previous-environment-end)
+    (define-key map "\C-c\C-c\C-n" #'texinfo-next-environment-start)
+    (define-key map "\C-c\C-c\C-p" #'texinfo-previous-environment-start)
     map))
 
 (easy-menu-define texinfo-mode-menu
@@ -624,7 +626,7 @@ value of `texinfo-mode-hook'."
              (mapcar (lambda (x) (cons (concat "@" (car x)) (cadr x)))
                      texinfo-section-list))
   (setq-local outline-regexp
-             (concat (regexp-opt (mapcar 'car outline-heading-alist) t)
+             (concat (regexp-opt (mapcar #'car outline-heading-alist) t)
                      "\\>"))
 
   (setq-local tex-start-of-header "%\\*\\*start")
@@ -893,7 +895,7 @@ A numeric argument says how many words the braces should 
surround.
 The default is not to surround any existing words with the braces."
   nil
   "@uref{" _ "}")
-(defalias 'texinfo-insert-@url 'texinfo-insert-@uref)
+(defalias 'texinfo-insert-@url #'texinfo-insert-@uref)
 
 ;;; Texinfo file structure
 
diff --git a/lisp/textmodes/texnfo-upd.el b/lisp/textmodes/texnfo-upd.el
index 04778ee..27807a9 100644
--- a/lisp/textmodes/texnfo-upd.el
+++ b/lisp/textmodes/texnfo-upd.el
@@ -1,4 +1,4 @@
-;;; texnfo-upd.el --- utilities for updating nodes and menus in Texinfo files
+;;; texnfo-upd.el --- utilities for updating nodes and menus in Texinfo files  
-*- lexical-binding: t; -*-
 
 ;; Copyright (C) 1989-1992, 2001-2021 Free Software Foundation, Inc.
 
@@ -420,7 +420,7 @@ of the node if one is found; else do not move point."
                 "\\|"                      ; or
                 "\\(^@ifnottex[ ]*\n\\)"   ; ifnottex line, if any
                 "\\)?"                     ; end of expression
-                (eval (cdr (assoc level texinfo-update-menu-lower-regexps))))
+                (eval (cdr (assoc level texinfo-update-menu-lower-regexps)) t))
                ;; the next higher level node marks the end of this
                ;; section, and no lower level node will be found beyond
                ;; this position even if region-end is farther off
@@ -454,7 +454,7 @@ if the match is found there, the value is t and point does 
not move."
              "\\|"                           ; or
              "\\(^@ifnottex[ ]*\n\\)"        ; ifnottex line, if any
              "\\)?"                          ; end of expression
-             (eval (cdr (assoc level texinfo-update-menu-higher-regexps))))
+             (eval (cdr (assoc level texinfo-update-menu-higher-regexps)) t))
             region-end t)
        (beginning-of-line) t)))))
 
@@ -505,7 +505,7 @@ The function finds entries of the same type.  Thus 
`subsections' and
          "\\(^@ifnottex[ ]*\n\\)"        ; ifnottex line, if any
           "\\)?"                          ; end of expression
          (eval
-          (cdr (assoc level texinfo-update-menu-same-level-regexps))))
+          (cdr (assoc level texinfo-update-menu-same-level-regexps)) t))
         search-end
         t)
        (goto-char (match-beginning 1)))))
@@ -742,7 +742,7 @@ You will need to edit the inserted text since a useful 
description
 complements the node name rather than repeats it as a title does."
 
   (interactive)
-  (let (beginning end node-name title)
+  (let (beginning node-name title) ;; end
     (save-excursion
       (beginning-of-line)
       (if (search-forward "* " (line-end-position) t)
@@ -1219,7 +1219,7 @@ Only argument is a string of the general type of section."
          "\\(^@ifnottex[ ]*\n\\)"        ; ifnottex line, if any
           "\\)?"                          ; end of expression
          (eval
-          (cdr (assoc level texinfo-update-menu-higher-regexps))))
+          (cdr (assoc level texinfo-update-menu-higher-regexps)) t))
         nil
         'goto-beginning)
        (point))))))
@@ -1243,7 +1243,7 @@ string of the general type of section."
             "\\)?"                        ; end of expression
            (eval
             ;; Never finds end of level above chapter so goes to end.
-            (cdr (assoc level texinfo-update-menu-higher-regexps))))
+            (cdr (assoc level texinfo-update-menu-higher-regexps)) t))
           nil
           'goto-end)
          (match-beginning 1)
@@ -1430,7 +1430,7 @@ will be at some level higher in the Texinfo file.  The 
fourth argument
                   "\\(^@ifnottex[ ]*\n\\)"
                   "\\)?")
                 (eval
-                 (cdr (assoc level texinfo-update-menu-same-level-regexps))))
+                 (cdr (assoc level texinfo-update-menu-same-level-regexps)) t))
                end
                t)
               'normal
@@ -1451,7 +1451,7 @@ will be at some level higher in the Texinfo file.  The 
fourth argument
                   "\\(^@ifnottex[ ]*\n\\)"
                   "\\)?")
                 (eval
-                 (cdr (assoc level texinfo-update-menu-same-level-regexps)))
+                 (cdr (assoc level texinfo-update-menu-same-level-regexps)) t)
                 "\\|"
                 ;; Match node line.
                 "\\(^@node\\).*\n"
@@ -1465,7 +1465,7 @@ will be at some level higher in the Texinfo file.  The 
fourth argument
                   "\\(^@ifnottex[ ]*\n\\)"
                   "\\)?")
                 (eval
-                 (cdr (assoc level texinfo-update-menu-higher-regexps)))
+                 (cdr (assoc level texinfo-update-menu-higher-regexps)) t)
                 "\\|"
                 ;; Handle `Top' node specially.
                 "^@node [ \t]*top[ \t]*\\(,\\|$\\)"
@@ -1489,7 +1489,7 @@ will be at some level higher in the Texinfo file.  The 
fourth argument
                   "\\|"
                   "\\(^@ifnottex[ ]*\n\\)"
                   "\\)?")
-                (eval (cdr (assoc level texinfo-update-menu-higher-regexps)))
+                (eval (cdr (assoc level texinfo-update-menu-higher-regexps)) t)
                 "\\|"
                 ;; Handle `Top' node specially.
                 "^@node [ \t]*top[ \t]*\\(,\\|$\\)"
@@ -1662,7 +1662,7 @@ or `Up' pointer."
             'no-pointer))
          ((eq direction 'up)
           (if (re-search-backward
-               (eval (cdr (assoc level texinfo-update-menu-higher-regexps)))
+               (eval (cdr (assoc level texinfo-update-menu-higher-regexps)) t)
                (point-min)
                t)
               'normal
@@ -1686,7 +1686,7 @@ node names in pre-existing `@node' lines that lack names."
   ;; Use marker; after inserting node lines, leave point at end of
   ;; region and mark at beginning.
 
-  (let (beginning-marker end-marker title last-section-position)
+  (let (end-marker title last-section-position) ;; beginning-marker
 
     ;; Save current position on mark ring and set mark to end.
     (push-mark end t)
@@ -2043,8 +2043,8 @@ chapter."
 
   (let* ((included-file-list (texinfo-multi-file-included-list outer-file))
         (files included-file-list)
-        next-node-name
-        previous-node-name
+        ;; next-node-name
+        ;; previous-node-name
         ;; Update the pointers and collect the names of the nodes and titles
         (main-menu-list (texinfo-multi-file-update files update-everything)))
 
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index 7836bd4..ffeb9e6 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -69,7 +69,7 @@
 
 (defvar text-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "\e\t" 'ispell-complete-word)
+    (define-key map "\e\t" #'ispell-complete-word)
     map)
   "Keymap for `text-mode'.
 Many other modes, such as `mail-mode', `outline-mode' and `indented-text-mode',
@@ -141,7 +141,7 @@ Turning on Paragraph-Indent minor mode runs the normal hook
     (remove-function (local 'indent-line-function)
                      #'indent-to-left-margin)))
 
-(defalias 'indented-text-mode 'text-mode)
+(defalias 'indented-text-mode #'text-mode)
 
 ;; This can be made a no-op once all modes that use text-mode-hook
 ;; are "derived" from text-mode.  (As of 2015/04, and probably well before,
diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el
index 1d90562..069c8e3 100644
--- a/lisp/textmodes/tildify.el
+++ b/lisp/textmodes/tildify.el
@@ -289,7 +289,7 @@ variable.  For example, for an XML file one might use:
   (setq-local tildify-foreach-region-function
     (apply-partially \\='tildify-foreach-ignore-environments
                      \\='((\"<! *--\" . \"-- *>\") (\"<\" . \">\"))))"
-  (let ((beg-re (concat "\\(?:" (mapconcat 'car pairs "\\)\\|\\(?:") "\\)"))
+  (let ((beg-re (concat "\\(?:" (mapconcat #'car pairs "\\)\\|\\(?:") "\\)"))
         p end-re)
     (save-excursion
       (save-restriction
@@ -499,8 +499,8 @@ variable will be set to the representation."
                            "mode won't have any effect, disabling.")))
         (setq tildify-mode nil))))
   (if tildify-mode
-      (add-hook 'post-self-insert-hook 'tildify-space nil t)
-    (remove-hook 'post-self-insert-hook 'tildify-space t)))
+      (add-hook 'post-self-insert-hook #'tildify-space nil t)
+    (remove-hook 'post-self-insert-hook #'tildify-space t)))
 
 
 ;;; *** Announce ***
diff --git a/lisp/textmodes/two-column.el b/lisp/textmodes/two-column.el
index 9c0ed8f..6c3bacc 100644
--- a/lisp/textmodes/two-column.el
+++ b/lisp/textmodes/two-column.el
@@ -1,4 +1,4 @@
-;;; two-column.el --- minor mode for editing of two-column text
+;;; two-column.el --- minor mode for editing of two-column text  -*- 
lexical-binding: t; -*-
 
 ;; Copyright (C) 1992-1995, 2001-2021 Free Software Foundation, Inc.
 
@@ -165,10 +165,10 @@ minus this value."
 
 (defvar 2C-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "2" '2C-two-columns)
-    (define-key map [f2] '2C-two-columns)
-    (define-key map "b" '2C-associate-buffer)
-    (define-key map "s" '2C-split)
+    (define-key map "2" #'2C-two-columns)
+    (define-key map [f2] #'2C-two-columns)
+    (define-key map "b" #'2C-associate-buffer)
+    (define-key map "s" #'2C-split)
     map)
   "Keymap for commands for setting up two-column mode.")
 
@@ -178,19 +178,19 @@ minus this value."
 ;; This one is for historical reasons and simple keyboards, it is not
 ;; at all mnemonic.  All usual sequences containing 2 were used, and
 ;; f2 could not be set up in a standard way under Emacs 18.
-;;;###autoload (global-set-key "\C-x6" '2C-command)
+;;;###autoload (global-set-key "\C-x6" #'2C-command)
 
-;;;###autoload (global-set-key [f2] '2C-command)
+;;;###autoload (global-set-key [f2] #'2C-command)
 
 (defvar 2C-minor-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "1" '2C-merge)
-    (define-key map "d" '2C-dissociate)
-    (define-key map "o" '2C-associated-buffer)
-    (define-key map "\^m" '2C-newline)
-    (define-key map "|" '2C-toggle-autoscroll)
-    (define-key map "{" '2C-shrink-window-horizontally)
-    (define-key map "}" '2C-enlarge-window-horizontally)
+    (define-key map "1" #'2C-merge)
+    (define-key map "d" #'2C-dissociate)
+    (define-key map "o" #'2C-associated-buffer)
+    (define-key map "\^m" #'2C-newline)
+    (define-key map "|" #'2C-toggle-autoscroll)
+    (define-key map "{" #'2C-shrink-window-horizontally)
+    (define-key map "}" #'2C-enlarge-window-horizontally)
     map)
   "Keymap for commands for use in two-column mode.")
 
@@ -275,7 +275,7 @@ some prefix.
 The appearance of the screen can be customized by the variables
 `2C-window-width', `2C-beyond-fill-column', `2C-mode-line-format' and
 `truncate-partial-width-windows'."
-  (add-hook 'post-command-hook '2C-autoscroll nil t)
+  (add-hook 'post-command-hook #'2C-autoscroll nil t)
   (setq fill-column (- 2C-window-width
                       2C-beyond-fill-column)
        mode-line-format 2C-mode-line-format



reply via email to

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