emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/rec-mode 12d864d 14/14: Merge remote-tracking branch 'u


From: Stefan Monnier
Subject: [elpa] externals/rec-mode 12d864d 14/14: Merge remote-tracking branch 'upstream/rec-mode/main' into externals/rec-mode
Date: Sat, 27 Mar 2021 13:30:43 -0400 (EDT)

branch: externals/rec-mode
commit 12d864dab007b5a21bc0c290a9bed58d78ab1894
Merge: e6f4d94 6044b89
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Merge remote-tracking branch 'upstream/rec-mode/main' into 
externals/rec-mode
---
 .elpaignore          |    1 +
 .gitignore           |    5 +
 aux/gendocs.sh       |  510 ++++++++++++++++
 aux/gendocs_template |  101 ++++
 ob-rec.el            |    3 +-
 rec-mode.el          | 1629 ++++++++++++++++++++++++++++++++++++++------------
 rec-mode.info        | 1338 +++++++++++++++++++++++++++--------------
 rec-mode.texi        |  369 ++++++++++--
 8 files changed, 3071 insertions(+), 885 deletions(-)

diff --git a/.elpaignore b/.elpaignore
new file mode 100644
index 0000000..0af7029
--- /dev/null
+++ b/.elpaignore
@@ -0,0 +1 @@
+aux/
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..92731fa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+*.elc
+
+# ELPA-generated files
+/rec-mode-autoloads.el
+/rec-mode-pkg.el
diff --git a/aux/gendocs.sh b/aux/gendocs.sh
new file mode 100755
index 0000000..dec8eb9
--- /dev/null
+++ b/aux/gendocs.sh
@@ -0,0 +1,510 @@
+#!/bin/sh -e
+# gendocs.sh -- generate a GNU manual in many formats.  This script is
+#   mentioned in maintain.texi.  See the help message below for usage details.
+
+scriptversion=2020-01-01.00
+
+# Copyright 2003-2020 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+#
+# Original author: Mohit Agarwal.
+# Send bug reports and any other correspondence to bug-gnulib@gnu.org.
+#
+# The latest version of this script, and the companion template, is
+# available from the Gnulib repository:
+#
+# https://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/gendocs.sh
+# https://git.savannah.gnu.org/cgit/gnulib.git/tree/doc/gendocs_template
+
+# TODO:
+# - image importing was only implemented for HTML generated by
+#   makeinfo.  But it should be simple enough to adjust.
+# - images are not imported in the source tarball.  All the needed
+#   formats (PDF, PNG, etc.) should be included.
+
+prog=`basename "$0"`
+srcdir=`pwd`
+
+scripturl="https://git.savannah.gnu.org/cgit/gnulib.git/plain/build-aux/gendocs.sh";
+templateurl="https://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/gendocs_template";
+
+: ${SETLANG="env LANG= LC_MESSAGES= LC_ALL= LANGUAGE="}
+: ${MAKEINFO="makeinfo"}
+: ${TEXI2DVI="texi2dvi"}
+: ${DOCBOOK2HTML="docbook2html"}
+: ${DOCBOOK2PDF="docbook2pdf"}
+: ${DOCBOOK2TXT="docbook2txt"}
+: ${GENDOCS_TEMPLATE_DIR="."}
+: ${PERL='perl'}
+: ${TEXI2HTML="texi2html"}
+unset CDPATH
+unset use_texi2html
+
+MANUAL_TITLE=
+PACKAGE=
+EMAIL=webmasters@gnu.org  # please override with --email
+commonarg= # passed to all makeinfo/texi2html invcations.
+dirargs=   # passed to all tools (-I dir).
+dirs=      # -I directories.
+htmlarg="--css-ref=/software/gnulib/manual.css -c TOP_NODE_UP_URL=/manual"
+default_htmlarg=true
+infoarg=--no-split
+generate_ascii=true
+generate_html=true
+generate_info=true
+generate_tex=true
+outdir=manual
+source_extra=
+split=node
+srcfile=
+texarg="-t @finalout"
+
+version="gendocs.sh $scriptversion
+
+Copyright 2020 Free Software Foundation, Inc.
+There is NO warranty.  You may redistribute this software
+under the terms of the GNU General Public License.
+For more information about these matters, see the files named COPYING."
+
+usage="Usage: $prog [OPTION]... PACKAGE MANUAL-TITLE
+
+Generate output in various formats from PACKAGE.texinfo (or .texi or
+.txi) source.  See the GNU Maintainers document for a more extensive
+discussion:
+  https://www.gnu.org/prep/maintain_toc.html
+
+Options:
+  --email ADR use ADR as contact in generated web pages; always give this.
+
+  -s SRCFILE   read Texinfo from SRCFILE, instead of PACKAGE.{texinfo|texi|txi}
+  -o OUTDIR    write files into OUTDIR, instead of manual/.
+  -I DIR       append DIR to the Texinfo search path.
+  --common ARG pass ARG in all invocations.
+  --html ARG   pass ARG to makeinfo or texi2html for HTML targets,
+                 instead of '$htmlarg'.
+  --info ARG   pass ARG to makeinfo for Info, instead of --no-split.
+  --no-ascii   skip generating the plain text output.
+  --no-html    skip generating the html output.
+  --no-info    skip generating the info output.
+  --no-tex     skip generating the dvi and pdf output.
+  --source ARG include ARG in tar archive of sources.
+  --split HOW  make split HTML by node, section, chapter; default node.
+  --tex ARG    pass ARG to texi2dvi for DVI and PDF, instead of -t @finalout.
+
+  --texi2html  use texi2html to make HTML target, with all split versions.
+  --docbook    convert through DocBook too (xml, txt, html, pdf).
+
+  --help       display this help and exit successfully.
+  --version    display version information and exit successfully.
+
+Simple example: $prog --email bug-gnu-emacs@gnu.org emacs \"GNU Emacs Manual\"
+
+Typical sequence:
+  cd PACKAGESOURCE/doc
+  wget \"$scripturl\"
+  wget \"$templateurl\"
+  $prog --email BUGLIST MANUAL \"GNU MANUAL - One-line description\"
+
+Output will be in a new subdirectory \"manual\" (by default;
+use -o OUTDIR to override).  Move all the new files into your web CVS
+tree, as explained in the Web Pages node of maintain.texi.
+
+Please use the --email ADDRESS option so your own bug-reporting
+address will be used in the generated HTML pages.
+
+MANUAL-TITLE is included as part of the HTML <title> of the overall
+manual/index.html file.  It should include the name of the package being
+documented.  manual/index.html is created by substitution from the file
+$GENDOCS_TEMPLATE_DIR/gendocs_template.  (Feel free to modify the
+generic template for your own purposes.)
+
+If you have several manuals, you'll need to run this script several
+times with different MANUAL values, specifying a different output
+directory with -o each time.  Then write (by hand) an overall index.html
+with links to them all.
+
+If a manual's Texinfo sources are spread across several directories,
+first copy or symlink all Texinfo sources into a single directory.
+(Part of the script's work is to make a tar.gz of the sources.)
+
+As implied above, by default monolithic Info files are generated.
+If you want split Info, or other Info options, use --info to override.
+
+You can set the environment variables MAKEINFO, TEXI2DVI, TEXI2HTML,
+and PERL to control the programs that get executed, and
+GENDOCS_TEMPLATE_DIR to control where the gendocs_template file is
+looked for.  With --docbook, the environment variables DOCBOOK2HTML,
+DOCBOOK2PDF, and DOCBOOK2TXT are also consulted.
+
+By default, makeinfo and texi2dvi are run in the default (English)
+locale, since that's the language of most Texinfo manuals.  If you
+happen to have a non-English manual and non-English web site, see the
+SETLANG setting in the source.
+
+Email bug reports or enhancement requests to bug-gnulib@gnu.org.
+"
+
+while test $# -gt 0; do
+  case $1 in
+    -s)          shift; srcfile=$1;;
+    -o)          shift; outdir=$1;;
+    -I)          shift; dirargs="$dirargs -I '$1'"; dirs="$dirs $1";;
+    --common)    shift; commonarg=$1;;
+    --docbook)   docbook=yes;;
+    --email)     shift; EMAIL=$1;;
+    --html)      shift; default_htmlarg=false; htmlarg=$1;;
+    --info)      shift; infoarg=$1;;
+    --no-ascii)  generate_ascii=false;;
+    --no-html)   generate_ascii=false;;
+    --no-info)   generate_info=false;;
+    --no-tex)    generate_tex=false;;
+    --source)    shift; source_extra=$1;;
+    --split)     shift; split=$1;;
+    --tex)       shift; texarg=$1;;
+    --texi2html) use_texi2html=1;;
+
+    --help)      echo "$usage"; exit 0;;
+    --version)   echo "$version"; exit 0;;
+    -*)
+      echo "$0: Unknown option \`$1'." >&2
+      echo "$0: Try \`--help' for more information." >&2
+      exit 1;;
+    *)
+      if test -z "$PACKAGE"; then
+        PACKAGE=$1
+      elif test -z "$MANUAL_TITLE"; then
+        MANUAL_TITLE=$1
+      else
+        echo "$0: extra non-option argument \`$1'." >&2
+        exit 1
+      fi;;
+  esac
+  shift
+done
+
+# makeinfo uses the dirargs, but texi2dvi doesn't.
+commonarg=" $dirargs $commonarg"
+
+# For most of the following, the base name is just $PACKAGE
+base=$PACKAGE
+
+if $default_htmlarg && test -n "$use_texi2html"; then
+  # The legacy texi2html doesn't support TOP_NODE_UP_URL
+  htmlarg="--css-ref=/software/gnulib/manual.css"
+fi
+
+if test -n "$srcfile"; then
+  # but here, we use the basename of $srcfile
+  base=`basename "$srcfile"`
+  case $base in
+    *.txi|*.texi|*.texinfo) base=`echo "$base"|sed 's/\.[texinfo]*$//'`;;
+  esac
+  PACKAGE=$base
+elif test -s "$srcdir/$PACKAGE.texinfo"; then
+  srcfile=$srcdir/$PACKAGE.texinfo
+elif test -s "$srcdir/$PACKAGE.texi"; then
+  srcfile=$srcdir/$PACKAGE.texi
+elif test -s "$srcdir/$PACKAGE.txi"; then
+  srcfile=$srcdir/$PACKAGE.txi
+else
+  echo "$0: cannot find .texinfo or .texi or .txi for $PACKAGE in $srcdir." >&2
+  exit 1
+fi
+
+if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then
+  echo "$0: cannot read $GENDOCS_TEMPLATE_DIR/gendocs_template." >&2
+  echo "$0: it is available from $templateurl." >&2
+  exit 1
+fi
+
+# Function to return size of $1 in something resembling kilobytes.
+calcsize()
+{
+  size=`ls -ksl $1 | awk '{print $1}'`
+  echo $size
+}
+
+# copy_images OUTDIR HTML-FILE...
+# -------------------------------
+# Copy all the images needed by the HTML-FILEs into OUTDIR.
+# Look for them in . and the -I directories; this is simpler than what
+# makeinfo supports with -I, but hopefully it will suffice.
+copy_images()
+{
+  local odir
+  odir=$1
+  shift
+  $PERL -n -e "
+BEGIN {
+  \$me = '$prog';
+  \$odir = '$odir';
+  @dirs = qw(. $dirs);
+}
+" -e '
+/<img src="(.*?)"/g && ++$need{$1};
+
+END {
+  #print "$me: @{[keys %need]}\n";  # for debugging, show images found.
+  FILE: for my $f (keys %need) {
+    for my $d (@dirs) {
+      if (-f "$d/$f") {
+        use File::Basename;
+        my $dest = dirname ("$odir/$f");
+        #
+        use File::Path;
+        -d $dest || mkpath ($dest)
+          || die "$me: cannot mkdir $dest: $!\n";
+        #
+        use File::Copy;
+        copy ("$d/$f", $dest)
+          || die "$me: cannot copy $d/$f to $dest: $!\n";
+        next FILE;
+      }
+    }
+    die "$me: $ARGV: cannot find image $f\n";
+  }
+}
+' -- "$@" || exit 1
+}
+
+case $outdir in
+  /*) abs_outdir=$outdir;;
+  *)  abs_outdir=$srcdir/$outdir;;
+esac
+
+echo "Making output for $srcfile"
+echo " in `pwd`"
+mkdir -p "$outdir/"
+
+# 
+if $generate_info; then
+  cmd="$SETLANG $MAKEINFO -o $PACKAGE.info $commonarg $infoarg \"$srcfile\""
+  echo "Generating info... ($cmd)"
+  rm -f $PACKAGE.info* # get rid of any strays
+  eval "$cmd"
+  tar czf "$outdir/$PACKAGE.info.tar.gz" $PACKAGE.info*
+  ls -l "$outdir/$PACKAGE.info.tar.gz"
+  info_tgz_size=`calcsize "$outdir/$PACKAGE.info.tar.gz"`
+  # do not mv the info files, there's no point in having them available
+  # separately on the web.
+fi  # end info
+
+# 
+if $generate_tex; then
+  cmd="$SETLANG $TEXI2DVI $dirargs $texarg \"$srcfile\""
+  printf "\nGenerating dvi... ($cmd)\n"
+  eval "$cmd"
+  # compress/finish dvi:
+  gzip -f -9 $PACKAGE.dvi
+  dvi_gz_size=`calcsize $PACKAGE.dvi.gz`
+  mv $PACKAGE.dvi.gz "$outdir/"
+  ls -l "$outdir/$PACKAGE.dvi.gz"
+
+  cmd="$SETLANG $TEXI2DVI --pdf $dirargs $texarg \"$srcfile\""
+  printf "\nGenerating pdf... ($cmd)\n"
+  eval "$cmd"
+  pdf_size=`calcsize $PACKAGE.pdf`
+  mv $PACKAGE.pdf "$outdir/"
+  ls -l "$outdir/$PACKAGE.pdf"
+fi # end tex (dvi + pdf)
+
+# 
+if $generate_ascii; then
+  opt="-o $PACKAGE.txt --no-split --no-headers $commonarg"
+  cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
+  printf "\nGenerating ascii... ($cmd)\n"
+  eval "$cmd"
+  ascii_size=`calcsize $PACKAGE.txt`
+  gzip -f -9 -c $PACKAGE.txt >"$outdir/$PACKAGE.txt.gz"
+  ascii_gz_size=`calcsize "$outdir/$PACKAGE.txt.gz"`
+  mv $PACKAGE.txt "$outdir/"
+  ls -l "$outdir/$PACKAGE.txt" "$outdir/$PACKAGE.txt.gz"
+fi
+
+# 
+
+if $generate_html; then
+# Split HTML at level $1.  Used for texi2html.
+html_split()
+{
+  opt="--split=$1 --node-files $commonarg $htmlarg"
+  cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $opt \"$srcfile\""
+  printf "\nGenerating html by $1... ($cmd)\n"
+  eval "$cmd"
+  split_html_dir=$PACKAGE.html
+  (
+    cd ${split_html_dir} || exit 1
+    ln -sf ${PACKAGE}.html index.html
+    tar -czf "$abs_outdir/${PACKAGE}.html_$1.tar.gz" -- *.html
+  )
+  eval html_$1_tgz_size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"`
+  rm -f "$outdir"/html_$1/*.html
+  mkdir -p "$outdir/html_$1/"
+  mv ${split_html_dir}/*.html "$outdir/html_$1/"
+  rmdir ${split_html_dir}
+}
+
+if test -z "$use_texi2html"; then
+  opt="--no-split --html -o $PACKAGE.html $commonarg $htmlarg"
+  cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
+  printf "\nGenerating monolithic html... ($cmd)\n"
+  rm -rf $PACKAGE.html  # in case a directory is left over
+  eval "$cmd"
+  html_mono_size=`calcsize $PACKAGE.html`
+  gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz"
+  html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"`
+  copy_images "$outdir/" $PACKAGE.html
+  mv $PACKAGE.html "$outdir/"
+  ls -l "$outdir/$PACKAGE.html" "$outdir/$PACKAGE.html.gz"
+
+  # Before Texinfo 5.0, makeinfo did not accept a --split=HOW option,
+  # it just always split by node.  So if we're splitting by node anyway,
+  # leave it out.
+  if test "x$split" = xnode; then
+    split_arg=
+  else
+    split_arg=--split=$split
+  fi
+  #
+  opt="--html -o $PACKAGE.html $split_arg $commonarg $htmlarg"
+  cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
+  printf "\nGenerating html by $split... ($cmd)\n"
+  eval "$cmd"
+  split_html_dir=$PACKAGE.html
+  copy_images $split_html_dir/ $split_html_dir/*.html
+  (
+    cd $split_html_dir || exit 1
+    tar -czf "$abs_outdir/$PACKAGE.html_$split.tar.gz" -- *
+  )
+  eval \
+    html_${split}_tgz_size=`calcsize "$outdir/$PACKAGE.html_$split.tar.gz"`
+  rm -rf "$outdir/html_$split/"
+  mv $split_html_dir "$outdir/html_$split/"
+  du -s "$outdir/html_$split/"
+  ls -l "$outdir/$PACKAGE.html_$split.tar.gz"
+
+else # use texi2html:
+  opt="--output $PACKAGE.html $commonarg $htmlarg"
+  cmd="$SETLANG $TEXI2HTML $opt \"$srcfile\""
+  printf "\nGenerating monolithic html with texi2html... ($cmd)\n"
+  rm -rf $PACKAGE.html  # in case a directory is left over
+  eval "$cmd"
+  html_mono_size=`calcsize $PACKAGE.html`
+  gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz"
+  html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"`
+  mv $PACKAGE.html "$outdir/"
+
+  html_split node
+  html_split chapter
+  html_split section
+fi
+fi # end html
+
+# 
+printf "\nMaking .tar.gz for sources...\n"
+d=`dirname $srcfile`
+(
+  cd "$d"
+  srcfiles=`ls -d *.texinfo *.texi *.txi *.eps $source_extra 2>/dev/null` || 
true
+  tar czfh "$abs_outdir/$PACKAGE.texi.tar.gz" $srcfiles
+  ls -l "$abs_outdir/$PACKAGE.texi.tar.gz"
+)
+texi_tgz_size=`calcsize "$outdir/$PACKAGE.texi.tar.gz"`
+
+# 
+# Do everything again through docbook.
+if test -n "$docbook"; then
+  opt="-o - --docbook $commonarg"
+  cmd="$SETLANG $MAKEINFO $opt \"$srcfile\" >${srcdir}/$PACKAGE-db.xml"
+  printf "\nGenerating docbook XML... ($cmd)\n"
+  eval "$cmd"
+  docbook_xml_size=`calcsize $PACKAGE-db.xml`
+  gzip -f -9 -c $PACKAGE-db.xml >"$outdir/$PACKAGE-db.xml.gz"
+  docbook_xml_gz_size=`calcsize "$outdir/$PACKAGE-db.xml.gz"`
+  mv $PACKAGE-db.xml "$outdir/"
+
+  split_html_db_dir=html_node_db
+  opt="$commonarg -o $split_html_db_dir"
+  cmd="$DOCBOOK2HTML $opt \"${outdir}/$PACKAGE-db.xml\""
+  printf "\nGenerating docbook HTML... ($cmd)\n"
+  eval "$cmd"
+  (
+    cd ${split_html_db_dir} || exit 1
+    tar -czf "$abs_outdir/${PACKAGE}.html_node_db.tar.gz" -- *.html
+  )
+  html_node_db_tgz_size=`calcsize "$outdir/${PACKAGE}.html_node_db.tar.gz"`
+  rm -f "$outdir"/html_node_db/*.html
+  mkdir -p "$outdir/html_node_db"
+  mv ${split_html_db_dir}/*.html "$outdir/html_node_db/"
+  rmdir ${split_html_db_dir}
+
+  cmd="$DOCBOOK2TXT \"${outdir}/$PACKAGE-db.xml\""
+  printf "\nGenerating docbook ASCII... ($cmd)\n"
+  eval "$cmd"
+  docbook_ascii_size=`calcsize $PACKAGE-db.txt`
+  mv $PACKAGE-db.txt "$outdir/"
+
+  cmd="$DOCBOOK2PDF \"${outdir}/$PACKAGE-db.xml\""
+  printf "\nGenerating docbook PDF... ($cmd)\n"
+  eval "$cmd"
+  docbook_pdf_size=`calcsize $PACKAGE-db.pdf`
+  mv $PACKAGE-db.pdf "$outdir/"
+fi
+
+# 
+printf "\nMaking index.html for $PACKAGE...\n"
+if test -z "$use_texi2html"; then
+  CONDS="/%%IF  *HTML_SECTION%%/,/%%ENDIF  *HTML_SECTION%%/d;\
+         /%%IF  *HTML_CHAPTER%%/,/%%ENDIF  *HTML_CHAPTER%%/d"
+else
+  # should take account of --split here.
+  CONDS="/%%ENDIF.*%%/d;/%%IF  *HTML_SECTION%%/d;/%%IF  *HTML_CHAPTER%%/d"
+fi
+
+curdate=`$SETLANG date '+%B %d, %Y'`
+sed \
+   -e "s!%%TITLE%%!$MANUAL_TITLE!g" \
+   -e "s!%%EMAIL%%!$EMAIL!g" \
+   -e "s!%%PACKAGE%%!$PACKAGE!g" \
+   -e "s!%%DATE%%!$curdate!g" \
+   -e "s!%%HTML_MONO_SIZE%%!$html_mono_size!g" \
+   -e "s!%%HTML_MONO_GZ_SIZE%%!$html_mono_gz_size!g" \
+   -e "s!%%HTML_NODE_TGZ_SIZE%%!$html_node_tgz_size!g" \
+   -e "s!%%HTML_SECTION_TGZ_SIZE%%!$html_section_tgz_size!g" \
+   -e "s!%%HTML_CHAPTER_TGZ_SIZE%%!$html_chapter_tgz_size!g" \
+   -e "s!%%INFO_TGZ_SIZE%%!$info_tgz_size!g" \
+   -e "s!%%DVI_GZ_SIZE%%!$dvi_gz_size!g" \
+   -e "s!%%PDF_SIZE%%!$pdf_size!g" \
+   -e "s!%%ASCII_SIZE%%!$ascii_size!g" \
+   -e "s!%%ASCII_GZ_SIZE%%!$ascii_gz_size!g" \
+   -e "s!%%TEXI_TGZ_SIZE%%!$texi_tgz_size!g" \
+   -e "s!%%DOCBOOK_HTML_NODE_TGZ_SIZE%%!$html_node_db_tgz_size!g" \
+   -e "s!%%DOCBOOK_ASCII_SIZE%%!$docbook_ascii_size!g" \
+   -e "s!%%DOCBOOK_PDF_SIZE%%!$docbook_pdf_size!g" \
+   -e "s!%%DOCBOOK_XML_SIZE%%!$docbook_xml_size!g" \
+   -e "s!%%DOCBOOK_XML_GZ_SIZE%%!$docbook_xml_gz_size!g" \
+   -e "s,%%SCRIPTURL%%,$scripturl,g" \
+   -e "s!%%SCRIPTNAME%%!$prog!g" \
+   -e "$CONDS" \
+$GENDOCS_TEMPLATE_DIR/gendocs_template >"$outdir/index.html"
+
+echo "Done, see $outdir/ subdirectory for new files."
+
+# Local variables:
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/aux/gendocs_template b/aux/gendocs_template
new file mode 100644
index 0000000..ee26d33
--- /dev/null
+++ b/aux/gendocs_template
@@ -0,0 +1,101 @@
+<!--#include virtual="/server/header.html" -->
+<!-- Parent-Version: 1.78 -->
+
+<!--
+Copyright (C) 2006-2020 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.  This file is offered as-is,
+without any warranty.
+-->
+
+<title>%%TITLE%% - GNU Project - Free Software Foundation</title>
+<!--#include virtual="/server/banner.html" -->
+<h2>%%TITLE%%</h2>
+
+<address>Free Software Foundation</address>
+<address>last updated %%DATE%%</address>
+
+<p>This manual (%%PACKAGE%%) is available in the following formats:</p>
+
+<ul>
+<li><a href="%%PACKAGE%%.html">HTML
+    (%%HTML_MONO_SIZE%%K bytes)</a> - entirely on one web page.</li>
+<li><a href="html_node/index.html">HTML</a> - with one web page per
+    node.</li>
+%%IF HTML_SECTION%%
+<li><a href="html_section/index.html">HTML</a> - with one web page per
+    section.</li>
+%%ENDIF HTML_SECTION%%
+%%IF HTML_CHAPTER%%
+<li><a href="html_chapter/index.html">HTML</a> - with one web page per
+    chapter.</li>
+%%ENDIF HTML_CHAPTER%%
+<li><a href="%%PACKAGE%%.html.gz">HTML compressed
+    (%%HTML_MONO_GZ_SIZE%%K gzipped characters)</a> - entirely on
+    one web page.</li>
+<li><a href="%%PACKAGE%%.html_node.tar.gz">HTML compressed
+    (%%HTML_NODE_TGZ_SIZE%%K gzipped tar file)</a> -
+    with one web page per node.</li>
+%%IF HTML_SECTION%%
+<li><a href="%%PACKAGE%%.html_section.tar.gz">HTML compressed
+    (%%HTML_SECTION_TGZ_SIZE%%K gzipped tar file)</a> -
+    with one web page per section.</li>
+%%ENDIF HTML_SECTION%%
+%%IF HTML_CHAPTER%%
+<li><a href="%%PACKAGE%%.html_chapter.tar.gz">HTML compressed
+    (%%HTML_CHAPTER_TGZ_SIZE%%K gzipped tar file)</a> -
+    with one web page per chapter.</li>
+%%ENDIF HTML_CHAPTER%%
+<li><a href="%%PACKAGE%%.info.tar.gz">Info document
+    (%%INFO_TGZ_SIZE%%K bytes gzipped tar file)</a>.</li>
+<li><a href="%%PACKAGE%%.txt">ASCII text
+    (%%ASCII_SIZE%%K bytes)</a>.</li>
+<li><a href="%%PACKAGE%%.txt.gz">ASCII text compressed
+    (%%ASCII_GZ_SIZE%%K bytes gzipped)</a>.</li>
+<li><a href="%%PACKAGE%%.dvi.gz">TeX dvi file
+    (%%DVI_GZ_SIZE%%K bytes gzipped)</a>.</li>
+<li><a href="%%PACKAGE%%.pdf">PDF file
+    (%%PDF_SIZE%%K bytes)</a>.</li>
+<li><a href="%%PACKAGE%%.texi.tar.gz">Texinfo source
+    (%%TEXI_TGZ_SIZE%%K bytes gzipped tar file).</a></li>
+</ul>
+
+<p>You can <a href="https://shop.fsf.org/";>buy printed copies of
+some manuals</a> (among other items) from the Free Software Foundation;
+this helps support FSF activities.</p>
+
+<p>(This page generated by the <a href="%%SCRIPTURL%%">%%SCRIPTNAME%%
+script</a>.)</p>
+
+<!-- If needed, change the copyright block at the bottom. In general,
+     all pages on the GNU web server should have the section about
+     verbatim copying.  Please do NOT remove this without talking
+     with the webmasters first.
+     Please make sure the copyright date is consistent with the document
+     and that it is like this: "2001, 2002", not this: "2001-2002". -->
+</div><!-- for id="content", starts in the include above -->
+<!--#include virtual="/server/footer.html" -->
+<div id="footer">
+<div class="unprintable">
+
+<p>Please send general FSF &amp; GNU inquiries to
+<a href="mailto:gnu@gnu.org";>&lt;gnu@gnu.org&gt;</a>.
+There are also <a href="/contact/">other ways to contact</a>
+the FSF.  Broken links and other corrections or suggestions can be sent
+to <a href="mailto:%%EMAIL%%";>&lt;%%EMAIL%%&gt;</a>.</p>
+</div>
+
+<p>Copyright &copy; 2020 Free Software Foundation, Inc.</p>
+
+<p>This page is licensed under a <a rel="license"
+href="https://creativecommons.org/licenses/by-nd/3.0/us/";>Creative
+Commons Attribution-NoDerivs 3.0 United States License</a>.</p>
+
+<!--#include virtual="/server/bottom-notes.html" -->
+
+</div>
+</div>
+</body>
+</html>
diff --git a/ob-rec.el b/ob-rec.el
index 4eb0070..6e47040 100644
--- a/ob-rec.el
+++ b/ob-rec.el
@@ -2,7 +2,8 @@
 
 ;; Copyright (C) 2011-2020 Free Software Foundation, Inc.
 
-;; Author: Jose E. Marchesi
+;; Author: Jose E. Marchesi <jemarch@gnu.org>
+;; Maintainer: Antoine Kalmbach <ane@iki.fi>
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
 ;; Version: 7.7
diff --git a/rec-mode.el b/rec-mode.el
index 94c2412..fbf86bf 100644
--- a/rec-mode.el
+++ b/rec-mode.el
@@ -6,7 +6,7 @@
 ;; Maintainer: Antoine Kalmbach <ane@iki.fi>
 ;; URL: https://www.gnu.org/software/recutils/
 ;; Package-Requires: ((emacs "25"))
-;; Version: 1.6
+;; Version: 1.7.0
 
 ;; This file is NOT part of GNU Emacs.
 
@@ -48,7 +48,9 @@
 (require 'calendar)
 (require 'hl-line)
 (require 'tabulated-list)
-(require 'subr-x)
+(eval-when-compile (require 'subr-x))
+(require 'seq)
+(require 'eieio)
 
 ;;;; Customization
 
@@ -60,19 +62,36 @@
 (defcustom rec-open-mode 'navigation
   "Default mode to use when switching a buffer to `rec-mode'.
 Valid values are `edit' and `navigation'.  The default is `navigation'"
-  :type 'symbol)
+  :type 'symbol
+  :safe (lambda (x) (member x '(edit navigation))))
+;;;###autoload (put rec-open-mode 'safe-local-variable (lambda (x) (member x 
'(edit navigation))
 
 (defcustom rec-popup-calendar t
   "Whether to use a popup calendar to select dates when editing field values.
 The default is t."
   :type 'boolean)
 
+(defcustom rec-move-to-next-line-after-edit t
+  "Whether to move forward to the next field or line after editing a record 
field."
+  :type 'boolean)
+
 (defcustom rec-mode-hook nil
   "Hook run when entering rec mode."
   :type 'hook)
 
+(defcustom rec-summary-window-height 10
+  "Height of the summary window."
+  :type 'integer)
+
+(defcustom rec-summary-deletes-other-windows nil
+  "Whether entering `rec-summary-mode' should kill other windows."
+  :type 'boolean)
+
+;;;; Faces and variables
+
 (defvar rec-max-lines-in-fields 15
   "Values of fields having more than the specified lines will be hidden by 
default in navigation mode.")
+(put 'rec-max-lines-in-fields 'safe-local-variable 'numberp)
 
 (defvar rec-recsel "recsel"
   "Name of the 'recsel' utility from the GNU recutils.")
@@ -92,6 +111,20 @@ The default is t."
 (defface rec-continuation-line-face '((t :weight bold))
   "Face for line continuations (+).")
 
+;;;; Utilities
+
+(defun rec-mode--syntax-highlight (str)
+  "Highlight STR using rec-mode's font-locking."
+  (with-temp-buffer
+    (insert str)
+    (delay-mode-hooks
+      (rec-mode)
+      (if (fboundp 'font-lock-ensure)
+          (font-lock-ensure)
+        (with-no-warnings
+          (font-lock-fontify-buffer)))
+      (buffer-string))))
+
 ;;;; Variables and constants that the user does not want to touch (really!)
 
 (defconst rec-mode-version "1.5"
@@ -175,7 +208,7 @@ The default is t."
     ("^\\+" . 'rec-continuation-line-face))
   "Font lock keywords used in `rec-mode'.")
 
-(defvar rec-mode-edit-map
+(defvar rec-edit-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "C-c C-n") 'rec-cmd-goto-next-rec)
     (define-key map (kbd "C-c C-p") 'rec-cmd-goto-previous-rec)
@@ -186,20 +219,31 @@ The default is t."
     (define-key map (kbd "C-c C-%") 'rec-cmd-statistic)
     (define-key map (kbd "C-c C-f m") 'rec-cmd-trim-field-value)
     (define-key map (kbd "C-c C-k") 'rec-cmd-compile)
-    (define-key map (kbd "C-c C-s q") 'rec-cmd-select-fast)
-    (define-key map (kbd "C-c C-s s") 'rec-cmd-select-sex)
+    (define-key map (kbd "C-c C-/ s") 'rec-cmd-navigate-current-type-by-sex)
+    (define-key map (kbd "C-c C-/ C-k") 'rec-cmd-exit-selection)
+    (define-key map (kbd "C-c M-s C-s") 'rec-cmd-new-buffer-from-sex)
+    (define-key map (kbd "C-c M-s C-q") 'rec-cmd-navigate-by-sex)
+    (define-key map (kbd "C-c C-x C-s") 'rec-cmd-xref-sex)
+    (define-key map (kbd "C-c C-x C-q") 'rec-cmd-xref-fast-string)
+    (define-key map (kbd "C-c C-s q") 'rec-cmd-jump-to-fast)
+    (define-key map (kbd "C-c C-s s") 'rec-cmd-jump-to-sex)
     (define-key map (kbd "C-c M-h") 'rec-cmd-show-summary)
     (define-key map (kbd "C-c C-i") 'rec-cmd-show-info)
     (define-key map (kbd "C-c C-f C-w") 'rec-cmd-kill-field)
     (define-key map (kbd "C-c C-f M-w") 'rec-cmd-copy-field)
     (define-key map (kbd "C-c C-r C-w") 'rec-cmd-kill-record)
     (define-key map (kbd "C-c C-r M-w") 'rec-cmd-copy-record)
+    (define-key map (kbd "C-c C-SPC") 'rec-cmd-toggle-field-visibility)
     (define-key map [tab] 'rec-cmd-goto-next-field)
     (define-key map (kbd "TAB") 'rec-cmd-goto-next-field)
     (define-key map (kbd "C-c C-b") 'rec-cmd-jump-back)
     (define-key map (kbd "C-c C-c") 'rec-finish-editing)
+    (define-key map (kbd "C-c C-t") 'rec-find-type)
+    ;; Set a dummy keymap as the parent so we shadow
+    ;; `rec-mode-map' instead of inheriting it.
+    (set-keymap-parent map (make-sparse-keymap))
     map)
-  "Keymap for `rec-mode' when editing records.")
+  "Keymap for `rec-edit-mode'.")
 
 (defvar rec-mode-map
   (let ((map (make-sparse-keymap)))
@@ -215,14 +259,21 @@ The default is t."
     (define-key map (kbd "t") 'rec-cmd-show-type)
     (define-key map (kbd "m") 'rec-cmd-trim-field-value)
     (define-key map (kbd "c") 'rec-cmd-compile)
+    (define-key map (kbd "/ s") 'rec-cmd-navigate-current-type-by-sex)
+    (define-key map (kbd "/ q") 'rec-cmd-navigate-current-type-by-fast-string)
+    (define-key map (kbd "/ /") 'rec-cmd-exit-selection)
+    (define-key map (kbd "X s") 'rec-cmd-xref-sex)
+    (define-key map (kbd "X q") 'rec-cmd-xref-fast-string)
     (define-key map (kbd "f C-w") 'rec-cmd-kill-field)
     (define-key map (kbd "f M-w") 'rec-cmd-copy-field)
     (define-key map (kbd "r C-w") 'rec-cmd-kill-record)
     (define-key map (kbd "r M-w") 'rec-cmd-copy-record)
-    (define-key map (kbd "s q") 'rec-cmd-select-fast)
-    (define-key map (kbd "s s") 'rec-cmd-select-sex)
+    (define-key map (kbd "s q") 'rec-cmd-jump-to-fast)
+    (define-key map (kbd "s s") 'rec-cmd-jump-to-sex)
+    (define-key map (kbd "S s") 'rec-cmd-new-buffer-from-sex)
+    (define-key map (kbd "S q") 'rec-cmd-new-buffer-from-fast-string)
     (define-key map (kbd "h") 'rec-cmd-show-summary)
-    (define-key map (kbd "C-c t") 'rec-find-type)
+    (define-key map (kbd "C-c C-t") 'rec-find-type)
     (define-key map [remap undo] 'rec-cmd-undo)
     (define-key map (kbd "#") 'rec-cmd-count)
     (define-key map (kbd "%") 'rec-cmd-statistic)
@@ -251,10 +302,9 @@ including the leading #:
 If the point is not at the beginning of a comment then return nil"
   (when (and (equal (current-column) 0)
              (looking-at rec-comment-re))
-    (let ((comment (list 'comment
-                         (point)
-                         (buffer-substring-no-properties (match-beginning 0)
-                                                         (match-end 0)))))
+    (let ((comment (rec-comment :position (point)
+                                :value (buffer-substring-no-properties 
(match-beginning 0)
+                                                                       
(match-end 0)))))
       (goto-char (match-end 0))
       ;; Skip a newline if needed
       (when (eolp) (forward-line 1))
@@ -296,24 +346,19 @@ nil"
       val)))
 
 (defun rec-parse-field ()
-  "Return a structure describing the field starting from the pointer.
-
-The returned structure is a list whose first element is the
-symbol 'field', the second element is the name of the field and
-the second element is the value of the field:
+  "Return a `rec-field' describing the field starting from the pointer.
 
-   (field POSITION FIELD-NAME FIELD-VALUE)
-
-If the pointer is not at the beginning of a field
-descriptor then return nil"
+If the pointer is not at the beginning of a field descriptor then
+return nil."
   (let ((there (point))
         field-name field-value)
-    (and (setq field-name (rec-parse-field-name))
-         (setq field-value (rec-parse-field-value)))
-    (when (and field-name field-value)
-        ;; Skip a newline if needed
-        (when (looking-at "\n") (goto-char (match-end 0)))
-        (list 'field there field-name field-value))))
+    (when (and (setq field-name (rec-parse-field-name))
+               (setq field-value (rec-parse-field-value)))
+      ;; Skip a newline if needed
+      (when (looking-at "\n") (goto-char (match-end 0)))
+      (rec-field :position there
+                 :name field-name
+                 :value field-value))))
 
 (defun rec-parse-record ()
   "Return a structure describing the record starting from the pointer.
@@ -326,100 +371,102 @@ The returned structure is a list of fields preceded by 
the symbol
 If the pointer is not at the beginning of a record, then return
 nil"
   (let ((there (point))
-        record field-or-comment)
+        (fields ()) field-or-comment)
     (while (setq field-or-comment (or (rec-parse-field)
                                       (rec-parse-comment)))
-      (setq record (cons field-or-comment record)))
-    (setq record (list 'record there (reverse record)))))
-
-;;;; Writer functions (rec-insert-*)
-;;
-;; Those functions dump the written representation of the parser
-;; structures (field, comment, record, etc) into the current buffer
-;; starting at the current position.
-
-(defun rec-insert-comment (comment)
-  "Insert the written form of COMMENT in the current buffer."
-  (when (rec-comment-p comment)
-    (insert (rec-comment-string comment))))
-
-(defun rec-insert-field-name (field-name)
-  "Insert the written form of FIELD-NAME in the current buffer."
-  (when (stringp field-name)
-    (insert (concat field-name ":"))
-    t))
-
-(defun rec-insert-field-value (field-value)
-  "Insert the written form of FIELD-VALUE in the current buffer."
-  (when (stringp field-value)
-    (let ((val field-value))
-      ;; FIXME: Maximum line size
-      (insert (replace-regexp-in-string "\n" "\n+ " val)))
-    (insert "\n")))
+      (push field-or-comment fields))
+    
+    (let* ((record (rec-record :position there
+                               :fields (reverse fields))))
+      (or (rec-record-to-descriptor record) record))))
 
-(defun rec-insert-field (field)
-  "Insert the written form of FIELD in the current buffer."
-  (when (rec-field-p field)
-    (when (rec-insert-field-name (rec-field-name field))
-      (insert " ")
-      (rec-insert-field-value (rec-field-value field)))))
-
-(defun rec-insert-record (record)
-  "Insert the written form of RECORD in the current buffer."
-  (when (rec-record-p record)
-    (mapcar (lambda (elem)
-              (cond
-               ((rec-comment-p elem) (rec-insert-comment elem))
-               ((rec-field-p elem) (rec-insert-field elem))))
-            (rec-record-elems record))))
 
 ;;;; Operations on record structures
 ;;
 ;; Those functions retrieve or set properties of field structures.
 
-(defun rec-record-p (record)
-  "Determine if RECORD is a record."
-  (and (listp record)
-       (= (length record) 3)
-       (equal (car record) 'record)))
+(defclass rec-record ()
+  ((position :initarg :position
+             :documentation "The position of the record in the recfile.")
+   (fields :initarg :fields
+           :documentation "The fields of the record."))
+  "A recfile record.")
+
+(defclass rec-record-descriptor (rec-record)
+  ((type :initarg :type
+         :documentation "The type described by the descriptor.")
+   (key :initarg :key
+        :initform nil
+        :documentation "The key field of the descriptor.")
+   (auto :initarg :auto
+         :initform nil
+         :documentation "The %auto field of the descriptor.")
+   (doc :initarg :doc
+        :initform ""
+        :documentation "The descriptor's %doc field."))
+  "A record descriptor.")
+
+(defclass rec-record-element ()
+  ((position :initarg :position)
+   (value :initarg :value))
+  "A record element, either a comment or field.")
+
+(cl-defgeneric rec-element-position (element)
+  "Return the position of ELEMENT.")
+
+(cl-defgeneric rec-element-value (element)
+  "Return the value of ELEMENT.")
+
+(cl-defmethod rec-element-position ((element rec-record-element))
+  "Return the position of ELEMENT."
+  (slot-value element 'position))
+
+(cl-defmethod rec-element-value ((element rec-record-element))
+  "Return the value of ELEMENT."
+  (slot-value element 'value))
+
+(defclass rec-comment (rec-record-element) ()
+  "A record comment.")
+
+(defclass rec-field (rec-record-element)
+  ((name :initarg :name)))
 
-(defun rec-record-position (record)
-  "Return the start position of the given RECORD."
-  (when (rec-record-p record)
-    (nth 1 record)))
+(defun rec-field-name (field)
+  (when (rec-field-p field)
+    (slot-value field 'name)))
 
-(defun rec-record-elems (record)
-  "Return a list with the elements of the given RECORD."
-  (when (rec-record-p record)
-    (nth 2 record)))
+(defun rec-field-position (field)
+  (when (rec-field-p field)
+    (rec-element-position field)))
 
-(defun rec-record-descriptor-p (record)
-  "Determine if the given RECORD is a descriptor."
-  (not (null (rec-record-assoc rec-keyword-rec record))))
+(defun rec-field-value (field)
+  (when (rec-field-p field)
+    (rec-element-value field)))
 
-(defun rec-record-assoc (name record)
+(defun rec-map-fields (fun record)
+  "Map function FUN over the fields in RECORD."
+  (cl-loop for field in (slot-value record 'fields)
+           when (rec-field-p field)
+           collect (funcall fun field)))
+
+(cl-defmethod rec-record-assoc (name (record rec-record))
   "Get a list with the values of the fields in RECORD named NAME.
 
 NAME shall be a field name.
 If no such field exists in RECORD then nil is returned."
-  (when (rec-record-p record)
-    (let (result)
-      (mapc (lambda (field)
-              (when (and (rec-field-p field)
-                         (equal name (rec-field-name field)))
-                (setq result (cons (rec-field-value field) result))))
-            (rec-record-elems record))
-      (reverse result))))
-
-(defun rec-record-names (record)
+  (cl-loop for field in (slot-value record 'fields)
+           when (and (rec-field-p field)
+                     (equal name (rec-field-name field)))
+           collect (rec-field-value field)))
+
+(cl-defgeneric rec-record-names (record)
+  "Get a list of the field names in the RECORD.")
+
+(cl-defmethod rec-record-names ((record rec-record))
   "Get a list of the field names in the RECORD."
-  (when (rec-record-p record)
-    (let (result)
-      (mapc (lambda (field)
-              (when (rec-field-p field)
-                (setq result (cons (rec-field-name field) result))))
-            (rec-record-elems record))
-      (reverse result))))
+  (cl-loop for field in (slot-value record 'fields)
+           when (rec-field-p field)
+           collect (rec-field-name field)))
 
 (defun rec-record-values (record fields)
   "Given a list of field names in FIELDS, return a list of the values of 
RECORD."
@@ -427,58 +474,48 @@ If no such field exists in RECORD then nil is returned."
     (append (rec-record-assoc (car fields) record)
             (rec-record-values record (cdr fields)))))
 
-;;;; Operations on comment structures
+;;;; Writer functions (rec-insert)
 ;;
-;; Those functions retrieve or set properties of comment structures.
+;; Those functions dump the written representation of the parser
+;; structures (field, comment, record, etc) into the current buffer
+;; starting at the current position.
+
+(cl-defgeneric rec-insert (element)
+  "Insert the written form of ELEMENT into the current buffer.")
+
+(cl-defmethod rec-insert ((comment rec-comment))
+  "Insert the written form of COMMENT in the current buffer."
+  (insert (rec-element-value comment) "\n"))
 
-(defun rec-comment-p (comment)
-  "Determine if the provided COMMENT arg is a comment structure."
-  (and (listp comment)
-       (= (length comment) 3)
-       (equal (car comment) 'comment)))
+(defun rec-insert-field-name (field-name)
+  "Insert the written form of FIELD-NAME in the current buffer."
+  (when (stringp field-name)
+    (insert (concat field-name ":"))
+    t))
 
-(defun rec-comment-position (comment)
-  "Return the start position of the given COMMENT."
-  (when (rec-comment-p comment)
-    (nth 1 comment)))
+(defun rec-insert-field-value (field-value)
+  "Insert the written form of FIELD-VALUE in the current buffer."
+  (when (stringp field-value)
+    (let ((val field-value))
+      ;; FIXME: Maximum line size
+      (insert (replace-regexp-in-string "\n" "\n+ " val)))
+    (insert "\n")))
 
-(defun rec-comment-string (comment)
-  "Return the string composing the COMMENT, including the initial '#' 
character."
-  (when (rec-comment-p comment)
-    (nth 2 comment)))
+(cl-defmethod rec-insert ((field rec-field))
+  "Insert the written form of FIELD in the current buffer."
+  (with-slots (name value) field
+    (when (rec-insert-field-name name)
+      (insert " ")
+      (rec-insert-field-value value))))
 
+(cl-defmethod rec-insert ((record rec-record))
+  "Insert the written form of RECORD in the current buffer."
+  (mapc #'rec-insert (slot-value record 'fields)))
+4
 ;;;; Operations on field structures
 ;;
 ;; Those functions retrieve or set properties of field structures.
 
-(defun rec-field-p (field)
-  "Determine if FIELD is a field."
-  (and (listp field)
-       (= (length field) 4)
-       (equal (car field) 'field)))
-
-(defun rec-field-position (field)
-  "Return the start position of the given FIELD."
-  (when (rec-field-p field)
-    (nth 1 field)))
-
-(defun rec-field-name (field)
-  "Return the name of the provided FIELD."
-  (when (rec-field-p field)
-    (nth 2 field)))
-
-(defun rec-field-value (field)
-  "Return the value of the provided FIELD."
-  (when (rec-field-p field)
-    (nth 3 field)))
-
-(defun rec-field-set-value (field value)
-  "Return FIELD with its value replaced by VALUE."
-  (list 'field
-        (rec-field-position field)
-        (rec-field-name field)
-        value))
-
 (defun rec-field-trim-value (field)
   "Return FIELD with its value trimmed."
   (when (rec-field-p field)
@@ -498,7 +535,8 @@ If no such field exists in RECORD then nil is returned."
         (delete-region (point) (point-max))
         (setq value (buffer-substring-no-properties (point-min)
                                                     (point-max))))
-      (rec-field-set-value field value))))
+      (setf (slot-value field 'value) value)
+      field)))
 
 ;;;; Get entities under pointer
 ;;
@@ -556,17 +594,20 @@ If no such field exists in RECORD then nil is returned."
 
 (defun rec-beginning-of-record-pos ()
   "Return the position of the beginning of the current record, or nil if the 
pointer is not on a record."
-  (save-excursion
-    (let (field-pos)
-      (while (and (not (equal (point) (point-min)))
-                  (setq field-pos (or (rec-beginning-of-field-pos)
-                                      (rec-beginning-of-comment-pos))))
-        (goto-char field-pos)
-        (if (not (equal (point) (point-min)))
-            (backward-char)))
-      (unless (or (eobp)
-                  (looking-at rec-comment-field-re))
-          (forward-char))
+  (let (field-pos)
+    (save-excursion
+      (cl-block found
+        (while (not (equal (point) (point-min)))
+          (save-excursion
+            (backward-char)
+            (setq field-pos (or (rec-beginning-of-field-pos)
+                                (rec-beginning-of-comment-pos))))
+          (if field-pos
+              (goto-char field-pos)
+            (if (or (rec-beginning-of-field-pos)
+                    (rec-beginning-of-comment-pos))
+                (cl-return-from found)
+              (backward-char)))))
       (when (looking-at rec-comment-field-re)
         (point)))))
 
@@ -630,12 +671,6 @@ The current record is the record where the pointer is"
 ;; These functions perform the management of the collection of records
 ;; in the buffer.
 
-;; FIXME: The term "descriptor" is used for this object as well as for its
-;; first field, which is confusing.
-(cl-defstruct (rec--descriptor
-               (:constructor nil)
-               (:constructor rec--descriptor-make (descriptor marker)))
-  descriptor marker)
 
 (defvar rec-buffer-descriptors nil
   "List of `rec--descriptor's.")
@@ -655,7 +690,7 @@ The current record is the record where the pointer is"
   "Update buffer descriptors and check if there's a parse error.
 
 Switch to fundamental mode if there is a parse error.  If
-`DONT-GO-FUNDAMENTAL is non-nil, don't switch to fundamental."
+DONT-GO-FUNDAMENTAL is non-nil, don't switch to fundamental."
   (if (rec-buffer-valid-p)
       (progn
         (rec-update-buffer-descriptors)
@@ -682,6 +717,36 @@ Switch to fundamental mode if there is a parse error.  If
       (message (concat (buffer-name) ": " errmsg))
       nil)))
 
+(cl-defgeneric rec-record-to-descriptor (record)
+  "Try casting RECORD into a descriptor.")
+
+(cl-defmethod rec-record-to-descriptor ((record rec-record))
+  "Try casting RECORD into a descriptor."
+  (let ((type (car-safe (rec-record-assoc "%rec" record))))
+    (if type
+        (with-slots (position fields) record
+          (rec-record-descriptor :position position
+                                 :fields fields
+                                 :type type
+                                 :key (car-safe (rec-record-assoc "%key" 
record))
+                                 :auto (car-safe (rec-record-assoc "%auto" 
record))
+                                 :doc (car-safe (rec-record-assoc "%doc" 
record)))))))
+
+(cl-defmethod rec-record-to-descriptor ((_record rec-record-descriptor))
+  rec-record-descriptor)
+
+(defun rec--parse-sexp-records (records)
+  "Parse a recinf sexp record in RECORDS."
+  (cl-loop for (nil pos fields) in records
+           for parsed-fields = (cl-loop for (nil pos name value) in fields
+                                        collect (rec-field :position pos
+                                                           :name name
+                                                           :value value))
+           for record = (rec-record :position pos
+                                    :fields parsed-fields)
+           collect (or (rec-record-to-descriptor record)
+                       record)))
+
 (defun rec-update-buffer-descriptors ()
   "Get a list of the record descriptors in the current buffer.
 
@@ -689,7 +754,6 @@ If the contents of the current buffer are not valid rec 
data then
 this function returns nil."
   (setq rec-buffer-descriptors
        (let* ((buffer (generate-new-buffer "Rec Inf "))
-              descriptors records
               (status
                ;; Call 'recinf' to get the list of record descriptors in
                ;; sexp format.
@@ -706,23 +770,12 @@ this function returns nil."
                        (goto-char (point-max))
                        (insert ")")
                        (unwind-protect
-                           (setq descriptors (read (point-min-marker)))
-                         (kill-buffer buffer)))
-                     (when descriptors
-                       (mapc (lambda (descriptor)
-                               ;; FIXME: The `rec-record-position' data comes
-                               ;; from the `recinf' tool.  Are these positions
-                               ;; counted in bytes or characters?  Do they
-                               ;; count positions starting from 0 or from 1?
-                               (let ((marker (copy-marker
-                                              (rec-record-position 
descriptor))))
-                                 ;; FIXME: Why do we need `marker' if the 
buffer
-                                 ;; position is already contained in
-                                 ;; `descriptor'?
-                                 (push (rec--descriptor-make descriptor marker)
-                                       records)))
-                             descriptors)
-                       (reverse records)))
+                           (let* ((result (read (point-min-marker)))
+                                  (first (car-safe result)))
+                             (if (and first (seq-every-p #'listp result))
+                                 (seq-filter #'rec-record-descriptor-p
+                                             (rec--parse-sexp-records 
result))))
+                         (kill-buffer buffer))))
             (kill-buffer buffer)
             nil))))
 
@@ -730,10 +783,9 @@ this function returns nil."
   "Return a list with the names of the record types in the existing buffer."
   ;; If a descriptor has more than a %rec field, then the first one is
   ;; used.  The rest are ignored.
-  (mapcar
-   (lambda (elem)
-     (car (rec-record-assoc rec-keyword-rec (rec--descriptor-descriptor 
elem))))
-   rec-buffer-descriptors))
+  (mapcar (lambda (descriptor)
+            (slot-value descriptor 'type))
+          rec-buffer-descriptors))
 
 (defun rec-type-p (type)
   "Determine if there are records of type TYPE in the current file."
@@ -766,11 +818,10 @@ this function returns nil."
           (descriptors rec-buffer-descriptors))
       (mapc
        (lambda (elem)
-         (when (equal (car (rec-record-assoc rec-keyword-rec
-                                             (rec--descriptor-descriptor 
elem)))
-                      type)
-           (setq found t)
-           (goto-char (rec--descriptor-marker elem))))
+         (with-slots ((rec-type type) position) elem
+           (when (equal rec-type type)
+             (setq found t)
+             (goto-char position))))
        descriptors)
       found)))
 
@@ -817,21 +868,23 @@ or the specified type does not exist, then return nil."
                (when (re-search-forward rec-comment-field-re nil t)
                  (match-beginning 0)))))
     (when pos
-        (goto-char pos)
-        t)))
+      (push-mark)
+      (goto-char pos)
+      t)))
 
 (defun rec-goto-previous-rec ()
   "Move the pointer to the end of the previous record in the file."
-    (let ((pos (save-excursion
-                 (rec-beginning-of-record)
-                 (if (not (= (point) (point-min)))
-                     (backward-char))
-                 (when (and (re-search-backward rec-record-re nil t)
-                            (rec-beginning-of-record))
-                   (point)))))
-      (when pos
-        (goto-char pos)
-        t)))
+  (let ((pos (save-excursion
+               (rec-beginning-of-record)
+               (if (not (= (point) (point-min)))
+                   (backward-char))
+               (when (and (re-search-backward rec-record-re nil t)
+                          (rec-beginning-of-record))
+                 (point)))))
+    (when pos
+      (push-mark)
+      (goto-char pos)
+      t)))
 
 (defun rec-type-first-rec-pos (type)
   "Return the position of the first record of the specified TYPE.
@@ -848,6 +901,8 @@ If there are no regular records in the file, return nil."
                  (rec-regular-p))
         (point)))))
 
+
+
 (defun rec-goto-type-first-rec (type)
   "Goto to the first record of type TYPE present in the file.
 If TYPE is nil then goto to the first Unknown record on the file.
@@ -858,6 +913,7 @@ If no such record exist then don't move and return nil."
     (when pos
       (goto-char pos))))
 
+
 (defun rec-count (&optional type sex)
   "Return number of record in the file.
 
@@ -873,22 +929,22 @@ on top of the results."
     (with-temp-buffer
       (if (stringp type)
           (if (stringp sex)
+              (call-process rec-recsel
+                            nil ; infile
+                            t   ; output to current buffer.
+                            nil ; display
+                            "-t" type "-e" sex "-c" rec-file-name)
             (call-process rec-recsel
                           nil ; infile
                           t   ; output to current buffer.
                           nil ; display
-                          "-t" type "-e" sex "-c" rec-file-name)
+                          "-t" type "-c" rec-file-name))
+        (if (stringp sex)
             (call-process rec-recsel
                           nil ; infile
                           t   ; output to current buffer.
                           nil ; display
-                          "-t" type "-c" rec-file-name))
-        (if (stringp sex)
-          (call-process rec-recsel
-                        nil ; infile
-                        t   ; output to current buffer.
-                        nil ; display
-                        "-e" sex "-c" rec-file-name)
+                          "-e" sex "-c" rec-file-name)
           (call-process rec-recsel
                         nil ; infile
                         t   ; output to current buffer.
@@ -909,17 +965,11 @@ Return nil otherwise."
   "Return the type of the record under point.
 
 If the record is of no known type, return nil."
-  (let ((descriptor (rec-record-descriptor)))
-    (cond
-     ((rec--descriptor-p descriptor)
-      (car (rec-record-assoc rec-keyword-rec
-                             (rec--descriptor-descriptor descriptor))))
-     ((equal descriptor "")
-      "")
-     (t
-      nil))))
-
-(defun rec-record-descriptor ()
+  (let ((descriptor (rec-current-record-descriptor)))
+    (when (rec-record-descriptor-p descriptor)
+      (slot-value descriptor 'type))))
+
+(defun rec-current-record-descriptor ()
   "Return the record descriptor of the record under point.
 
 Return \"\" if no proper record descriptor is found in the file.
@@ -934,17 +984,15 @@ Return nil if the point is not on a record."
              for curr in descriptors and
              next in next-descriptors
              
-             if (and (>= point (marker-position (rec--descriptor-marker curr)))
+             if (and (>= point (slot-value curr 'position))
                      (or (= index (- count 1))
-                         (< point (marker-position
-                                   (rec--descriptor-marker
-                                    next)))))
+                         (< point (slot-value next 'position))))
              
              return curr)))
 
 (defun rec-summary-fields ()
   "Return a list with the names of the summary fields in the current record 
set."
-  (let ((descriptor (rec--descriptor-descriptor (rec-record-descriptor))))
+  (let ((descriptor (rec-current-record-descriptor)))
     (when descriptor
       (let ((fields-str (rec-record-assoc rec-keyword-summary descriptor)))
         (when fields-str
@@ -952,7 +1000,7 @@ Return nil if the point is not on a record."
 
 (defun rec-mandatory-fields ()
   "Return a list with the names of the mandatory fields in the current record 
set."
-  (let ((descriptor (rec--descriptor-descriptor (rec-record-descriptor))))
+  (let ((descriptor (rec-current-record-descriptor)))
     (when descriptor
       (let ((fields-str (rec-record-assoc rec-keyword-mandatory descriptor)))
         (when fields-str
@@ -962,9 +1010,7 @@ Return nil if the point is not on a record."
   "Return the name of the field declared as the key of the current record set.
 
 Returns nil if no key is declared."
-  (let ((descriptor (rec--descriptor-descriptor (rec-record-descriptor))))
-    (when descriptor
-      (car (rec-record-assoc rec-keyword-key descriptor)))))
+  (slot-value (rec-current-record-descriptor) 'key))
 
 ;;;; Navigation
 
@@ -983,6 +1029,7 @@ descriptor record.  If nil, the descriptor is skipped."
            (save-excursion
              (let ((record-type (rec-record-type)))
                (and (rec-goto-next-rec)
+                    record-type
                     (equal (rec-record-type) record-type)))))
       (rec-goto-next-rec))
   (rec-show-record))
@@ -991,9 +1038,8 @@ descriptor record.  If nil, the descriptor is skipped."
   "Show the record under the point."
   (setq buffer-read-only t)
   (rec-narrow-to-record)
-  (use-local-map rec-mode-map)
   (rec-set-head-line nil)
-  (rec-set-mode-line (rec-record-type))
+  (rec-update-mode-line)
   ;; Hide the contents of big fields.
   (rec-hide-record-fields)
   ;; Change the appearance of continuation line markers to look like
@@ -1009,8 +1055,8 @@ descriptor record.  If nil, the descriptor is skipped."
 (defun rec-hide-continuation-line-markers ()
   "Make continuation line markers look like indentation."
   (let ((record (rec-current-record)))
-    (when (rec-record-p record)
-      (mapcar
+    (when record
+      (mapc
        (lambda (field)
          (when (rec-field-p field)
            (let* ((pos (rec-field-position field))
@@ -1025,7 +1071,7 @@ descriptor record.  If nil, the descriptor is skipped."
                  (let ((ov (make-overlay (match-beginning 0) (match-end 0))))
                    (overlay-put ov 'display '(space . (:width 
rec-continuation-line-markers-width)))
                    (push ov rec-continuation-line-markers-overlays)))))))
-       (rec-record-elems record)))))
+       (slot-value record 'fields)))))
 
 (defun rec-remove-continuation-line-marker-overlays ()
   "Delete all the continuation line markers overlays."
@@ -1055,7 +1101,7 @@ can then be used to toggle the visibility."
                  (goto-char (rec-field-position field))
                  (rec-fold-field))
                t))))
-       (rec-record-elems record)))))
+       (slot-value record 'fields)))))
 
 (defun rec-field-folded-p ()
   "Return whether the current field is folded."
@@ -1099,14 +1145,13 @@ can then be used to toggle the visibility."
 (defun rec-unfold-record-fields ()
   "Unfold any folded field in the current record."
   (let ((record (rec-current-record)))
-    (when (rec-record-p record)
-      (mapcar
-       (lambda (field)
-         (when (rec-field-p field)
-           (save-excursion
-             (goto-char (rec-field-position field))
-             (rec-unfold-field))))
-       (rec-record-elems record)))))
+    (mapcar
+     (lambda (field)
+       (when (rec-field-p field)
+         (save-excursion
+           (goto-char (rec-field-position field))
+           (rec-unfold-field))))
+     (slot-value record 'fields))))
 
 (defun rec-toggle-field-visibility ()
   "Toggle the visibility of the current field."
@@ -1243,9 +1288,8 @@ manual."
 
 If the field has no type, i.e. it is an unrestricted field which
 can contain any text, then nil is returned."
-  (let* ((descriptor (rec-record-descriptor))
-         (types (rec-record-assoc "%type"
-                                  (rec--descriptor-descriptor descriptor)))
+  (let* ((descriptor (rec-current-record-descriptor))
+         (types (rec-record-assoc "%type" descriptor))
          res-type)
     ;; Note that invalid %type entries are simply ignored.
     (mapc
@@ -1268,13 +1312,25 @@ can contain any text, then nil is returned."
 
 ;;;; Mode line and Head line
 
-(defun rec-set-mode-line (str)
-  "Set the modeline in rec buffers.
-Argument STR is the string to be displayed."
-  (when str
-    (setq mode-line-buffer-identification
-          (list 20
-                "%b " str))))
+(defun rec-update-mode-line ()
+  "Update the modeline in rec buffers.
+
+Argument STR is the string to be displayed.
+
+If `rec-selection-mode' is active, that string is displayed instead."
+  (let* ((message (cond ((derived-mode-p 'rec-edit-mode)
+                         (if rec-selection-mode
+                             (format "Edit %s / %s" rec-edit-mode-type 
selection-format)
+                           (format "Edit %s" (symbol-name 
rec-edit-mode-type))))
+                        
+                        (rec-selection-mode
+                         (rec-selection-stringify 
rec-selection-current-selection))
+
+                        (t (rec-record-type)))))
+    (when message
+      (setq mode-line-buffer-identification
+            (list 20 "%b "
+                  (propertize message 'face 'bold))))))
 
 (defun rec-set-head-line (str)
   "Set the headline in rec buffers to STR."
@@ -1343,14 +1399,31 @@ PROMPT is the prompt string to use."
 
 (defvar rec-summary-mode-map
   (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map tabulated-list-mode-map)
-    (define-key map "\C-m" 'rec-summary-cmd-jump-to-record)
+    (define-key map [return] 'rec-summary-cmd-jump-to-record)
+    (define-key map (kbd "RET") 'rec-summary-cmd-jump-to-record)
+    (define-key map (kbd "n") 'rec-summary-cmd-next)
+    (define-key map (kbd "p") 'rec-summary-cmd-prev)
+    (define-key map (kbd "q") 'rec-summary-quit)
     map)
   "Local keymap for `rec-summary-mode' buffers.")
 
-(defvar rec-summary-rec-buffer nil
+(defun rec-summary-quit ()
+  "Quit the summary."
+  (interactive)
+  (let ((record-buffer rec-summary-rec-buffer))
+    (kill-buffer (current-buffer))
+    (if (not (eq (selected-window) (next-window nil 'no-minibuf)))
+        (delete-window)
+      (switch-to-buffer record-buffer))))
+
+(defvar rec-summary-buffer nil
+  "The `rec-summary-mode' buffer associated with the rec file.
+
+This variable is not buffer local, as there can be only one
+summary buffer open for the current buffer.")
+
+(defvar-local rec-summary-rec-buffer nil
   "The `rec-mode' buffer paired with this summary buffer.")
-(make-variable-buffer-local 'rec-summary-rec-buffer)
 
 (define-derived-mode rec-summary-mode tabulated-list-mode "Rec Summary"
   "Major mode for summarizing the contents of a recfile.
@@ -1359,7 +1432,8 @@ PROMPT is the prompt string to use."
   (setq tabulated-list-format nil)
   (setq tabulated-list-padding 2)
   (setq tabulated-list-sort-key nil)
-  (tabulated-list-init-header))
+  (tabulated-list-init-header)
+  (add-hook 'post-command-hook #'rec-summary-sync-rec-buffer nil t))
 
 (defun rec-summary-populate (headers entries)
   "Populate a `rec-mode' summary buffer with the data in ENTRIES.
@@ -1373,6 +1447,44 @@ Argument HEADERS specifies the headers to display."
   (setq tabulated-list-entries entries)
   (tabulated-list-print nil))
 
+(defvar rec-summary-inhibit-sync nil
+  "Whether to prevent syncing the rec buffer.")
+
+(defun rec-summary-sync-rec-buffer ()
+  "Make sure the rec buffer of the summary shows the currently selected 
record."
+  (when  (and (not rec-summary-inhibit-sync)
+              rec-summary-rec-buffer
+              (tabulated-list-get-id))
+    (if (eobp)
+        (forward-line -1))
+    (unless (eobp)
+      (save-excursion
+        (let ((there (marker-position (tabulated-list-get-id)))
+              (old (selected-window))
+              (window (get-buffer-window rec-summary-rec-buffer t)))
+          (if window
+              (unwind-protect
+                  (progn
+                    (select-window window)
+                    (rec-goto-position there t))
+                (select-window old))
+            (with-current-buffer rec-summary-rec-buffer
+              (rec-goto-position there t))))))))
+
+(defun rec-summary-cmd-next ()
+  "Move to the next line in the summary."
+  (interactive)
+  (forward-line 1)
+  (rec-summary-update-overlay)
+  (display-buffer rec-summary-rec-buffer))
+
+(defun rec-summary-cmd-prev ()
+  "Move to the next line in the summary."
+  (interactive)
+  (forward-line -1)
+  (rec-summary-update-overlay)
+  (display-buffer rec-summary-rec-buffer))
+
 (defun rec-summary-cmd-jump-to-record ()
   "Jump to the selected record in the `rec-mode' buffer."
   (interactive)
@@ -1397,7 +1509,8 @@ Argument HEADERS specifies the headers to display."
 (cl-defun rec-query (&rest args
                            &key (type nil) (join nil) (index nil) (sex nil)
                            (fast-string nil) (random nil) (fex nil) (password 
nil)
-                           (group-by nil) (sort-by nil) (icase nil) (uniq nil))
+                           (group-by nil) (sort-by nil) (icase nil) (uniq nil) 
(no-sexps nil)
+                           (descriptor nil))
   "Perform a query in the current buffer using recsel.
 
 ARGS contains the arguments to pass to the program.
@@ -1424,9 +1537,13 @@ Optional argument SORT-BY sorts the output by given 
fields.
 
 Optional argument ICASE makes the selection case-insensitive.
 
-Optional argument UNIQ when non-nil, returns only unique results."
+Optional argument UNIQ when non-nil, returns only unique results.
+
+Optional argument NO-SEXPS when non-nil, returns the results in rec format.
+
+Optional argument DESCRIPTOR when non-nil, includes the record descriptor."
   (let ((buffer (generate-new-buffer "Rec Sel "))
-        args records status)
+        args status)
     (save-restriction
       (widen)
       (unwind-protect
@@ -1458,8 +1575,10 @@ Optional argument UNIQ when non-nil, returns only unique 
results."
               (setq args (cons "-i" args)))
             (when uniq
               (setq args (cons "-U" args)))
-            (when (and (not group-by) (not sort-by))
+            (when (and (not group-by) (not sort-by) (not no-sexps))
               (setq args (cons "--print-sexps" args)))
+            (when descriptor
+              (setq args (cons "-d" args)))
             ;; Call 'recsel' to perform the query.
             (setq status (apply #'call-process-region
                                 (point-min) (point-max)
@@ -1471,13 +1590,26 @@ Optional argument UNIQ when non-nil, returns only 
unique results."
             (if (/= status 0)
                 (error "Recsel returned error: %d" status))
             (with-current-buffer buffer
-              (goto-char (point-min))
-              (insert "(")
-              (goto-char (point-max))
-              (insert ")")
-              (setq records (read (point-min-marker)))))
-        (kill-buffer buffer)))
-    records))
+              (if (not no-sexps)
+                  (progn
+                    (goto-char (point-min))
+                    (insert "(")
+                    (goto-char (point-max))
+                    (insert ")")
+                    (read (point-min-marker)))
+                (buffer-substring-no-properties (point-min) (point-max)))))
+        (kill-buffer buffer)))))
+
+;;;; Cross referencing
+
+(defun rec-mode--xref-after-jump-hook ()
+  "After jumping via Xref, narrow to the current record if necssary."
+  (unless (derived-mode-p 'rec-edit-mode)
+    (rec-show-record)))
+
+(defun rec-mode--xref-widen-before-return ()
+  "Widen the buffer before returning from xref."
+  (widen))
 
 ;;;; Selection of records
 ;;
@@ -1494,7 +1626,7 @@ Optional argument UNIQ when non-nil, returns only unique 
results."
       (message "No current selection")
     (widen)
     (let* ((first-record (car rec-current-selection))
-           (pos (rec-record-position first-record)))
+           (pos (slot-value first-record 'position)))
       (goto-char pos)
       (rec-show-record))))
 
@@ -1505,34 +1637,400 @@ The result of the selection is stored in 
`rec-current-selection'."
   (interactive)
   (setq rec-current-selection (rec-query)))
 
-(defun rec-cmd-select-fast (prefix str)
-  "Perform a fast selection using a fast string search of STR.
+(defun rec-cmd-jump-to-fast (prefix fast-string)
+  "Jump to the first record matching FAST-STRING.
 
 Argument PREFIX when non-nil means to use a case-insensitive search."
   (interactive "P\nsFast string query: ")
   (when (not (equal str ""))
-    (setq rec-current-selection (rec-query :fast-string str
-                                           :icase prefix
-                                           :type (rec-record-type)))
+    (setq rec-current-selection
+          (rec--parse-sexp-records
+           (rec-query :fast-string fast-string
+                      :icase prefix
+                      :type (rec-record-type))))
     (rec-navigate-selection)))
 
-(defun rec-cmd-select-sex (prefix sex)
-  "Perform a selection on the current record set using a selection expression.
+(defun rec-cmd-jump-to-sex (prefix sex)
+  "Jump to the first record matching SEX.
 
 A PREFIX argument means to use a case-insensitive search.
 Argument SEX is the selection expression to use."
   (interactive "P\nsSelection expression: ")
   (when (not (equal sex ""))
-    (setq rec-current-selection (rec-query :sex sex
-                                           :icase prefix
-                                           :type (rec-record-type)))
+    (setq rec-current-selection
+          (rec--parse-sexp-records
+           (rec-query :sex sex
+                      :icase prefix
+                      :type (rec-record-type))))
     (rec-navigate-selection)))
 
+;;;;; Selecting into a new buffer
+
+(defun rec--new-buffer-for-selection (selection expr)
+  "Generate a new buffer for SELECTION and switch to it."
+  (if selection
+    (let* ((name (generate-new-buffer-name
+                  (format "*Selection of %s*" (buffer-name))))
+           (origin (buffer-name))
+           (buf (get-buffer-create name)))
+      (with-current-buffer buf
+        (insert
+         (format "# Generated from %s using expression %s" origin expr))
+        (newline)
+        (insert selection)
+        (goto-char (point-min))
+        (rec-edit-mode)
+        (run-hooks 'hack-local-variables-hook))
+      (rec-update-buffer-descriptors)
+      (switch-to-buffer buf))
+    (user-error "No results.")))
+
+(defun rec-cmd-new-buffer-from-sex (sex)
+  "Query the current buffer using SEX and insert the result into a new buffer."
+  (interactive
+   (list (read-string "Selection expression: "
+                      nil
+                      'rec-selection-sex-history)))
+  (when sex
+    (rec--new-buffer-for-selection
+     (rec-query :type (rec-record-type)
+                :sex sex
+                :descriptor t
+                :no-sexps t)
+     sex)))
+
+
+(defun rec-cmd-new-buffer-from-fast-string (fast-string)
+  "Query the current buffer using FAST-STRING and insert the result into a new 
buffer."
+  (interactive
+   (list (read-string "Fast string search: "
+                      nil
+                      'rec-selection-fast-history)))
+  (when fast-string
+    (rec--new-buffer-for-selection
+     (rec-query :type (rec-record-type)
+                :fast-string fast-string
+                :descriptor t
+                :no-sexps t)
+     fast-string)))
+
+
+;;;;; Record selection mode
+
+(defvar-local rec-selection-mode nil)
+
+;;;;;; Classes that represent the current selection
+
+(cl-defgeneric rec-selection-query (selection &optional fex)
+  "Query records on the current buffer using SELECTION.
+Optionally select only the fields in FEX.")
+
+(cl-defgeneric rec-selection-stringify (selection)
+  "Return a string representation of SELECTION.")
+
+(cl-defgeneric rec-selection-expr (selection)
+  "Return the actual expression used in the selection.")
+
+(defclass rec-selection ()
+  ((type :initarg :type
+         :initform nil)
+   (icase :initarg :icase))
+  "A query to restrict candidates for the current buffer.")
+
+(defclass rec-selection-fast (rec-selection)
+  ((fast :initarg :fast)))
+
+(cl-defmethod rec-selection-expr ((selection rec-selection-fast))
+  (slot-value selection 'fast))
+
+(cl-defmethod rec-selection-stringify ((selection rec-selection-fast))
+  (with-slots (type fast) selection
+    (format "%s[%s]" type fast)))
+
+(cl-defmethod rec-selection-query ((selection rec-selection-fast) &optional 
fex)
+  "Query records using a fast string search."
+  (with-slots (type icase fast) selection
+    (rec-query :type type
+               :fex fex
+               :icase icase
+               :fast-string fast)))
+
+(defclass rec-selection-sex (rec-selection)
+  ((sex :initarg :sex)))
+
+(cl-defmethod rec-selection-expr ((selection rec-selection-sex))
+  (slot-value selection 'sex))
+
+(cl-defmethod rec-selection-stringify ((selection rec-selection-sex))
+  (with-slots (type sex) selection
+    (format "%s / %s" type sex)))
+
+(cl-defmethod rec-selection-query ((selection rec-selection-sex) &optional fex)
+  "Query records using a selection expression."
+  (with-slots (type icase sex) selection
+    (rec-query :type type
+               :fex fex
+               :icase icase
+               :sex sex)))
+
+;;;;;; Variables for containing the selectionk
+
+(defvar-local rec-selection-current-selection nil
+  "The currently active selection expression.")
+
+(defvar-local rec-selection-current-record-type nil
+  "The record type being navigated in selection mode.")
+
+(defvar-local rec-selection-previous-mode-line nil
+  "The mode line text before the selection.")
+
+(defvar rec-selection-sex-history nil
+  "The history of record selection history.")
+
+;;;;;; Functions for entering selection mode
+
+(defun rec-begin-selection (selection)
+  "Enter `rec-selection-mode' via SELECTION."
+  (when (or (not rec-selection-mode)
+            (y-or-n-p "You are currently navigating a selection.  Do you want 
to quit navigation and start with another selection? "))
+    (let ((results (rec--parse-sexp-records
+                    (rec-selection-query selection))))
+      (if results
+          (progn
+            (setq rec-current-selection results)
+            (when rec-selection-mode
+              (rec-cmd-exit-selection))
+            
+            (setq rec-selection-previous-mode-line 
mode-line-buffer-identification)
+            (setq rec-selection-current-selection selection)
+            (rec-selection-mode)
+            (save-window-excursion
+              (when (buffer-live-p rec-summary-buffer)
+                (rec-cmd-show-summary)))
+            (rec-cmd-goto-next-selection-record 0))
+        (user-error "The search returned no results")))))
+
+(defun rec-cmd-navigate-current-type-by-sex (prefix sex)
+  "Query records with SEX and restrict navigation to those records.
+Prefix argument PREFIX if non-nil means ignore case.
+
+See `rec-selection-mode'."
+  (interactive
+   (let ((prev (if rec-selection-current-selection
+                   (rec-selection-expr rec-selection-current-selection))))
+     (list current-prefix-arg
+           (read-string
+            (format "Navigate %s records by selection expression%s: "
+                    (rec-record-type)
+                    (if prev
+                        (format " (default %s)" prev)
+                      ""))
+            nil 'rec-selection-sex-history prev))))
+  (when (not (equal sex ""))
+    (rec-begin-selection
+     (rec-selection-sex :sex sex
+                        :icase prefix
+                        :type (rec-record-type)))))
+
+(defvar rec-selection-fast-history nil
+  "The history of record selection history (fast search).")
+
+(defun rec-cmd-navigate-current-type-by-fast-string (prefix fast-string)
+  "Query records with fast-string  and restrict navigation to those records.
+
+Prefix argument PREFIX if non-nil means ignore case.
+
+See `rec-selection-mode'."
+  (interactive
+   (let ((prev (if rec-selection-current-selection
+                   (rec-selection-expr rec-selection-current-selection))))
+     (list current-prefix-arg
+           (read-string
+            (format "Navigate %s records by fast string search%s: "
+                    (rec-record-type)
+                    (if prev
+                        (format " (default %s)" prev)
+                      ""))
+            nil 'rec-selection-fast-history prev))))
+  (when (not (equal fast-string ""))
+    (rec-begin-selection
+     (rec-selection-fast :fast fast-string
+                         :type (rec-record-type)
+                         :icase prefix))))
+
+(defun rec-cmd-exit-selection ()
+  "Exit `rec-selection-mode'."
+  (interactive)
+  (when rec-selection-mode
+    (rec-selection-mode -1)
+    (save-window-excursion
+      (when (buffer-live-p rec-summary-buffer)
+        (rec-cmd-show-summary)))
+    (put 'rec-summary-buffer 'selection nil)
+    (setq mode-line-buffer-identification rec-selection-previous-mode-line)))
+
+(defvar rec-show-hook nil
+  "List of functions to call when a record is shown.")
+
+(defun rec-cmd-goto-next-selection-record (n)
+  "Goto the next record in the current selection.
+
+Prefix arguments N moves next by N records."
+  (interactive "P")
+  (if rec-current-selection
+      (let* ((record (rec-current-record))
+             (pos (slot-value record 'position))
+             (where-am-i
+              (cl-position-if
+               (lambda (rec)
+                 (= pos (byte-to-position (slot-value rec 'position))))
+               rec-current-selection))
+             (next (if (numberp where-am-i)
+                       (nth (+ where-am-i (or n 1)) rec-current-selection)
+                     (car rec-current-selection))))
+        (if (and next (or (/= pos (slot-value next 'position)) (zerop n)))
+            (rec-goto-record next)
+          (user-error
+           (if rec-selection-current-selection
+               (format "No more records of type %s in selection %s"
+                       (slot-value rec-selection-current-selection 'type)
+                       (rec-selection-expr rec-selection-current-selection))
+             (format "No more records in selection %s" (rec-selection-expr 
rec-selection-current-selection))))))
+    (user-error "No active selection")))
+
+(defun rec-cmd-goto-prev-selection-record (n)
+  "Goto the previous record in the current selection.
+
+Prefix arguments N moves next by N records."
+  (interactive "P")
+  (rec-cmd-goto-next-selection-record (- (or n 1))))
+
+
+
+;;;;; Selection cross reference
+
+(cl-defgeneric rec--xref-summary-for-record (record type kind)
+  "Return a formated summary line for RECORD of type TYPE.")
+
+(cl-defgeneric rec--xref-truncate-fields (record kind)
+  "Truncate fields of RECORD of search KIND.")
+
+(cl-defgeneric rec--xref-truncate-fields (record (_kind (head sex)))
+  "Truncate fields from a selection expression SEX of RECORD.
+
+Takes up to the first three elements of a record and displays them, padded
+with four spaces."
+  (let* ((rec-fields (slot-value record 'fields))
+        (fields (mapconcat
+                 (lambda (field)
+                   (concat
+                    "    "
+                    (with-temp-buffer
+                      (rec-insert field)
+                      (string-trim-right
+                       (rec-mode--syntax-highlight (buffer-string))))))
+                 (cl-subseq rec-fields 0 3 )
+                 "\n")))
+    (if (< 3 (length rec-fields))
+                (concat fields "\n    ...")
+      fields)))
+
+(cl-defgeneric rec--xref-truncate-fields (record (kind (head fast)))
+  "Truncate fields for KIND fast string searches in RECORD."
+  (let* ((fields (slot-value record 'fields))
+         (matching (seq-filter
+                    (lambda (field)
+                      (string= (slot-value field 'value)
+                               (cdr kind)))
+                    fields)))
+    (mapconcat
+     (lambda (field)
+       (concat "    "
+               (let* ((full (rec-mode--syntax-highlight
+                             (with-temp-buffer
+                               (rec-insert field)
+                               (string-trim-right
+                                (buffer-string))))))
+                 (when (string-match (regexp-quote
+                                      (cdr kind))
+                                     full)
+                   (put-text-property (match-beginning 0)
+                                      (match-end 0)
+                                      'face
+                                      'highlight
+                                      full))
+                 full)))
+     matching
+     "\n")))
+
+(defun rec--xref-summary-for-record (record type kind)
+  "Base class method to do the rest of the formating."
+  (let* ((line-number (number-to-string
+                       (line-number-at-pos
+                        (slot-value record 'position) t)))
+         (heading (concat (propertize type 'face 'font-lock-type-face)
+                          " at line "
+                          line-number)))
+    
+    (add-face-text-property 0 (length heading) 'bold nil heading)
+    (format "%s\n%s"
+            heading
+            (rec--xref-truncate-fields record kind))))
+
+(defun rec--xref-query (query kind)
+  "Make a XREF results list using QUERY identified by KIND."
+  (let* ((results (rec--parse-sexp-records query))
+         (descriptor (cl-find-if #'rec-record-descriptor-p results))
+         (type (if descriptor
+                   (slot-value descriptor 'type)
+                 "Record")))
+    (when results
+      (xref--show-xrefs
+       (mapcar
+        (lambda (record)
+          (xref-make
+           (rec--xref-summary-for-record record type kind)
+           (xref-buffer-location :buffer (current-buffer)
+                                 :position (slot-value record 'position))))
+        (cdr results))
+       nil))))
+
+(defun rec-cmd-xref-sex (sex)
+  "Cross reference records for SEX.
+
+Creates an XREF buffer with entries of the current record type
+in the current buffer matching the selection expression."
+  (interactive
+   (list (read-string "Selection expression: "
+                      nil 'rec-selection-sex-history)))
+  (rec--xref-query
+   (rec-query :sex sex
+              :descriptor t
+              :icase t
+              :type (rec-record-type))
+   (cons 'sex sex)))
+
+
+(defun rec-cmd-xref-fast-string (fast-string)
+  "Cross reference records for FAST-STRING.
+
+Creates an XREF buffer with entries of the current record type
+in the current buffer matching the fast string search."
+  (interactive
+   (list (read-string "Fast string search: "
+                      nil 'rec-selection-sex-history)))
+  (rec--xref-query
+   (rec-query :fast-string fast-string
+              :descriptor t
+              :icase t
+              :type (rec-record-type))
+   (cons 'fast fast-string)))
+
+
 ;;;; Commands
 ;;
 ;; The following functions implement interactive commands available in
 ;; the several modes defined in this file.
-
 (defvar rec-field-name)
 (make-variable-buffer-local 'rec-field-name)
 (defvar rec-buffer)
@@ -1543,11 +2041,18 @@ Argument SEX is the selection expression to use."
 (make-variable-buffer-local 'rec-update-p)
 (defvar rec-preserve-last-newline nil)
 (make-variable-buffer-local 'rec-preserve-last-newline)
-(defvar rec-editing nil)
-(make-variable-buffer-local 'rec-editing)
 
-(defvar rec-prev-buffer)                ;FIXME: Should it have a global value?
-(defvar rec-pointer)                    ;FIXME: Buffer local?  Global value?
+(defvar rec-prev-buffer nil
+  "The previous buffer we were in before jumping into `rec-edit-field-mode'.")
+(make-variable-buffer-local 'rec-prev-bufffer)
+
+(defvar rec-pointer nil
+  "The previous position in `rec-prev-buffer' we were at, before jumping into 
`rec-edit-field-mode'.")
+(make-variable-buffer-local 'rec-point)
+
+(defvar rec-prev-window-configuration nil
+  "The window configuration that was active before jumping into 
`rec-edit-field-mode'.")
+(make-variable-buffer-local 'rec-prev-window-configuration)
 
 (defconst rec-cmd-edit-field-message
   "Edit the value of the field and use \\[rec-finish-editing-field] to exit"
@@ -1557,7 +2062,7 @@ Argument SEX is the selection expression to use."
   "Edit the contents of the field under point in a separate buffer.
 
 The input method used for getting the field value depends on its
-type, unless a prefix argument N specifies.is used.  Then the more general
+type, unless a prefix argument N is used.  Then the more general
 method, i.e. asking for the new value in an unrestricted buffer,
 will be used for fields of any type."
   (interactive "P")
@@ -1615,10 +2120,11 @@ will be used for fields of any type."
                  fast-selection-data)
                 (rec-delete-field)
                 (save-excursion
-                  (rec-insert-field (list 'field
-                                          0
-                                          field-name
-                                          new-value)))))))
+                  (rec-insert
+                   (rec-field :position 0
+                              :name field-name
+                              :value new-value)))
+                (rec-finish-editing-move)))))
          ((and (equal field-type-kind 'date) rec-popup-calendar
                (null n))
           (setq rec-field-name field-name)
@@ -1640,10 +2146,11 @@ will be used for fields of any type."
                 (let ((inhibit-read-only t))
                   (rec-delete-field)
                   (save-excursion
-                    (rec-insert-field (list 'field
-                                            0
-                                            rec-field-name
-                                            (format-time-string 
rec-time-stamp-format)))))))
+                    (rec-insert
+                     (rec-field :position 0
+                                :name rec-field-name
+                                :value (format-time-string 
rec-time-stamp-format))))
+                  (rec-finish-editing-move))))
             (define-key map (kbd "RET")
               (lambda () (interactive)
                 (let* ((date (calendar-cursor-to-date))
@@ -1654,10 +2161,11 @@ will be used for fields of any type."
                   (let ((inhibit-read-only t))
                     (rec-delete-field)
                     (save-excursion
-                      (rec-insert-field (list 'field
-                                              0
-                                              rec-field-name
-                                              (format-time-string "%Y-%m-%d" 
time))))))))
+                      (rec-insert
+                       (rec-field :position 0
+                                  :name rec-field-name
+                                  :value (format-time-string "%Y-%m-%d" 
time))))
+                    (rec-finish-editing-move)))))
             (use-local-map map)
             (message "[RET]: Select date [t]: Time-stamp     [q]: Exit")))
          (t
@@ -1670,35 +2178,61 @@ will be used for fields of any type."
             (set-marker rec-marker pointer prev-buffer)
             (setq rec-prev-buffer prev-buffer)
             (setq rec-pointer pointer)
+            (setq rec-prev-window-configuration (current-window-configuration))
             (insert field-value)
             (switch-to-buffer-other-window edit-buf)
             (goto-char (point-min))
             (message (substitute-command-keys rec-cmd-edit-field-message)))))
       (message "Not in a field"))))
 
-(defun rec-finish-editing-field ()
-  "Stop editing the value of a field."
-  (interactive)
+(defun rec-finish-editing-move ()
+  "Move point to the next field or line after editing.
+
+If there is no next field, move forward one line, unless
+`rec-editing' is nil, we are on a single record, so we're not
+going to move past the last line.
+
+If the movement would jump to a next record, this moves forward one line.
+
+If `rec-move-to-next-line-after-edit' is nil, do nothing."
+  (when rec-move-to-next-line-after-edit
+    (if (let ((this-end (rec-end-of-record-pos)))
+          (save-excursion
+            (rec-goto-next-field)
+            (< (line-end-position) this-end)))
+        (rec-goto-next-field)
+      (when (derived-mode-p 'rec-edit-mode)
+        (forward-line 1)))))
+
+(defun rec-finish-editing-field (&optional stay)
+  "Stop editing the value of a field, and move on the next field.
+
+If no field is next, move forward one line.
+
+If `rec-move-to-next-line-after-edit' is non-nil, moves to the
+next field or line.
+
+Prefix argument STAY means stay on the field we just edited."
+  (interactive "P")
   (let ((marker rec-marker)
         (prev-pointer rec-pointer)
         (edit-buffer (current-buffer))
         (name rec-field-name)
         (value (buffer-substring-no-properties (point-min) (point-max))))
-    (if (equal (length (window-list)) 1)
-        (set-window-buffer (selected-window) rec-prev-buffer)
-      (delete-window))
+    (set-window-configuration rec-prev-window-configuration)
     (switch-to-buffer rec-prev-buffer)
     (let ((inhibit-read-only t))
       (kill-buffer edit-buffer)
       (goto-char marker)
       (rec-delete-field)
-      (rec-insert-field (list 'field
-                              0
-                              name
-                              value))
+      (rec-insert (rec-field :position 0
+                             :name name
+                             :value value))
       (goto-char prev-pointer)
-      (unless rec-editing
-        (rec-hide-continuation-line-markers)))))
+      (unless (derived-mode-p 'rec-edit-mode)
+        (rec-hide-continuation-line-markers))
+      (unless stay
+        (rec-finish-editing-move)))))
 
 (defun rec-beginning-of-field ()
   "Goto to the beginning of the current field."
@@ -1759,12 +2293,12 @@ Interactive version of `rec-goto-next-field'."
   (interactive)
   (if (save-excursion
         (not (rec-goto-next-field)))
-      (if rec-editing
+      (if (derived-mode-p 'rec-edit-mode)
           (progn
             (goto-char (point-min))
             (unless (looking-at rec-field-name-re)
               (rec-goto-next-field)))
-      (rec-beginning-of-record))
+        (rec-beginning-of-record))
     (rec-goto-next-field)))
 
 (defun rec-cmd-goto-next-rec (&optional n)
@@ -1789,8 +2323,9 @@ Optional argument N specifies number of records to skip."
            (message "No more records")
          (message "%s" (concat "No more records of type "
                                (rec-record-type)))))))
-  (unless rec-editing
-    (rec-show-record)))
+  (unless (derived-mode-p 'rec-edit-mode)
+    (rec-show-record)
+    (rec-summary-move-to-record (rec-current-record))))
 
 (defun rec-cmd-goto-previous-rec (&optional n)
   "Move to the previous record of the same type.
@@ -1815,8 +2350,9 @@ Optional argument N specifies number of records to skip."
            (message "No more records")
          (message "%s" (concat "No more records of type "
                                (rec-record-type)))))))
-  (unless rec-editing
-    (rec-show-record)))
+  (unless (derived-mode-p 'rec-edit-mode)
+    (rec-show-record))
+  (rec-summary-move-to-record (rec-current-record)))
 
 (defun rec-cmd-undo ()
   "Undo a change in the buffer when in navigation mode."
@@ -1831,59 +2367,63 @@ Optional argument N specifies number of records to 
skip."
       (progn
         (widen)
         (goto-char (marker-position rec-jump-back))
-        (unless rec-editing
+        (unless (derived-mode-p 'rec-edit-mode)
           (rec-show-record))
         (setq rec-jump-back nil))
     (message "No previous position to jump")))
 
+(defvar-local rec-edit-mode-type nil
+  "The kind of thing we are navigating.
+
+One of ‘buffer‘, ‘record‘ or ‘type‘.")
+
 (defun rec-edit-record ()
   "Go to the record edition mode."
   (interactive)
-  (setq rec-editing t)
-  (rec-unfold-all-fields)
-  (rec-remove-continuation-line-marker-overlays)
-  (setq buffer-read-only nil)
-  (use-local-map rec-mode-edit-map)
+  (major-mode-suspend)
+  (save-restriction
+    (rec-edit-mode))
   (rec-set-head-line (substitute-command-keys "Editing record - use 
\\[rec-finish-editing] to return to navigation mode"))
-  (rec-set-mode-line "Edit record")
+  (setq rec-edit-mode-type 'record)
+  (rec-update-mode-line)
   (setq rec-update-p nil)
   (setq rec-preserve-last-newline t))
 
 (defun rec-edit-type ()
   "Go to the type edition mode."
   (interactive)
-  (setq rec-editing t)
-  (rec-unfold-all-fields)
-  (rec-remove-continuation-line-marker-overlays)
-  (setq buffer-read-only nil)
-  (use-local-map rec-mode-edit-map)
+  (major-mode-suspend)
+  (rec-edit-mode)
   (widen)
   (rec-narrow-to-type (rec-record-type))
   (setq rec-update-p t)
   (rec-set-head-line (concat "Editing type "
                              "'" (rec-record-type) "'"
                              (substitute-command-keys " - use 
\\[rec-finish-editing] to return to navigation mode")))
-  (rec-set-mode-line "Edit type"))
+  (setq rec-edit-mode-type 'type)
+  (rec-update-mode-line))
 
 (defun rec-edit-buffer ()
   "Go to the buffer edition mode."
   (interactive)
-  (setq rec-editing t)
-  (rec-unfold-all-fields)
-  (rec-remove-continuation-line-marker-overlays)
-  (setq buffer-read-only nil)
-  (use-local-map rec-mode-edit-map)
+  (major-mode-suspend)
+  (rec-edit-mode)
   (widen)
   (setq rec-update-p t)
   (rec-set-head-line (substitute-command-keys "Editing buffer - use 
\\[rec-finish-editing] to return to navigation mode"))
-  (rec-set-mode-line "Edit buffer"))
+  (setq rec-edit-mode-type 'buffer)
+  (rec-update-mode-line)
+  (recenter-top-bottom))
 
 (defun rec-finish-editing ()
-  "Go back from the record edition mode."
+  "Go back from the record, type or buffer edition mode."
   (interactive)
   (when (or (not rec-update-p)
             (and rec-update-p
                  (save-restriction (widen) 
(rec-update-buffer-descriptors-and-check t))))
+    (save-excursion
+      (save-restriction
+        (major-mode-restore)))
     (or (rec-current-record)
         (rec-goto-next-rec)
         (rec-goto-previous-rec))
@@ -1895,8 +2435,7 @@ Optional argument N specifies number of records to skip."
     (setq rec-update-p nil)
     (rec-show-record)
     (rec-set-head-line nil)
-    (rec-set-mode-line (rec-record-type))
-    (setq rec-editing nil)
+    (rec-update-mode-line)
     (message "End of edition")))
 
 (defun rec-cmd-show-descriptor ()
@@ -1907,7 +2446,7 @@ This jump sets jump-back."
   (let ((type (rec-record-type)))
     (when type
       (setq rec-jump-back (point-marker))
-      (if rec-editing
+      (if (derived-mode-p 'rec-edit-mode)
           (rec-goto-type type)
         (rec-show-type type t)))))
 
@@ -1982,7 +2521,7 @@ This command is especially useful with enumerated types."
 (defun rec-cmd-append-field ()
   "Goto the end of the record and switch to edit record mode."
   (interactive)
-  (unless rec-editing
+  (unless (derived-mode-p 'rec-edit-mode)
     (rec-edit-record)
     (goto-char (point-max))
     (insert "\n")
@@ -1996,7 +2535,7 @@ This command is especially useful with enumerated types."
           (field (rec-current-field)))
       (setq field (rec-field-trim-value field))
       (rec-delete-field)
-      (rec-insert-field field))))
+      (rec-insert field))))
 
 (defun rec-cmd-compile ()
   "Compile the current file with recfix."
@@ -2091,48 +2630,169 @@ This command is especially useful with enumerated 
types."
           (message "record copied to kill ring"))
       (message "Not in a record"))))
 
-(defun rec-cmd-show-summary ()
+;;;; Summary
+
+(defvar-local rec-summary-overlay nil
+  "The overlay on a highlighted record summary line.")
+
+(defun rec-summary-update-overlay ()
+  (unless rec-summary-overlay
+    (setq rec-summary-overlay (make-overlay (point) (point))))
+  (move-overlay rec-summary-overlay
+                (line-beginning-position)
+                (line-end-position))
+  (overlay-put rec-summary-overlay 'face 'highlight))
+
+(defmacro rec-select-summary (&rest body)
+  "Execute BODY in the rec summary, if it exists."
+  (declare (indent 0) (debug (&rest form)))
+  `(if (and rec-summary-buffer (get-buffer-window rec-summary-buffer t))
+       (let ((selected (selected-window)))
+         (save-excursion
+           (unwind-protect
+               (progn
+                 (pop-to-buffer rec-summary-buffer)
+                 ,@body)
+             (select-window selected))))
+     (with-current-buffer rec-summary-buffer
+       ,@body)))
+
+(defun rec-summary-move-to-record (record)
+  "Move the cursor in the summary buffer to the position of RECORD."
+  (when (buffer-live-p rec-summary-buffer)
+    (let ((target (slot-value record 'position))
+          (rec-summary-inhibit-sync t)
+          where)
+      (with-current-buffer rec-summary-buffer
+        (goto-char (point-min))
+        (cl-loop for current = (marker-position (tabulated-list-get-id))
+                 until (eq target current)
+                 do (forward-line 1)
+                 finally (setq where (point))))
+      (when (integer-or-marker-p where)
+        (rec-select-summary
+          (goto-char where)
+          (rec-summary-update-overlay))))))
+
+(defvar-local rec-summary-selection nil
+  "The selection that was used to display the summary.")
+
+(defun rec-cmd-show-summary (&optional use-selection)
   "Show a window with a summary of the contents of the current record set.
 
 The fields used to build the summary are determined in the
 following way: if there is a %summary field in the record
 descriptor of the current record set then it must contain a comma
 separated list of fields.  Otherwise the %key is used.  Otherwise
-the user is prompted."
+the user is prompted.
+
+When USE-SELECTION is non-nil, present the summary buffer for the currently
+active selection in `rec-selection-current-selection'."
   (interactive)
-  (let ((summary-buffer-name (concat (buffer-name (current-buffer)) " 
Summary")))
-    (if (buffer-live-p (get-buffer summary-buffer-name))
-        (progn
-          (delete-other-windows)
-          (split-window-vertically 10)
-          (switch-to-buffer summary-buffer-name))
+  (let* ((summary-buffer-name (concat (buffer-name (current-buffer)) " 
Summary"))
+         (current-record (save-excursion
+                           (rec-beginning-of-record)
+                           (rec-current-record)))
+         (buffer (or rec-summary-buffer (get-buffer summary-buffer-name))))
+    (when (and (buffer-live-p buffer)
+               ;; Kill the buffer if we have a selection but
+               ;; the buffer is not on a selection and vice versa.
+               (or (and (get 'rec-summary-buffer 'selection)
+                        (not rec-selection-mode))
+                   (and (not (get 'rec-summary-buffer 'selection))
+                        rec-selection-mode)))
+      (kill-buffer buffer))
+    (if (buffer-live-p buffer)
+        (switch-to-buffer rec-summary-buffer)
       (let ((summary-fields (rec-summary-fields)))
         (unless summary-fields
           (setq summary-fields (list (rec-key)))
           (unless (car summary-fields)
             (setq summary-fields (split-string (read-from-minibuffer "Fields 
to use in the summary: ") "[ ,]"))))
         (if (car summary-fields)
-            (let* ((query (rec-query :fex (string-join summary-fields ",")))
-                   (summary-list (mapcar (lambda (rec)
-                                           (let ((entry-marker (make-marker)))
-                                             (set-marker entry-marker 
(rec-record-position rec))
-                                             (list entry-marker (vconcat 
(rec-record-values rec summary-fields)))))
-                                         query)))
+            (let* ((fex (string-join summary-fields ","))
+                   (query (if (and rec-selection-mode 
rec-selection-current-selection)
+                              (rec-selection-query 
rec-selection-current-selection fex)
+                            (rec-query :type (rec-record-type)
+                                       :fex fex)))
+                   (summary-list
+                    (mapcar (lambda (rec)
+                              (let* ((entry-marker (make-marker)))
+                                (set-marker entry-marker
+                                            (byte-to-position (slot-value rec 
'position)))
+                                (list entry-marker
+                                      (vconcat
+                                       (cl-loop for field in summary-fields
+                                                for value = (car 
(rec-record-assoc field rec ))
+                                                collect (or value ""))))))
+                            (rec--parse-sexp-records query))))
               ;; Create the summary window if it does not exist and populate
               ;; it.
               (let ((rec-buf (current-buffer))
-                    (buf (get-buffer-create (concat (buffer-name 
(current-buffer)) " Summary"))))
-                (delete-other-windows)
-                (split-window-vertically 10)
-                (switch-to-buffer buf)
-                (let ((inhibit-read-only t))
+                    (rec-summary-inhibit-sync t)
+                    (selection rec-selection-current-selection)
+                    (buf (get-buffer-create summary-buffer-name)))
+                (setq rec-summary-buffer buf)
+                (when rec-selection-mode
+                  (put 'rec-summary-buffer 'selection (rec-selection-stringify 
rec-selection-current-selection)))
+                (when rec-summary-deletes-other-windows
+                  (delete-other-windows))
+                ;; If there's just one window, split the buffer.
+                (let ((split-width-threshold nil)) ;; Forbid horiz split.
+                  (if (and (one-window-p)
+                           pop-up-windows
+                           (not pop-up-frames))
+                      (progn
+                        
+                        (split-window (selected-window) 
rec-summary-window-height)
+                        (select-window (next-window (frame-first-window)))
+                        (pop-to-buffer buf)
+                        (if (not (eq buf (window-buffer (frame-first-window))))
+                                 (delete-other-windows)))
+                    (pop-to-buffer buf))
+                  (set-buffer rec-buf)
+                  (rec-select-summary nil)
+                  (set-buffer buf))
+                (let ((inhibit-read-only t)
+                      (rec-summary-buffer buf))
                   (delete-region (point-min) (point-max))
-                  (setq rec-summary-rec-buffer rec-buf)
                   (rec-summary-mode)
+                  (setq rec-summary-selection selection)
+                  (setq rec-summary-rec-buffer rec-buf)
                   (rec-summary-populate (vconcat (mapcar (lambda (field) (list 
field 15 nil)) summary-fields)) summary-list)
-                  (hl-line-mode 1))))
+                  (rec-summary-move-to-record current-record))))
           (message "No fields to build the summary."))))))
 
+;;;; Record movement
+
+(defun rec-goto-position (pos &optional skip-summary)
+  "Move to POS, and highlight the record there.
+
+Optional argument SKIP-SUMMARY means do not sync buffer
+positions, this is useful when the callee of this function is the
+summary buffer."
+  (if (derived-mode-p 'rec-edit-mode)
+      (progn
+        (goto-char pos)
+        (pulse-momentary-highlight-region (rec-beginning-of-record-pos)
+                                          (rec-end-of-record-pos)
+                                          'next-error)
+        (rec-update-mode-line))
+    (progn
+      (widen)
+      (goto-char pos)
+      (rec-show-record)))
+  (unless skip-summary
+    (rec-summary-move-to-record (rec-current-record))))
+
+(defun rec-goto-record (record)
+  "Go to the position of RECORD.
+
+The record is assumed to have its position in bytes, not
+characters."
+  (rec-goto-position (slot-value record 'position)))
+
+
 ;;;; Interacting with other modes
 
 (defun rec-log-current-defun ()
@@ -2148,8 +2808,130 @@ function returns nil."
           (let ((values (rec-record-assoc key record)))
             (if values
                 (car values)
-              (rec-field-value (car (rec-record-elems record)))))
-        (rec-field-value (car (rec-record-elems record)))))))
+              (rec-field-value (car (slot-value record 'fields)))))
+        (rec-field-value (car (slot-value record 'fields)))))))
+
+
+;;;; Flymake support
+
+;; Tell the byte compiler this function is available.  This is new in Emacs 26,
+;; so as long as we support Emacs 25 this will remain.  Note that the hook
+;; `flymake-diagnostic-functions' is not in Flymake of Emacs 25, so this
+;; function never gets called on Emacs 25.  So Flymake is not going to work on
+;; Emacs <26, but the alternative would be to explicitly Package-Require a new,
+;; backported version of Flymake from ELPA, but we would like to limit these to
+;; a minimum.
+(declare-function flymake-make-diagnostic "flymake")
+
+(defvar-local rec-mode--recfix-process nil
+  "Buffer-local process for recfix'ing the buffer.")
+
+(defun rec-mode-flymake-recfix-diagnostics (source-buffer output-buffer)
+  "Read diagnostics for SOURCE-BUFFER using the results in OUTPUT-BUFFER."
+  (with-current-buffer source-buffer
+    (save-restriction
+      (set-buffer source-buffer)
+      (widen)
+      (with-current-buffer output-buffer
+        (goto-char (point-min))
+        (cl-loop
+         while (search-forward-regexp
+                "^.*?:\s*\\([0-9]+\\): .*?: \\(.*\\)$"
+                nil
+                t)
+         for (beg . end) = (flymake-diag-region
+                            source-buffer
+                            (string-to-number (match-string 1))
+                            nil)
+         for msg = (match-string 2)
+         collect (flymake-make-diagnostic source-buffer beg end :error 
msg))))))
+
+;;;###autoload
+(defun rec-mode-flymake-recfix (report-fn &rest _args)
+  "A Flymake backend for recfile compilation. 
+
+Defers to `recfix' for checking the buffer, calling REPORT-FN
+to report the errors."
+  (when (executable-find rec-recfix)
+    (when (process-live-p rec-mode--recfix-process)
+      (kill-process rec-mode--recfix-process))
+    (let ((source-buffer (current-buffer))
+          (output-buffer (generate-new-buffer " *flymake-recfix*")))
+      (setq
+       rec-mode--recfix-process
+       (make-process
+        :name "rec-mode-flymake-recfix"
+        :stderr output-buffer
+        :buffer "*stdout of flymake-recfix*"
+        :command (list rec-recfix)
+        :connection-type 'pipe
+        :sentinel
+        (lambda (proc _event)
+          (when (eq (process-status proc) 'exit)
+            (unwind-protect
+                (let ((diagnostics (rec-mode-flymake-recfix-diagnostics 
source-buffer output-buffer)))
+                  (if (or diagnostics (zerop (process-exit-status proc)))
+                      (funcall report-fn diagnostics)
+                    (funcall report-fn
+                             :panic
+                             :explanation
+                             (format "recfix process %s died" proc))))
+              (kill-buffer output-buffer))))
+        :noquery t))
+      (save-restriction
+        (widen)
+        (process-send-string rec-mode--recfix-process
+                             (buffer-substring-no-properties (point-min) 
(point-max)))
+        (process-send-eof rec-mode--recfix-process)))))
+
+;;;###autoload
+(defun rec-mode-eldoc-function (&rest _ignore)
+  "ElDoc documentation function for `rec-mode'."
+  (when (rec-current-field)
+    (let* ((name (rec-field-name (rec-current-field)))
+           (field-type (rec-current-field-type))
+           (type (rec-type-kind field-type))
+           (data (rec-type-data field-type)))
+      (when (and (not (null name))
+                 (not (null type)))
+        (rec-mode--syntax-highlight
+         (format "%s: %s %s"
+                 name
+                 (symbol-name type)
+                 (if (listp data)
+                     (mapconcat (lambda (datum)
+                                  (if (stringp datum)
+                                      datum
+                                    (prin1-to-string datum))) data " ")
+                   data)))))))
+
+;;;; Imenu support
+
+(defun rec-mode-imenu-index-name-function ()
+  "Get an imenu index entry for the record at point."
+  (let ((type (rec-record-type))
+        (current (rec-current-record)))
+    (if type
+        (cond ((rec-record-descriptor-p current)
+               (propertize (format "%%%s" type) 'face 'font-lock-keyword-face))
+              ((not (null (rec-key)))
+               (let ((key-value (car-safe (rec-record-assoc
+                                           (rec-key)
+                                           current))))
+                 (format "%s %s" type (or key-value ""))))
+              (t type))
+      "Record")))
+
+(defun rec-mode-imenu-goto-function (name position &rest rest)
+  "Move to the chosen record.
+
+Calls function `imenu-default-goto-function' (which see), with
+NAME, POSITION and REST, but unlike that function, re-narrows
+onto the chosen record."
+  (apply 'imenu-default-goto-function name position rest)
+  (unless (derived-mode-p 'rec-edit-mode)
+    (rec-show-record))
+  (rec-summary-move-to-record (rec-current-record)))
 
 ;;;; Definition of modes
 
@@ -2160,6 +2942,59 @@ function returns nil."
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.rec\\'" . rec-mode))
 
+(easy-menu-define rec-mode-menu (list rec-mode-map rec-edit-mode-map)
+  "Menu for rec-mode."
+  '("Rec"
+    ["Jump back"               rec-cmd-jump-back rec-jump-back]
+    ["Next record"             rec-cmd-goto-next-rec
+     :help "Go to the next record of the same type."]
+    ["Previous record"         rec-cmd-goto-previous-rec 
+     :help "Go to the previous record of the same type."]
+    ["Next field"              rec-cmd-goto-next-field t]
+    ["Go to record descriptor" rec-cmd-show-descriptor t]
+    "---"
+    ["Append field"       rec-cmd-append-field t]
+    ["Toggle field visibility" rec-cmd-toggle-field-visibility t]
+    ["Trim field value"   rec-cmd-trim-field-value t]
+    
+    "---"
+    ("Restrict navigation"
+     ["Matching selection expression..." rec-cmd-navigate-current-type-by-sex
+      :help "Restrict movement to records of the current type matching a 
selection expression."]
+     ["Matching fast string search..." 
rec-cmd-navigate-current-type-by-fast-string
+      :help "Restrict movement to records of the current type matching an fast 
string search."]
+     "---"
+     ["Exit selection navigation" rec-cmd-exit-selection rec-selection-mode])
+    ("Select records"
+     ["New buffer from selection expression..." rec-cmd-new-buffer-from-sex
+      :help "Run a selection expression on the file and copy the results to a 
new buffer."]
+     ["New buffer from fast string search..." 
rec-cmd-new-buffer-from-fast-string
+      :help "Run a fast string search on the file and copy the results to a 
new buffer."])
+    ("Cross reference"
+     
+     ["For selection expression..." rec-cmd-xref-sex
+      :help "Run a selection expression on the buffer and make an XREF list 
out of it."]
+     ["For fast string search..." rec-cmd-occur-from-sex
+      :help "Run a fast string search and copy the matching lines into a new 
buffer."])
+    
+    "---"
+    ["Edit field"         rec-cmd-edit-field t]
+    ["Edit record"        rec-edit-record  (not (derived-mode-p 
'rec-edit-mode))]
+    ["Edit type"          rec-edit-type  (not (derived-mode-p 'rec-edit-mode))]
+    ["Edit buffer"        rec-edit-buffer (not (derived-mode-p 
'rec-edit-mode))]
+    "---"
+    ["Show info about file" rec-cmd-show-info t]
+    ["Show field type"    rec-cmd-show-type t]
+    ["Show field value statistics" rec-cmd-statistic t]
+    "---"
+    ["Count records of same type" rec-cmd-count t]
+    "---"
+    ["Show summary"       rec-cmd-show-summary t]
+    ["Compile (recfix)"   rec-cmd-compile t]
+    ["Find type..."       rec-find-type t]
+    ["---"                nil                :visible (derived-mode-p 
'rec-edit-mode)]
+    ["Finish editing"     rec-finish-editing :visible (derived-mode-p 
'rec-edit-mode)]))
+
 (define-derived-mode rec-mode nil "Rec"
   "A major mode for editing rec files.
 \\{rec-mode-map}"
@@ -2169,11 +3004,23 @@ function returns nil."
   (setq-local add-log-current-defun-function #'rec-log-current-defun)
   (setq-local font-lock-defaults '(rec-font-lock-keywords))
   (setq-local syntax-propertize-function rec-syntax-propertize-function)
+  (setq-local beginning-of-defun-function #'rec-beginning-of-record)
+  (setq-local end-of-defun-function #'rec-end-of-record)
   (add-to-invisibility-spec '(rec-hide-field . "..."))
 
+  (add-hook 'xref-after-jump-hook #'rec-mode--xref-after-jump-hook nil t)
+  (add-hook 'xref-after-return-hook #'rec-mode--xref-after-return-hook nil t)
+
   ;; Run some code later (i.e. after running the mode hook and setting the
   ;; file-local variables).
-  (add-hook 'hack-local-variables-hook #'rec--after-major-mode nil t))
+  (add-hook 'hack-local-variables-hook #'rec--after-major-mode nil t)
+  (setq-local eldoc-documentation-function #'rec-mode-eldoc-function)
+  (setq-local imenu-prev-index-position-function #'rec-goto-previous-rec)
+  (setq-local imenu-extract-index-name-function 
#'rec-mode-imenu-index-name-function)
+  (setq-local imenu-default-goto-function #'rec-mode-imenu-goto-function)
+
+
+  (add-hook 'flymake-diagnostic-functions #'rec-mode-flymake-recfix nil t))
 
 (defun rec--after-major-mode ()
   "Goto the first record of the first type (including the Unknown).
@@ -2189,9 +3036,20 @@ mode and show the output of recfix in a separated 
buffer."
           (setq buffer-read-only t)
           (rec-show-type (car (rec-buffer-types))))
       ;; Edit mode
-      (use-local-map rec-mode-edit-map)
-      (setq rec-editing t)
-      (rec-set-mode-line "Edit buffer"))))
+      (rec-edit-mode)
+      (setq rec-edit-mode-type 'buffer)
+      (rec-update-mode-line))))
+
+(define-derived-mode rec-edit-mode rec-mode "Rec Edit"
+  "A major mode for editing recfiles in Edit Mode.
+
+See Info node `(rec-mode)Editing Mode'.
+\\{rec-edit-mode-map}"
+  (rec-unfold-all-fields)
+  (rec-remove-continuation-line-marker-overlays)
+  (setq buffer-read-only nil)
+  (remove-hook 'hack-local-variables-hook #'rec--after-major-mode t)
+  (add-hook 'hack-local-variables-hook 
#'rec-update-buffer-descriptors-and-check nil t))
 
 (defvar rec-edit-field-mode-map
   (let ((map (make-sparse-keymap)))
@@ -2202,6 +3060,29 @@ mode and show the output of recfix in a separated 
buffer."
 (define-derived-mode rec-edit-field-mode nil "Rec Edit"
   "A major mode for editing rec field values.")
 
+(defvar rec-selection-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [remap rec-cmd-goto-next-rec] 
#'rec-cmd-goto-next-selection-record)
+    (define-key map [remap rec-cmd-goto-previous-rec] 
#'rec-cmd-goto-prev-selection-record)
+    map))
+
+;;;###autoload
+(define-minor-mode rec-selection-mode
+  "A minor mode for navigating a selection of the current buffer.
+
+When a selection is entered via `\\[rec-cmd-filter-sex]', the
+minor mode is entered.  This minor mode alters the behaviour of
+the standard bindings of `rec-cmd-goto-next-rec' and
+`rec-cmd-goto-previous-rec'.  In the minor mode, only the records
+matching the currently active selection are available for
+navigation. The minor mode can be exited using
+`rec-selection-exit', bound to `\\[rec-cmd-exit-selection]'.
+
+\\{rec-selection-mode-map}."
+  :lighter " Selection"
+  :variable rec-selection-mode
+  :keymap rec-selection-mode-map)
+
 ;; Local variables:
 ;; outline-regexp: ";;;;"
 ;; End:
diff --git a/rec-mode.info b/rec-mode.info
index 6fd3cd6..e9bef84 100644
--- a/rec-mode.info
+++ b/rec-mode.info
@@ -1,17 +1,17 @@
 This is rec-mode.info, produced by makeinfo version 6.7 from
 rec-mode.texi.
 
-This manual is for rec-mode for Emacs, which is part of the GNU recutils
-suite (version 1.8.90, 13 November 2020).
+This manual is for rec-mode for Emacs, which is part of the GNU
+recutils suite (version 1.8.90, 27 November 2020).
 
-   Copyright (C) 2012-2020 Free Software Foundation, Inc.
+   Copyright © 2012-2020 Free Software Foundation, Inc.
 
      Permission is granted to copy, distribute and/or modify this
      document under the terms of the GNU Free Documentation License,
      Version 1.3 or any later version published by the Free Software
      Foundation; with no Invariant Sections, no Front-Cover Texts, and
      no Back-Cover Texts.  A copy of the license is included in the
-     section entitled "GNU Free Documentation License".
+     section entitled “GNU Free Documentation License”.
 INFO-DIR-SECTION Emacs
 START-INFO-DIR-ENTRY
 * Rec Mode: (rec-mode). Emacs mode for editing recfiles.
@@ -23,29 +23,35 @@ File: rec-mode.info,  Node: Top,  Next: Introduction,  Up: 
(dir)
 rec-mode: an Emacs mode for editing recfiles
 ********************************************
 
-This manual documents version 1.8.90 of rec-mode.
+This manual documents version 1.7.0 of rec-mode.
 
    This manual is for rec-mode for Emacs, which is part of the GNU
-recutils suite (version 1.8.90, 13 November 2020).
+recutils suite (version 1.8.90, 27 November 2020).
 
-   Copyright (C) 2012-2020 Free Software Foundation, Inc.
+   Copyright © 2012-2020 Free Software Foundation, Inc.
 
      Permission is granted to copy, distribute and/or modify this
      document under the terms of the GNU Free Documentation License,
      Version 1.3 or any later version published by the Free Software
      Foundation; with no Invariant Sections, no Front-Cover Texts, and
      no Back-Cover Texts.  A copy of the license is included in the
-     section entitled "GNU Free Documentation License".
+     section entitled “GNU Free Documentation License”.
 
 * Menu:
 
 * Introduction::                Getting started
 * Navigation mode::             User-friendly interface for browing recfiles
 * Edition modes::               Edit recfiles in rec-format
+* Summary mode::                List records in a table.
+* Selecting records::           Run queries on the current buffer.
+* Cross referencing::           Cross reference records.
 * Configuration::               Adapting rec-mode to your needs
-* GNU Free Documentation License:: Distribution terms for this document
+* Command Index::               Command and Function Index
+* Key Index::                   Key (Character) Index
+* Variable and Concept Index::  Variable and Concept Index
+* GNU Free Documentation License::  Distribution terms for this document
 
- -- The Detailed Node Listing --
+ — The Detailed Node Listing —
 
 Introduction
 
@@ -55,22 +61,29 @@ Introduction
 
 Navigation mode
 
-* Record navigation::           Moving through records.
-* Field navigation::            Moving through fields in a record.
-* Field folding::               Hiding and showing the values of fields.
-* Field edition::               Changing the values of fields.
-* Searches::                    Finding records fufilling some criteria.
-* Statistics::                  Counting records.
-* Data integrity::              Verifying the integrity of the recfile.
+* Record navigation::           Moving through records
+* Field navigation::            Moving through fields in a record
+* Field folding::               Hiding and showing the values of fields
+* Field edition::               Changing the values of fields
+* Searches::                    Finding records fulfilling some criteria
+* Statistics::                  Counting records
+* Data integrity::              Verifying the integrity of the recfile
 
-Edition modes
+Selecting records
 
-* Edition modes::               Edit recfiles in rec-format
+* Buffer from selection::       Copy the selection into a new recfile buffer.
+* Selection mode::              Navigate the current buffer based on a search.
+
+
+Cross referencing
+
+* Cross referencing by selection:: Cross reference matching selections.
 
 Configuration
 
 * Finding the recutils::        Specifying the location of the recutils.
-* Records appearance::          Setting the way records are displayed.
+* Records appearance::          Setting the way records are displayed
+
 
 
 File: rec-mode.info,  Node: Introduction,  Next: Navigation mode,  Prev: Top,  
Up: Top
@@ -104,27 +117,28 @@ File: rec-mode.info,  Node: Installation,  Next: 
Activation,  Up: Introduction
 ================
 
 rec-mode is implemented in a self-contained elisp file called
-'rec-mode.el'.  It can be obtained in several ways:
-
-   - As part of a released tarball of recutils.  'rec-mode.el' can be
-     found in the 'etc/' directory in the tarball contents.
-   - As part of the source tree cloned from the development git repo.
-     'rec-mode.el' can be found in the 'etc/' directory in the recutils
-     sources tree.
-   - As a single file downloaded form some other location in internet.
-   - It may be already installed as part of a binary package in some
+‘rec-mode.el’.  It can be obtained in several ways:
+
+   − From GNU ELPA (https://elpa.gnu.org/packages/rec-mode.html) using
+     the built-in Emacs package manager.
+   − As part of the source tree cloned from the development git
+     repository of rec-mode.  ‘rec-mode.el’ can be found in the root
+     directory of the recutils sources tree.
+   − As a single file downloaded form some other location in internet.
+   − It may be already installed as part of a binary package in some
      distribution.
 
-In the first three cases you need to tell Emacs where to locate the
-'rec-mode.el' file and to load it.  Add the following to your '.emacs'
+In the second case you need to tell Emacs where to locate the
+‘rec-mode.el’ file and to load it.  Add the following to your ‘.emacs’
 file.
+
      (add-to-list 'load-path "~/path/to/recmode/")
      (require 'rec-mode)
 
-If 'rec-mode.el' was installed as part of a binary package in a
-distribution then you usually don't have to touch the 'load-path'
-variable.  Depending on the specific case you may have to 'require' the
-package.
+If ‘rec-mode.el’ was installed as part of a binary package in a
+distribution then you usually don’t have to touch the ‘load-path’
+variable.  Depending on the specific case you may have to ‘require’
+the package.
 
 
 File: rec-mode.info,  Node: Activation,  Next: Feedback,  Prev: Installation,  
Up: Introduction
@@ -132,25 +146,23 @@ File: rec-mode.info,  Node: Activation,  Next: Feedback,  
Prev: Installation,  U
 1.2 Activation
 ==============
 
-To make sure files with extension '.rec' use rec-mode, add the following
-line to your '.emacs' file.
-     (add-to-list 'auto-mode-alist '("\\.rec\\'" . rec-mode))
-rec-mode buffers need font-lock to be turned on - this is the default in
+rec-mode should automatically activate when opening ‘.rec’ files.  To
+make sure files with extension ‘.rec’ use rec-mode, add the rec-mode
+buffers need font-lock to be turned on - this is the default in
 Emacs(1).
 
-   With this setup, all files with extension '.rec' will be put into rec
-mode.  As an alternative, make the first line of a recfile look like
-this:
+   If the file doesn’t end in ‘.rec’, make the first line of a recfile
+look like this:
 
      # -*- mode: rec -*-
 
-which will select rec-mode for this buffer no matter what the file's
+which will select rec-mode for this buffer no matter what the file’s
 name is.
 
    ---------- Footnotes ----------
 
-   (1) If you don't use font-lock globally, turn it on in the rec buffer
-with '(add-hook 'rec-mode-hook 'turn-on-font-lock)'
+   (1) If you don’t use font-lock globally, turn it on in the rec
+buffer with ‘(add-hook 'rec-mode-hook 'turn-on-font-lock)’
 
 
 File: rec-mode.info,  Node: Feedback,  Prev: Activation,  Up: Introduction
@@ -178,21 +190,22 @@ File: rec-mode.info,  Node: Navigation mode,  Next: 
Edition modes,  Prev: Introd
 *****************
 
 When a recfile is visited in Emacs and rec-mode is activated, the
-contents of the file are examined and parsed in order to determine if it
-is a valid recfile and, in that case, to extract information like the
-kind of records stored in the file.
+contents of the file are examined and parsed in order to determine if
+it is a valid recfile and, in that case, to extract information like
+the kind of records stored in the file.
 
-   If the file does not contain valid rec data then the buffer is put in
-'fundamental-mode' and a description of the syntax error, along its
+   If the file does not contain valid rec data then the buffer is put
+in ‘fundamental-mode’ and a description of the syntax error, along its
 location, is notified in the echo area.
 
-   If the file contains valid rec data, the mode sets itself in what is
-known as "navigation mode".  In this mode the buffer is made read-only
-and it is narrowed to the first record present in the file.  Also, the
-presentation of the record contents is slightly changed in order to
-improve the visualization of the data: continuation line marks are
-replaced by indentation, big fields are folded, etc.  The modeline is
-changed in order to reflect the type of the records being navigated.
+   If the file contains valid rec data, the mode sets itself in what
+is known as “navigation mode”.  In this mode the buffer is made
+read-only and it is narrowed to the first record present in the file.
+Also, the presentation of the record contents is slightly changed in
+order to improve the visualization of the data: continuation line
+marks are replaced by indentation, big fields are folded, etc.  The
+modeline is changed in order to reflect the type of the records being
+navigated.
 
    At this point the user can navigate through the records and fields
 contained in the file, and edit the contents of the fields and the
@@ -217,21 +230,26 @@ File: rec-mode.info,  Node: Record navigation,  Next: 
Field navigation,  Up: Nav
 
 The following commands jump to other records in the buffer.
 
-'n'     ('rec-cmd-goto-next-rec')
+‘n’
+‘M-x rec-cmd-goto-next-rec’
      Display the next record of the same type in the buffer.
-     'C-u N n' will move next N times.
-'p'     ('rec-cmd-goto-previous-rec')
+     ‘C-u N n’ will move next N times.
+‘p’
+‘M-x rec-cmd-goto-previous-rec’
      Display the previous record of the same type in the buffer.
-     'C-u N p' will move backwards N times.
-'d'     ('rec-cmd-show-descriptor')
-     Display the record descriptor applicable to the current record.  If
-     the current record is anonymous, i.e. there is not record
+     ‘C-u N p’ will move backwards N times.
+‘d’
+‘M-x rec-cmd-show-descriptor’
+     Display the record descriptor applicable to the current record.
+     If the current record is anonymous, i.e. there is not record
      descriptor.  then this command does nothing.
-'b'     ('rec-cmd-jump-back')
+‘b’
+‘M-x rec-cmd-jump-back’
      Display the record previously displayed in the buffer.
-'C-c C-t'     ('rec-find-type')
-     Prompt the user for one of the record types present in the recfile
-     and display the first record of the selected type.
+‘C-c C-t’
+‘M-x rec-find-type’
+     Prompt the user for one of the record types present in the
+     recfile and display the first record of the selected type.
 
 
 File: rec-mode.info,  Node: Field navigation,  Next: Field folding,  Prev: 
Record navigation,  Up: Navigation mode
@@ -242,12 +260,15 @@ File: rec-mode.info,  Node: Field navigation,  Next: 
Field folding,  Prev: Recor
 The following commands iterate through the fields in a record, and to
 get information about some of the properties of the fields.
 
-'TAB'     ('rec-cmd-goto-next-field')
+‘TAB’
+‘M-x rec-cmd-goto-next-field’
      Move the cursor to the beginning of the name of the next field in
-     the current record.  If the cursor is currently located at the last
-     field of the record then move it to the beginning of the first
-     field.
-'t'     ('rec-cmd-show-type')
+     the current record.  If the cursor is currently located at the
+     last field of the record then move it to the beginning of the
+     first field.
+
+‘t’
+‘M-x rec-cmd-show-type’
      Show information about the type of the field under the cursor, if
      it is defined.
 
@@ -262,14 +283,15 @@ difficult to have an overview of the contents of the 
record.  The
 following commands fold and unfold the value of the field under the
 cursor.
 
-'SPC'     ('rec-cmd-toggle-field-visibility')
-     Toggle the visibility of the field under the cursor.  When a field
-     is folded then three dots are displayed in the buffer instead of
-     the value of the field.
+‘SPC’
+‘M-x rec-cmd-toggle-field-visibility’
+     Toggle the visibility of the field under the cursor.  When a
+     field is folded then three dots are displayed in the buffer
+     instead of the value of the field.
 
-     It is possible to automatically fold any field whose value exceeds
-     a certain limit which can be configured by the user.  *Note Records
-     appearance::.
+     It is possible to automatically fold any field whose value
+     exceeds a certain limit which can be configured by the user.
+     *Note Records appearance::.
 
 
 File: rec-mode.info,  Node: Field edition,  Next: Searches,  Prev: Field 
folding,  Up: Navigation mode
@@ -279,32 +301,34 @@ File: rec-mode.info,  Node: Field edition,  Next: 
Searches,  Prev: Field folding
 
 The following commands change the value of the field under the cursor.
 
-'e'     ('rec-cmd-edit-field')
-     Edit the value of the field under the cursor.  The specific action
-     depends on the type of the field in the corresponding record
-     descriptor:
-        - For date fields a calendar buffer is opened in another window
-          and the focus is moved there.  The user can then select a date
-          by moving the cursor there and press 'RET' in order to set
-          that date as the value for the field.  Alternatively the user
-          can press 't' in order to set the field to "now", or 'q' to
-          cancel the operation.  In the later case the value of the
-          field is left untouched.
-        - For enumerated and bool fields a fast-select buffer is opened
-          in another window, showing a list of labeled options.  The
-          labels are single digits and letters.  The user can then
-          select ony of the options by pressing the corresponding label,
-          or cancel the operation by pressing 'RET'.  In the later case
-          the value of the field is left untouched.
-        - For any other kind of fields an edition buffer is opened in
+‘e’
+‘M-x rec-cmd-edit-field’
+     Edit the value of the field under the cursor.  The specific
+     action depends on the type of the field in the corresponding
+     record descriptor:
+        − For date fields a calendar buffer is opened in another
+          window and the focus is moved there.  The user can then
+          select a date by moving the cursor there and press ‘RET’ in
+          order to set that date as the value for the field.
+          Alternatively the user can press ‘t’ in order to set the
+          field to “now”, or ‘q’ to cancel the operation.  In the
+          later case the value of the field is left untouched.
+        − For enumerated and bool fields a fast-select buffer is
+          opened in another window, showing a list of labeled options.
+          The labels are single digits and letters.  The user can then
+          select ony of the options by pressing the corresponding
+          label, or cancel the operation by pressing ‘RET’.  In the
+          later case the value of the field is left untouched.
+        − For any other kind of fields an edition buffer is opened in
           another window, showing the current contents of the field.
           The user can then edit the buffer as desired.  When she is
-          done, the user can then press 'C-c C-c' in order to set the
-          new value of the field, or just kill the buffer to cancel the
-          operation.
-'m'     ('rec-cmd-trim-field-value')
-     Trim the value of the field under the cursor, removing any sequence
-     of leading and trailing blank characters.
+          done, the user can then press ‘C-c C-c’ in order to set the
+          new value of the field, or just kill the buffer to cancel
+          the operation.
+‘m’
+‘M-x rec-cmd-trim-field-value’
+     Trim the value of the field under the cursor, removing any
+     sequence of leading and trailing blank characters.
 
 
 File: rec-mode.info,  Node: Searches,  Next: Statistics,  Prev: Field edition, 
 Up: Navigation mode
@@ -312,19 +336,21 @@ File: rec-mode.info,  Node: Searches,  Next: Statistics,  
Prev: Field edition,
 2.5 Searches
 ============
 
-The following commands jump to the first record in the buffer satisfying
-some criteria.
-
-'s q'     ('rec-cmd-select-fast')
-     Display the first record having a field whose value matches a given
-     fixed pattern.  This is equivalent of using the command line option
-     '-q' of 'recsel'.  If a prefix argument is specified then the
-     search is case-insensitive.
-'s s'     ('rec-cmd-select-sex')
-     Display the first record in the buffer satisfying a given selection
-     expression.  This is equivalent of using the command line option
-     '-e' of 'recsel'.  If a prefix argument is specified then the
-     search is case-insensitive.
+The following commands jump to the first record in the buffer
+satisfying some criteria.
+
+‘s q’
+‘M-x rec-cmd-jump-to-fast’
+     Display the first record having a field whose value matches a
+     given fixed pattern.  This is equivalent of using the command
+     line option ‘-q’ of ‘recsel’.  If a prefix argument is specified
+     then the search is case-insensitive.
+‘s s’
+‘M-x rec-cmd-jump-to-sex’
+     Display the first record in the buffer satisfying a given
+     selection expression.  This is equivalent of using the command
+     line option ‘-e’ of ‘recsel’.  If a prefix argument is specified
+     then the search is case-insensitive.
 
 
 File: rec-mode.info,  Node: Statistics,  Next: Data integrity,  Prev: 
Searches,  Up: Navigation mode
@@ -335,22 +361,25 @@ File: rec-mode.info,  Node: Statistics,  Next: Data 
integrity,  Prev: Searches,
 The following commands allow to count records in the current buffer
 based on some provided criteria.
 
-'I'     ('rec-cmd-show-info')
+‘I’
+‘M-x rec-cmd-show-info’
      Show the number of records in the buffer categorized by type.
-'#'     ('rec-cmd-count')
+‘#’
+‘M-x rec-cmd-count’
      Count the number of records in the buffer having the same type as
      the current record.  With a numeric prefix N, ask for a selection
-     expression and count the number of records in the buffer satisfying
-     the expression.
+     expression and count the number of records in the buffer
+     satisfying the expression.
 
      Note that rec-mode tries to guess a reasonable default for the
      selection expression, depending on the type of the field and its
-     value.  If the user press 'RET' then the provided default selection
-     expression is used.
-'%'     ('rec-cmd-statistics')
+     value.  If the user press ‘RET’ then the provided default
+     selection expression is used.
+‘%’
+‘M-x rec-cmd-statistics’
      If the field under the cursor contains an enumerated value, show
-     the percentages of records in the current record set having fields
-     with each of the possible values of the enumerated type.
+     the percentages of records in the current record set having
+     fields with each of the possible values of the enumerated type.
 
 
 File: rec-mode.info,  Node: Data integrity,  Prev: Statistics,  Up: Navigation 
mode
@@ -361,51 +390,56 @@ File: rec-mode.info,  Node: Data integrity,  Prev: 
Statistics,  Up: Navigation m
 The integrity of the rec data stored in the file can be checked using
 the following commands.
 
-'c'     ('rec-cmd-compile')
-     Compile the buffer with 'recfix' and open a compilation window
+‘c’
+‘M-x rec-cmd-compile’
+     Compile the buffer with ‘recfix’ and open a compilation window
      showing the result of the command.  In case some error or warning
-     is reported, the user can jump to the location triggering the error
-     by pressing 'RET' in the compilation window.
+     is reported, the user can jump to the location triggering the
+     error by pressing ‘RET’ in the compilation window.
 
 
-File: rec-mode.info,  Node: Edition modes,  Next: Configuration,  Prev: 
Navigation mode,  Up: Top
+File: rec-mode.info,  Node: Edition modes,  Next: Summary mode,  Prev: 
Navigation mode,  Up: Top
 
 3 Edition modes
 ***************
 
 The navigation mode described in a previous chapter is mainly intended
-for browsing recdata and doing changes at the record level: editing the
-contents of a field, adding or removing fields, etc.  In order to
+for browsing recdata and doing changes at the record level: editing
+the contents of a field, adding or removing fields, etc.  In order to
 perform broader changes, such as adding/deleting record descriptors,
-records or comment blocks, the user must enter into one of the "edition
-modes".
+records or comment blocks, the user must enter into one of the
+“edition modes”.
 
    There are three edition modes, covering different areas of the
 recfile: record, record type and buffer.  When an edition mode is
 entered the buffer is set in read/write mode, it is narrowed to the
 desired area and any embellishment used in navigation mode is
 removed(1).  As a general rule, the commands available in navigation
-mode are also available in the edition mode prefixed with 'C-c' and with
-a control sequence 'C-'.  Thus, 'n', which in record navigation mode
-jumps to the next record, becomes 'C-c C-n' in the record edition modes.
-The exceptions to this are the bindings 'c' ('rec-cmd-compile') which
-becomes 'C-c C-k' and 'h' ('rec-cmd-show-summary') which becomes 'C-c
-M-h'.
+mode are also available in the edition mode prefixed with ‘C-c’ and
+with a control sequence ‘C-’.  Thus, ‘n’, which in record navigation
+mode jumps to the next record, becomes ‘C-c C-n’ in the record edition
+modes.  The exceptions to this are the bindings ‘c’
+(‘rec-cmd-compile’) which becomes ‘C-c C-k’ and ‘h’
+(‘rec-cmd-show-summary’) which becomes ‘C-c M-h’.
 
    The following commands are used to enter into one of the available
 edition modes from the navigation mode.
 
-'R'     ('rec-edit-record')
+‘R’
+‘M-x rec-edit-record’
      Edit the record being navigated.
-'T'     ('rec-edit-type')
+‘T’
+‘M-x rec-edit-type’
      Edit the record set being navigated.
-'B'     ('rec-edit-buffer')
+‘B’
+‘M-x rec-edit-buffer’
      Edit the buffer.
 
 After doing modifications in the buffer, the user can go back to
 navigation mode by using the following command.
 
-'C-c C-c'     ('rec-finish-editing')
+‘C-c C-c’
+‘M-x rec-finish-editing’
      Finish the current edition and return to navigation mode.  If a
      syntactic error was introduced in the edition activity then the
      error is reported in the echo area and navigation mode is not
@@ -416,59 +450,420 @@ navigation mode by using the following command.
    (1) Exceptuating font-lock
 
 
-File: rec-mode.info,  Node: Configuration,  Next: GNU Free Documentation 
License,  Prev: Edition modes,  Up: Top
+File: rec-mode.info,  Node: Summary mode,  Next: Selecting records,  Prev: 
Edition modes,  Up: Top
+
+4 Summary mode
+**************
+
+Besides the standard viewing modes of buffers, there is also a third
+option called “summary mode”.  Summary mode is a tabulated list of the
+record in which each record is a row in the table.  The columns in the
+table are determined by user input, or alternatively, by special keys
+in the current file.
+
+‘h’
+‘M-x rec-cmd-show-summary’
+     Creates a summary buffer from the current type being viewed in
+     the recfile.  The columns are based on user input (prompted), or
+     if the record has either a ‘%summary’ or ‘%key’ in its
+     descriptor, those fields are used.
+
+   The input for the summary query is a “field expression”, a
+comma-separated list of column names.  Thus, if your recfile looks
+like the following:
+
+     Name: Ada Lovelace
+     Age: 36
+
+     Name: Peter the Great
+     Age: 53
+
+     Name: Matusalem
+     Age: 969
+
+   Then calling ‘rec-cmd-show-summary’ and entering ‘Name,Age’ would
+create a table of all records with those columns.  If your record
+descriptor contains a ‘%summary’ like below:
+
+     %summary: Age,Name
+
+then this is used as the field expression instead.  Similarly, if no
+‘%summary’ field is defined and a ‘%key’ field exists, then that field
+is used.
+
+   Calling this command enters “record summary mode”, which a a major
+mode derived from “tabulated list mode” (*note (elisp)Tabulated List
+mode::).  In this mode, the following bindings are available:
+
+‘n’
+‘M-x rec-summary-cmd-next’
+     Go to the next record in the summary.
+
+Navigation inside the summary buffer maintains the position of the
+associated recfile buffer, and vice versa.  The currently active
+record in the recfile is shown highlighted in the buffer.  As a
+result, the summary can be thought of as a useful “overview” overview
+for any recfile buffer.
+
+
+File: rec-mode.info,  Node: Selecting records,  Next: Cross referencing,  
Prev: Summary mode,  Up: Top
+
+5 Selecting records
+*******************
+
+Sometimes it is useful to operate or inspect only a subset of all the
+records on the file.  To this end, rec-mode provides several ways of
+using the searching facilities of recutils.
+
+   Selection can be done using two mechanisms:
+
+   • selection expressions, which are expressions that can be applied
+     to a record.  These offer a powerful query language for records.
+     *Note (recutils)Selection Expressions::.
+
+   • fast string searches, which match records whose field values
+     match a string.
+
+   For instance, you can create a new buffer out of the current
+buffer, so that only the records that match your search are copied.
+This way you can create new recfiles out of existing ones based on
+selections.
+
+   To help navigate the buffer based on a search, you can create a new
+navigation mode where the commands for moving between records only
+move to those matching a search.  This is known as selection mode.
+
+* Menu:
+
+* Buffer from selection::       Copy the selection into a new recfile buffer.
+* Selection mode::              Navigate the current buffer based on a search.
 
-4 Configuration
+
+File: rec-mode.info,  Node: Buffer from selection,  Next: Selection mode,  Up: 
Selecting records
+
+5.1 Buffer from selection
+=========================
+
+Creating new recfiles based on selections can be done by creating a
+wholly new buffer using the “buffer from selection” commands in
+rec-mode.
+
+‘x s’
+‘M-x rec-cmd-new-buffer-from-sex’
+     Creates a new buffer from a “selection expression”.  *Note
+     (recutils)Selection Expressions::.  Prompts the user for a
+     selection expression and then displays a new buffer containing
+     records that match the expression.
+‘x q’
+‘M-x rec-cmd-new-buffer-from-fast-string’
+     Creates a new buffer from a “fast string search”.  Prompts the
+     user for a string and then displays a new buffer which contains
+     all records whose any field contains this string.
+
+   In both of these commands, if the recfile has a “record
+descriptor”, it is copied as well.
+
+
+File: rec-mode.info,  Node: Selection mode,  Prev: Buffer from selection,  Up: 
Selecting records
+
+5.2 Selection mode
+==================
+
+In both navigation mode and the assorted edition modes,
+‘rec-cmd-goto-next-rec’ and ‘rec-cmd-goto-prev-rec’ navigate to the
+next and previous record, respectively.  On large files, finding a
+particular record using these commands only can be quite tedious.  To
+this end, using selections, it is possible to jump to or restrict
+navigation to records matching selections.
+
+Restricting the navigation commands, typically bound to ‘n’ and ‘C-c
+C-n’ (mutatis mutandis for backward movement), to records that match
+the current selection, can be done using what is called record
+selection mode.
+
+   Record selection mode is a buffer-local minor mode in which the
+commands for next and previous records as described above do not
+behave the usual way: they navigate records that only match the
+currently active selection.
+
+   Record selection mode can be entered by the following commands:
+
+‘/ s’
+‘M-x rec-cmd-navigate-current-type-by-sex’
+     Prompts the user for a selection expression, runs a query on the
+     current buffer and the current type, and then enters record
+     selection mode.
+‘/ q’
+‘M-x rec-cmd-navigate-current-type-by-fast-string’
+     Same as above, but with a fast string search.
+
+In record selection mode, besides the standard navigation bindings,
+the following additional bindings are defined:
+
+‘/ h’
+‘M-x rec-cmd-show-summary-for-selection’
+     Creates a summary buffer (*note Summary mode::) with the contents
+     from the selection instead of the current buffer.
+
+‘/ /’
+‘M-x rec-cmd-exit-selection’
+     Exits record selection mode and restores the normal navigation
+     keybindings.
+
+
+File: rec-mode.info,  Node: Cross referencing,  Next: Configuration,  Prev: 
Selecting records,  Up: Top
+
+6 Cross referencing
+*******************
+
+Besides navigation, edition and selection, rec-mode provides another
+powerful feature for recfiles, known as “cross referencing”.  In
+short, cross referencing is an Emacs term for listing various kinds of
+search results for certain keywords an identifiers.  For records, this
+could mean the following:
+
+  1. Finding the type definition of a field.
+  2. Finding the uses of a certain type, the inverse of above.
+  3. Finding the referred record of a foreign key.  If a field is a
+     key referring to another record, you can jump to that record.
+  4. Finding the referents of a record if it is a foreign key.
+  5. Finding records that match a certain selection expression or fast
+     string search.
+
+Emacs provides a unified interface for this called Xref.  *Note
+(emacs)Find Identifier Referencs::.  Rec mode implements several
+backends for these purposes.
+
+   Regardless of functionality, if there are more than one search
+result, Xref searches present their results in a special ‘XREF’
+buffer.  It is an ordered list of results, similar to compilation mode
+(*note (emacs)Compilation Mode::).  Xref makes it easy to navigate
+between search results, as it binds the ‘next-error’ functionality,
+letting you navigate the results even if you are outside the rec mode
+buffer.
+
+   As of version 1.7.0, Xref implements only the last functionality,
+cross referencing records by selection expressions or fast string
+searches.
+
+* Menu:
+
+* Cross referencing by selection::
+
+
+File: rec-mode.info,  Node: Cross referencing by selection,  Up: Cross 
referencing
+
+6.1 Cross referencing by selection
+==================================
+
+Cross referencing by selection lets you perform a query and then list
+the results using the Xref buffer.  Rec mode provides two such
+commands:
+
+‘X s’
+‘M-x rec-cmd-xref-sex’
+     Query the current recfile using a selection expression and the
+     current type and then list the results using Xref.  Each results
+     shows a small snippet of the matched record making it easier to
+     identify which records matched the search.
+‘X q’
+‘M-x rec-cmd-xref-fast-string’
+     Like above, but using a fast string.  Instead of previewing the
+     first three fields of a record, it shows each field where there
+     was a match.
+
+
+File: rec-mode.info,  Node: Configuration,  Next: Command Index,  Prev: Cross 
referencing,  Up: Top
+
+7 Configuration
 ***************
 
-TBC
+rec-mode can be configured using the customization facilities of
+Emacs.
 
 * Menu:
 
-* Finding the recutils::     Specifying the location of the recutils.
-* Records appearance::       Setting the way records are displayed
+* Finding the recutils::        Specifying the location of the recutils.
+* Records appearance::          Setting the way records are displayed
 
 
 File: rec-mode.info,  Node: Finding the recutils,  Next: Records appearance,  
Up: Configuration
 
-4.1 Finding the recutils
+7.1 Finding the recutils
 ========================
 
-'rec-mode' makes use of the several utilities which are part of the
+‘rec-mode’ makes use of the several utilities which are part of the
 recutils.  The following variables tell the mode where to find the
 utilities.  The default values of these variables must work if the
 recutils are installed system-wide in the system.
 
-'rec-recsel'
-     Name of the 'recsel' utility from the GNU recutils.
-'rec-recinf'
-     Name of the 'recinf' utility from the GNU recutils.
-'rec-recfix'
-     Name of the 'recfix' utility from the GNU recutils.
+ -- Variable: rec-recsel
+     Name of the ‘recsel’ utility from the GNU recutil.
+
+ -- Variable: rec-recinf
+     Name of the ‘recinf’ utility from the GNU recutils.
+
+ -- Variable: rec-recfix
+     Name of the ‘recfix’ utility from the GNU recutils.
 
 
 File: rec-mode.info,  Node: Records appearance,  Prev: Finding the recutils,  
Up: Configuration
 
-4.2 Records appearance
+7.2 Records appearance
 ======================
 
 The appearance of the records in navigation mode can be customised by
 tweaking the value of the following variables.
 
-'rec-max-lines-in-fields'
-     Values in fiels having more than the specified number of lines will
-     be hidden by default in navigation mode.  When hidden, an ellipsis
-     is shown instead of the value of the field.  Default is '15'.
+ -- Variable: rec-max-lines-in-fields
+     Values in fiels having more than the specified number of lines
+     will be hidden by default in navigation mode.  When hidden, an
+     ellipsis is shown instead of the value of the field.  Default is
+     ‘15’.
+
+
+File: rec-mode.info,  Node: Command Index,  Next: Key Index,  Prev: 
Configuration,  Up: Top
+
+Command and Function Index
+**************************
+
+[index]
+* Menu:
+
+* rec-cmd-compile:                       Data integrity.     (line 11)
+* rec-cmd-count:                         Statistics.         (line 14)
+* rec-cmd-edit-field:                    Field edition.      (line 10)
+* rec-cmd-exit-selection:                Selection mode.     (line 44)
+* rec-cmd-goto-next-field:               Field navigation.   (line 11)
+* rec-cmd-goto-next-rec:                 Record navigation.  (line 10)
+* rec-cmd-goto-previous-rec:             Record navigation.  (line 14)
+* rec-cmd-jump-back:                     Record navigation.  (line 23)
+* rec-cmd-jump-to-fast:                  Searches.           (line 11)
+* rec-cmd-jump-to-sex:                   Searches.           (line 17)
+* rec-cmd-navigate-current-type-by-fast-string: Selection mode.
+                                                             (line 32)
+* rec-cmd-navigate-current-type-by-sex:  Selection mode.     (line 27)
+* rec-cmd-new-buffer-from-fast-string:   Buffer from selection.
+                                                             (line 18)
+* rec-cmd-new-buffer-from-sex:           Buffer from selection.
+                                                             (line 12)
+* rec-cmd-show-descriptor:               Record navigation.  (line 18)
+* rec-cmd-show-info:                     Statistics.         (line 11)
+* rec-cmd-show-summary:                  Summary mode.       (line 14)
+* rec-cmd-show-summary-for-selection:    Selection mode.     (line 39)
+* rec-cmd-show-type:                     Field navigation.   (line 18)
+* rec-cmd-statistics:                    Statistics.         (line 25)
+* rec-cmd-toggle-field-visibility:       Field folding.      (line 13)
+* rec-cmd-trim-field-value:              Field edition.      (line 34)
+* rec-cmd-xref-fast-string:              Cross referencing by selection.
+                                                             (line 18)
+* rec-cmd-xref-sex:                      Cross referencing by selection.
+                                                             (line 12)
+* rec-edit-buffer:                       Edition modes.      (line 36)
+* rec-edit-record:                       Edition modes.      (line 30)
+* rec-edit-type:                         Edition modes.      (line 33)
+* rec-find-type:                         Record navigation.  (line 26)
+* rec-finish-editing:                    Edition modes.      (line 43)
+* rec-summary-cmd-next:                  Summary mode.       (line 48)
+
+
+File: rec-mode.info,  Node: Key Index,  Next: Variable and Concept Index,  
Prev: Command Index,  Up: Top
+
+Key (Character) Index
+*********************
+
+[index]
+* Menu:
+
+* #:                                     Statistics.         (line 14)
+* %:                                     Statistics.         (line 25)
+* / /:                                   Selection mode.     (line 44)
+* / h:                                   Selection mode.     (line 39)
+* / q:                                   Selection mode.     (line 32)
+* / s:                                   Selection mode.     (line 27)
+* b:                                     Record navigation.  (line 23)
+* B:                                     Edition modes.      (line 36)
+* c:                                     Data integrity.     (line 11)
+* C-c C-c:                               Edition modes.      (line 43)
+* C-c C-t:                               Record navigation.  (line 26)
+* d:                                     Record navigation.  (line 18)
+* e:                                     Field edition.      (line 10)
+* h:                                     Summary mode.       (line 14)
+* I:                                     Statistics.         (line 11)
+* m:                                     Field edition.      (line 34)
+* n:                                     Record navigation.  (line 10)
+* n <1>:                                 Summary mode.       (line 48)
+* p:                                     Record navigation.  (line 14)
+* R:                                     Edition modes.      (line 30)
+* s q:                                   Searches.           (line 11)
+* s s:                                   Searches.           (line 17)
+* SPC:                                   Field folding.      (line 13)
+* t:                                     Field navigation.   (line 18)
+* T:                                     Edition modes.      (line 33)
+* TAB:                                   Field navigation.   (line 11)
+* x q:                                   Buffer from selection.
+                                                             (line 18)
+* X q:                                   Cross referencing by selection.
+                                                             (line 18)
+* x s:                                   Buffer from selection.
+                                                             (line 12)
+* X s:                                   Cross referencing by selection.
+                                                             (line 12)
+
+
+File: rec-mode.info,  Node: Variable and Concept Index,  Next: GNU Free 
Documentation License,  Prev: Key Index,  Up: Top
+
+Variable and Concept Index
+**************************
+
+[index]
+* Menu:
+
+* activation:                            Activation.         (line  6)
+* author:                                Feedback.           (line  6)
+* bug reports:                           Feedback.           (line  6)
+* counting:                              Statistics.         (line  6)
+* cross referencing:                     Cross referencing.  (line  6)
+* cross referencing, selection:          Cross referencing by selection.
+                                                             (line  6)
+* editing fields:                        Field edition.      (line  6)
+* edition modes:                         Edition modes.      (line  6)
+* edition, fields:                       Field edition.      (line  6)
+* feedback:                              Feedback.           (line  6)
+* fixing records:                        Data integrity.     (line  6)
+* folding:                               Field folding.      (line  6)
+* jumping, to records:                   Record navigation.  (line  6)
+* maintainer:                            Feedback.           (line  6)
+* modes, edition:                        Edition modes.      (line  6)
+* modes, navigation:                     Navigation mode.    (line  6)
+* modes, selection:                      Selection mode.     (line  6)
+* modes, summary:                        Summary mode.       (line  6)
+* motion, between records:               Record navigation.  (line  6)
+* navigation mode:                       Navigation mode.    (line  6)
+* rec-max-lines-in-fields:               Records appearance. (line  9)
+* rec-recfix:                            Finding the recutils.
+                                                             (line 17)
+* rec-recinf:                            Finding the recutils.
+                                                             (line 14)
+* rec-recsel:                            Finding the recutils.
+                                                             (line 11)
+* record navigation:                     Record navigation.  (line  6)
+* selection mode:                        Selection mode.     (line  6)
+* selection, buffer:                     Buffer from selection.
+                                                             (line  6)
+* summary:                               Summary mode.       (line  6)
+* summary, selection:                    Selection mode.     (line 37)
+* xref:                                  Cross referencing.  (line  6)
 
 
-File: rec-mode.info,  Node: GNU Free Documentation License,  Prev: 
Configuration,  Up: Top
+File: rec-mode.info,  Node: GNU Free Documentation License,  Prev: Variable 
and Concept Index,  Up: Top
 
 Appendix A GNU Free Documentation License
 *****************************************
 
-                     Version 1.3, 3 November 2008
+                    Version 1.3, 3 November 2008
 
-     Copyright (C) 2000, 2001, 2002, 2007, 2008, 2020 Free Software
+     Copyright © 2000, 2001, 2002, 2007, 2008, 2020 Free Software
      Foundation, Inc.
      <http://fsf.org/>
 
@@ -477,132 +872,136 @@ Appendix A GNU Free Documentation License
 
   0. PREAMBLE
 
-     The purpose of this License is to make a manual, textbook, or other
-     functional and useful document "free" in the sense of freedom: to
-     assure everyone the effective freedom to copy and redistribute it,
-     with or without modifying it, either commercially or
-     noncommercially.  Secondarily, this License preserves for the
-     author and publisher a way to get credit for their work, while not
-     being considered responsible for modifications made by others.
+     The purpose of this License is to make a manual, textbook, or
+     other functional and useful document “free” in the sense of
+     freedom: to assure everyone the effective freedom to copy and
+     redistribute it, with or without modifying it, either
+     commercially or noncommercially.  Secondarily, this License
+     preserves for the author and publisher a way to get credit for
+     their work, while not being considered responsible for
+     modifications made by others.
 
-     This License is a kind of "copyleft", which means that derivative
+     This License is a kind of “copyleft”, which means that derivative
      works of the document must themselves be free in the same sense.
-     It complements the GNU General Public License, which is a copyleft
-     license designed for free software.
+     It complements the GNU General Public License, which is a
+     copyleft license designed for free software.
 
      We have designed this License in order to use it for manuals for
      free software, because free software needs free documentation: a
      free program should come with manuals providing the same freedoms
      that the software does.  But this License is not limited to
      software manuals; it can be used for any textual work, regardless
-     of subject matter or whether it is published as a printed book.  We
-     recommend this License principally for works whose purpose is
+     of subject matter or whether it is published as a printed book.
+     We recommend this License principally for works whose purpose is
      instruction or reference.
 
   1. APPLICABILITY AND DEFINITIONS
 
      This License applies to any manual or other work, in any medium,
-     that contains a notice placed by the copyright holder saying it can
-     be distributed under the terms of this License.  Such a notice
-     grants a world-wide, royalty-free license, unlimited in duration,
-     to use that work under the conditions stated herein.  The
-     "Document", below, refers to any such manual or work.  Any member
-     of the public is a licensee, and is addressed as "you".  You accept
-     the license if you copy, modify or distribute the work in a way
-     requiring permission under copyright law.
-
-     A "Modified Version" of the Document means any work containing the
-     Document or a portion of it, either copied verbatim, or with
+     that contains a notice placed by the copyright holder saying it
+     can be distributed under the terms of this License.  Such a
+     notice grants a world-wide, royalty-free license, unlimited in
+     duration, to use that work under the conditions stated herein.
+     The “Document”, below, refers to any such manual or work.  Any
+     member of the public is a licensee, and is addressed as “you”.
+     You accept the license if you copy, modify or distribute the work
+     in a way requiring permission under copyright law.
+
+     A “Modified Version” of the Document means any work containing
+     the Document or a portion of it, either copied verbatim, or with
      modifications and/or translated into another language.
 
-     A "Secondary Section" is a named appendix or a front-matter section
-     of the Document that deals exclusively with the relationship of the
-     publishers or authors of the Document to the Document's overall
-     subject (or to related matters) and contains nothing that could
-     fall directly within that overall subject.  (Thus, if the Document
-     is in part a textbook of mathematics, a Secondary Section may not
-     explain any mathematics.)  The relationship could be a matter of
-     historical connection with the subject or with related matters, or
-     of legal, commercial, philosophical, ethical or political position
-     regarding them.
-
-     The "Invariant Sections" are certain Secondary Sections whose
-     titles are designated, as being those of Invariant Sections, in the
-     notice that says that the Document is released under this License.
-     If a section does not fit the above definition of Secondary then it
-     is not allowed to be designated as Invariant.  The Document may
-     contain zero Invariant Sections.  If the Document does not identify
-     any Invariant Sections then there are none.
-
-     The "Cover Texts" are certain short passages of text that are
+     A “Secondary Section” is a named appendix or a front-matter
+     section of the Document that deals exclusively with the
+     relationship of the publishers or authors of the Document to the
+     Document’s overall subject (or to related matters) and contains
+     nothing that could fall directly within that overall subject.
+     (Thus, if the Document is in part a textbook of mathematics, a
+     Secondary Section may not explain any mathematics.)  The
+     relationship could be a matter of historical connection with the
+     subject or with related matters, or of legal, commercial,
+     philosophical, ethical or political position regarding them.
+
+     The “Invariant Sections” are certain Secondary Sections whose
+     titles are designated, as being those of Invariant Sections, in
+     the notice that says that the Document is released under this
+     License.  If a section does not fit the above definition of
+     Secondary then it is not allowed to be designated as Invariant.
+     The Document may contain zero Invariant Sections.  If the
+     Document does not identify any Invariant Sections then there are
+     none.
+
+     The “Cover Texts” are certain short passages of text that are
      listed, as Front-Cover Texts or Back-Cover Texts, in the notice
      that says that the Document is released under this License.  A
-     Front-Cover Text may be at most 5 words, and a Back-Cover Text may
-     be at most 25 words.
-
-     A "Transparent" copy of the Document means a machine-readable copy,
-     represented in a format whose specification is available to the
-     general public, that is suitable for revising the document
-     straightforwardly with generic text editors or (for images composed
-     of pixels) generic paint programs or (for drawings) some widely
-     available drawing editor, and that is suitable for input to text
-     formatters or for automatic translation to a variety of formats
-     suitable for input to text formatters.  A copy made in an otherwise
-     Transparent file format whose markup, or absence of markup, has
-     been arranged to thwart or discourage subsequent modification by
-     readers is not Transparent.  An image format is not Transparent if
-     used for any substantial amount of text.  A copy that is not
-     "Transparent" is called "Opaque".
+     Front-Cover Text may be at most 5 words, and a Back-Cover Text
+     may be at most 25 words.
+
+     A “Transparent” copy of the Document means a machine-readable
+     copy, represented in a format whose specification is available to
+     the general public, that is suitable for revising the document
+     straightforwardly with generic text editors or (for images
+     composed of pixels) generic paint programs or (for drawings) some
+     widely available drawing editor, and that is suitable for input
+     to text formatters or for automatic translation to a variety of
+     formats suitable for input to text formatters.  A copy made in an
+     otherwise Transparent file format whose markup, or absence of
+     markup, has been arranged to thwart or discourage subsequent
+     modification by readers is not Transparent.  An image format is
+     not Transparent if used for any substantial amount of text.  A
+     copy that is not “Transparent” is called “Opaque”.
 
      Examples of suitable formats for Transparent copies include plain
      ASCII without markup, Texinfo input format, LaTeX input format,
-     SGML or XML using a publicly available DTD, and standard-conforming
-     simple HTML, PostScript or PDF designed for human modification.
-     Examples of transparent image formats include PNG, XCF and JPG.
-     Opaque formats include proprietary formats that can be read and
-     edited only by proprietary word processors, SGML or XML for which
-     the DTD and/or processing tools are not generally available, and
-     the machine-generated HTML, PostScript or PDF produced by some word
-     processors for output purposes only.
-
-     The "Title Page" means, for a printed book, the title page itself,
-     plus such following pages as are needed to hold, legibly, the
-     material this License requires to appear in the title page.  For
-     works in formats which do not have any title page as such, "Title
-     Page" means the text near the most prominent appearance of the
-     work's title, preceding the beginning of the body of the text.
-
-     The "publisher" means any person or entity that distributes copies
-     of the Document to the public.
-
-     A section "Entitled XYZ" means a named subunit of the Document
-     whose title either is precisely XYZ or contains XYZ in parentheses
-     following text that translates XYZ in another language.  (Here XYZ
-     stands for a specific section name mentioned below, such as
-     "Acknowledgements", "Dedications", "Endorsements", or "History".)
-     To "Preserve the Title" of such a section when you modify the
-     Document means that it remains a section "Entitled XYZ" according
-     to this definition.
+     SGML or XML using a publicly available DTD, and
+     standard-conforming simple HTML, PostScript or PDF designed for
+     human modification.  Examples of transparent image formats
+     include PNG, XCF and JPG. Opaque formats include proprietary
+     formats that can be read and edited only by proprietary word
+     processors, SGML or XML for which the DTD and/or processing tools
+     are not generally available, and the machine-generated HTML,
+     PostScript or PDF produced by some word processors for output
+     purposes only.
+
+     The “Title Page” means, for a printed book, the title page
+     itself, plus such following pages as are needed to hold, legibly,
+     the material this License requires to appear in the title page.
+     For works in formats which do not have any title page as such,
+     “Title Page” means the text near the most prominent appearance of
+     the work’s title, preceding the beginning of the body of the
+     text.
+
+     The “publisher” means any person or entity that distributes
+     copies of the Document to the public.
+
+     A section “Entitled XYZ” means a named subunit of the Document
+     whose title either is precisely XYZ or contains XYZ in
+     parentheses following text that translates XYZ in another
+     language.  (Here XYZ stands for a specific section name mentioned
+     below, such as “Acknowledgements”, “Dedications”, “Endorsements”,
+     or “History”.)  To “Preserve the Title” of such a section when
+     you modify the Document means that it remains a section “Entitled
+     XYZ” according to this definition.
 
      The Document may include Warranty Disclaimers next to the notice
      which states that this License applies to the Document.  These
-     Warranty Disclaimers are considered to be included by reference in
-     this License, but only as regards disclaiming warranties: any other
-     implication that these Warranty Disclaimers may have is void and
-     has no effect on the meaning of this License.
+     Warranty Disclaimers are considered to be included by reference
+     in this License, but only as regards disclaiming warranties: any
+     other implication that these Warranty Disclaimers may have is
+     void and has no effect on the meaning of this License.
 
   2. VERBATIM COPYING
 
      You may copy and distribute the Document in any medium, either
      commercially or noncommercially, provided that this License, the
      copyright notices, and the license notice saying this License
-     applies to the Document are reproduced in all copies, and that you
-     add no other conditions whatsoever to those of this License.  You
-     may not use technical measures to obstruct or control the reading
-     or further copying of the copies you make or distribute.  However,
-     you may accept compensation in exchange for copies.  If you
-     distribute a large enough number of copies you must also follow the
-     conditions in section 3.
+     applies to the Document are reproduced in all copies, and that
+     you add no other conditions whatsoever to those of this License.
+     You may not use technical measures to obstruct or control the
+     reading or further copying of the copies you make or distribute.
+     However, you may accept compensation in exchange for copies.  If
+     you distribute a large enough number of copies you must also
+     follow the conditions in section 3.
 
      You may also lend copies, under the same conditions stated above,
      and you may publicly display copies.
@@ -610,17 +1009,18 @@ Appendix A GNU Free Documentation License
   3. COPYING IN QUANTITY
 
      If you publish printed copies (or copies in media that commonly
-     have printed covers) of the Document, numbering more than 100, and
-     the Document's license notice requires Cover Texts, you must
+     have printed covers) of the Document, numbering more than 100,
+     and the Document’s license notice requires Cover Texts, you must
      enclose the copies in covers that carry, clearly and legibly, all
      these Cover Texts: Front-Cover Texts on the front cover, and
-     Back-Cover Texts on the back cover.  Both covers must also clearly
-     and legibly identify you as the publisher of these copies.  The
-     front cover must present the full title with all words of the title
-     equally prominent and visible.  You may add other material on the
-     covers in addition.  Copying with changes limited to the covers, as
-     long as they preserve the title of the Document and satisfy these
-     conditions, can be treated as verbatim copying in other respects.
+     Back-Cover Texts on the back cover.  Both covers must also
+     clearly and legibly identify you as the publisher of these
+     copies.  The front cover must present the full title with all
+     words of the title equally prominent and visible.  You may add
+     other material on the covers in addition.  Copying with changes
+     limited to the covers, as long as they preserve the title of the
+     Document and satisfy these conditions, can be treated as verbatim
+     copying in other respects.
 
      If the required texts for either cover are too voluminous to fit
      legibly, you should put the first ones listed (as many as fit
@@ -628,39 +1028,40 @@ Appendix A GNU Free Documentation License
      adjacent pages.
 
      If you publish or distribute Opaque copies of the Document
-     numbering more than 100, you must either include a machine-readable
-     Transparent copy along with each Opaque copy, or state in or with
-     each Opaque copy a computer-network location from which the general
-     network-using public has access to download using public-standard
-     network protocols a complete Transparent copy of the Document, free
-     of added material.  If you use the latter option, you must take
-     reasonably prudent steps, when you begin distribution of Opaque
-     copies in quantity, to ensure that this Transparent copy will
-     remain thus accessible at the stated location until at least one
-     year after the last time you distribute an Opaque copy (directly or
-     through your agents or retailers) of that edition to the public.
-
-     It is requested, but not required, that you contact the authors of
-     the Document well before redistributing any large number of copies,
-     to give them a chance to provide you with an updated version of the
-     Document.
+     numbering more than 100, you must either include a
+     machine-readable Transparent copy along with each Opaque copy, or
+     state in or with each Opaque copy a computer-network location
+     from which the general network-using public has access to
+     download using public-standard network protocols a complete
+     Transparent copy of the Document, free of added material.  If you
+     use the latter option, you must take reasonably prudent steps,
+     when you begin distribution of Opaque copies in quantity, to
+     ensure that this Transparent copy will remain thus accessible at
+     the stated location until at least one year after the last time
+     you distribute an Opaque copy (directly or through your agents or
+     retailers) of that edition to the public.
+
+     It is requested, but not required, that you contact the authors
+     of the Document well before redistributing any large number of
+     copies, to give them a chance to provide you with an updated
+     version of the Document.
 
   4. MODIFICATIONS
 
      You may copy and distribute a Modified Version of the Document
      under the conditions of sections 2 and 3 above, provided that you
-     release the Modified Version under precisely this License, with the
-     Modified Version filling the role of the Document, thus licensing
-     distribution and modification of the Modified Version to whoever
-     possesses a copy of it.  In addition, you must do these things in
-     the Modified Version:
+     release the Modified Version under precisely this License, with
+     the Modified Version filling the role of the Document, thus
+     licensing distribution and modification of the Modified Version
+     to whoever possesses a copy of it.  In addition, you must do
+     these things in the Modified Version:
 
        A. Use in the Title Page (and on the covers, if any) a title
-          distinct from that of the Document, and from those of previous
-          versions (which should, if there were any, be listed in the
-          History section of the Document).  You may use the same title
-          as a previous version if the original publisher of that
-          version gives permission.
+          distinct from that of the Document, and from those of
+          previous versions (which should, if there were any, be
+          listed in the History section of the Document).  You may use
+          the same title as a previous version if the original
+          publisher of that version gives permission.
 
        B. List on the Title Page, as authors, one or more persons or
           entities responsible for authorship of the modifications in
@@ -679,160 +1080,163 @@ Appendix A GNU Free Documentation License
 
        F. Include, immediately after the copyright notices, a license
           notice giving the public permission to use the Modified
-          Version under the terms of this License, in the form shown in
-          the Addendum below.
+          Version under the terms of this License, in the form shown
+          in the Addendum below.
 
        G. Preserve in that license notice the full lists of Invariant
-          Sections and required Cover Texts given in the Document's
+          Sections and required Cover Texts given in the Document’s
           license notice.
 
        H. Include an unaltered copy of this License.
 
-       I. Preserve the section Entitled "History", Preserve its Title,
+       I. Preserve the section Entitled “History”, Preserve its Title,
           and add to it an item stating at least the title, year, new
-          authors, and publisher of the Modified Version as given on the
-          Title Page.  If there is no section Entitled "History" in the
-          Document, create one stating the title, year, authors, and
-          publisher of the Document as given on its Title Page, then add
-          an item describing the Modified Version as stated in the
-          previous sentence.
+          authors, and publisher of the Modified Version as given on
+          the Title Page.  If there is no section Entitled “History”
+          in the Document, create one stating the title, year,
+          authors, and publisher of the Document as given on its Title
+          Page, then add an item describing the Modified Version as
+          stated in the previous sentence.
 
        J. Preserve the network location, if any, given in the Document
           for public access to a Transparent copy of the Document, and
           likewise the network locations given in the Document for
-          previous versions it was based on.  These may be placed in the
-          "History" section.  You may omit a network location for a work
-          that was published at least four years before the Document
-          itself, or if the original publisher of the version it refers
-          to gives permission.
-
-       K. For any section Entitled "Acknowledgements" or "Dedications",
-          Preserve the Title of the section, and preserve in the section
-          all the substance and tone of each of the contributor
-          acknowledgements and/or dedications given therein.
-
-       L. Preserve all the Invariant Sections of the Document, unaltered
-          in their text and in their titles.  Section numbers or the
-          equivalent are not considered part of the section titles.
-
-       M. Delete any section Entitled "Endorsements".  Such a section
+          previous versions it was based on.  These may be placed in
+          the “History” section.  You may omit a network location for
+          a work that was published at least four years before the
+          Document itself, or if the original publisher of the version
+          it refers to gives permission.
+
+       K. For any section Entitled “Acknowledgements” or
+          “Dedications”, Preserve the Title of the section, and
+          preserve in the section all the substance and tone of each
+          of the contributor acknowledgements and/or dedications given
+          therein.
+
+       L. Preserve all the Invariant Sections of the Document,
+          unaltered in their text and in their titles.  Section
+          numbers or the equivalent are not considered part of the
+          section titles.
+
+       M. Delete any section Entitled “Endorsements”.  Such a section
           may not be included in the Modified Version.
 
        N. Do not retitle any existing section to be Entitled
-          "Endorsements" or to conflict in title with any Invariant
+          “Endorsements” or to conflict in title with any Invariant
           Section.
 
        O. Preserve any Warranty Disclaimers.
 
      If the Modified Version includes new front-matter sections or
      appendices that qualify as Secondary Sections and contain no
-     material copied from the Document, you may at your option designate
-     some or all of these sections as invariant.  To do this, add their
-     titles to the list of Invariant Sections in the Modified Version's
-     license notice.  These titles must be distinct from any other
-     section titles.
-
-     You may add a section Entitled "Endorsements", provided it contains
-     nothing but endorsements of your Modified Version by various
-     parties--for example, statements of peer review or that the text
-     has been approved by an organization as the authoritative
-     definition of a standard.
+     material copied from the Document, you may at your option
+     designate some or all of these sections as invariant.  To do
+     this, add their titles to the list of Invariant Sections in the
+     Modified Version’s license notice.  These titles must be distinct
+     from any other section titles.
+
+     You may add a section Entitled “Endorsements”, provided it
+     contains nothing but endorsements of your Modified Version by
+     various parties—for example, statements of peer review or that
+     the text has been approved by an organization as the
+     authoritative definition of a standard.
 
      You may add a passage of up to five words as a Front-Cover Text,
-     and a passage of up to 25 words as a Back-Cover Text, to the end of
-     the list of Cover Texts in the Modified Version.  Only one passage
-     of Front-Cover Text and one of Back-Cover Text may be added by (or
-     through arrangements made by) any one entity.  If the Document
-     already includes a cover text for the same cover, previously added
-     by you or by arrangement made by the same entity you are acting on
-     behalf of, you may not add another; but you may replace the old
-     one, on explicit permission from the previous publisher that added
-     the old one.
+     and a passage of up to 25 words as a Back-Cover Text, to the end
+     of the list of Cover Texts in the Modified Version.  Only one
+     passage of Front-Cover Text and one of Back-Cover Text may be
+     added by (or through arrangements made by) any one entity.  If
+     the Document already includes a cover text for the same cover,
+     previously added by you or by arrangement made by the same entity
+     you are acting on behalf of, you may not add another; but you may
+     replace the old one, on explicit permission from the previous
+     publisher that added the old one.
 
      The author(s) and publisher(s) of the Document do not by this
-     License give permission to use their names for publicity for or to
-     assert or imply endorsement of any Modified Version.
+     License give permission to use their names for publicity for or
+     to assert or imply endorsement of any Modified Version.
 
   5. COMBINING DOCUMENTS
 
      You may combine the Document with other documents released under
      this License, under the terms defined in section 4 above for
-     modified versions, provided that you include in the combination all
-     of the Invariant Sections of all of the original documents,
+     modified versions, provided that you include in the combination
+     all of the Invariant Sections of all of the original documents,
      unmodified, and list them all as Invariant Sections of your
      combined work in its license notice, and that you preserve all
      their Warranty Disclaimers.
 
      The combined work need only contain one copy of this License, and
-     multiple identical Invariant Sections may be replaced with a single
-     copy.  If there are multiple Invariant Sections with the same name
-     but different contents, make the title of each such section unique
-     by adding at the end of it, in parentheses, the name of the
-     original author or publisher of that section if known, or else a
-     unique number.  Make the same adjustment to the section titles in
-     the list of Invariant Sections in the license notice of the
-     combined work.
+     multiple identical Invariant Sections may be replaced with a
+     single copy.  If there are multiple Invariant Sections with the
+     same name but different contents, make the title of each such
+     section unique by adding at the end of it, in parentheses, the
+     name of the original author or publisher of that section if
+     known, or else a unique number.  Make the same adjustment to the
+     section titles in the list of Invariant Sections in the license
+     notice of the combined work.
 
      In the combination, you must combine any sections Entitled
-     "History" in the various original documents, forming one section
-     Entitled "History"; likewise combine any sections Entitled
-     "Acknowledgements", and any sections Entitled "Dedications".  You
-     must delete all sections Entitled "Endorsements."
+     “History” in the various original documents, forming one section
+     Entitled “History”; likewise combine any sections Entitled
+     “Acknowledgements”, and any sections Entitled “Dedications”.  You
+     must delete all sections Entitled “Endorsements.”
 
   6. COLLECTIONS OF DOCUMENTS
 
      You may make a collection consisting of the Document and other
      documents released under this License, and replace the individual
-     copies of this License in the various documents with a single copy
-     that is included in the collection, provided that you follow the
-     rules of this License for verbatim copying of each of the documents
-     in all other respects.
+     copies of this License in the various documents with a single
+     copy that is included in the collection, provided that you follow
+     the rules of this License for verbatim copying of each of the
+     documents in all other respects.
 
      You may extract a single document from such a collection, and
-     distribute it individually under this License, provided you insert
-     a copy of this License into the extracted document, and follow this
-     License in all other respects regarding verbatim copying of that
-     document.
+     distribute it individually under this License, provided you
+     insert a copy of this License into the extracted document, and
+     follow this License in all other respects regarding verbatim
+     copying of that document.
 
   7. AGGREGATION WITH INDEPENDENT WORKS
 
      A compilation of the Document or its derivatives with other
-     separate and independent documents or works, in or on a volume of a
-     storage or distribution medium, is called an "aggregate" if the
+     separate and independent documents or works, in or on a volume of
+     a storage or distribution medium, is called an “aggregate” if the
      copyright resulting from the compilation is not used to limit the
-     legal rights of the compilation's users beyond what the individual
-     works permit.  When the Document is included in an aggregate, this
-     License does not apply to the other works in the aggregate which
-     are not themselves derivative works of the Document.
+     legal rights of the compilation’s users beyond what the
+     individual works permit.  When the Document is included in an
+     aggregate, this License does not apply to the other works in the
+     aggregate which are not themselves derivative works of the
+     Document.
 
      If the Cover Text requirement of section 3 is applicable to these
-     copies of the Document, then if the Document is less than one half
-     of the entire aggregate, the Document's Cover Texts may be placed
-     on covers that bracket the Document within the aggregate, or the
-     electronic equivalent of covers if the Document is in electronic
-     form.  Otherwise they must appear on printed covers that bracket
-     the whole aggregate.
+     copies of the Document, then if the Document is less than one
+     half of the entire aggregate, the Document’s Cover Texts may be
+     placed on covers that bracket the Document within the aggregate,
+     or the electronic equivalent of covers if the Document is in
+     electronic form.  Otherwise they must appear on printed covers
+     that bracket the whole aggregate.
 
   8. TRANSLATION
 
      Translation is considered a kind of modification, so you may
-     distribute translations of the Document under the terms of section
-     4.  Replacing Invariant Sections with translations requires special
-     permission from their copyright holders, but you may include
-     translations of some or all Invariant Sections in addition to the
-     original versions of these Invariant Sections.  You may include a
-     translation of this License, and all the license notices in the
-     Document, and any Warranty Disclaimers, provided that you also
-     include the original English version of this License and the
-     original versions of those notices and disclaimers.  In case of a
-     disagreement between the translation and the original version of
-     this License or a notice or disclaimer, the original version will
-     prevail.
-
-     If a section in the Document is Entitled "Acknowledgements",
-     "Dedications", or "History", the requirement (section 4) to
-     Preserve its Title (section 1) will typically require changing the
-     actual title.
+     distribute translations of the Document under the terms of
+     section 4.  Replacing Invariant Sections with translations
+     requires special permission from their copyright holders, but you
+     may include translations of some or all Invariant Sections in
+     addition to the original versions of these Invariant Sections.
+     You may include a translation of this License, and all the
+     license notices in the Document, and any Warranty Disclaimers,
+     provided that you also include the original English version of
+     this License and the original versions of those notices and
+     disclaimers.  In case of a disagreement between the translation
+     and the original version of this License or a notice or
+     disclaimer, the original version will prevail.
+
+     If a section in the Document is Entitled “Acknowledgements”,
+     “Dedications”, or “History”, the requirement (section 4) to
+     Preserve its Title (section 1) will typically require changing
+     the actual title.
 
   9. TERMINATION
 
@@ -843,65 +1247,66 @@ Appendix A GNU Free Documentation License
 
      However, if you cease all violation of this License, then your
      license from a particular copyright holder is reinstated (a)
-     provisionally, unless and until the copyright holder explicitly and
-     finally terminates your license, and (b) permanently, if the
+     provisionally, unless and until the copyright holder explicitly
+     and finally terminates your license, and (b) permanently, if the
      copyright holder fails to notify you of the violation by some
      reasonable means prior to 60 days after the cessation.
 
      Moreover, your license from a particular copyright holder is
-     reinstated permanently if the copyright holder notifies you of the
-     violation by some reasonable means, this is the first time you have
-     received notice of violation of this License (for any work) from
-     that copyright holder, and you cure the violation prior to 30 days
-     after your receipt of the notice.
+     reinstated permanently if the copyright holder notifies you of
+     the violation by some reasonable means, this is the first time
+     you have received notice of violation of this License (for any
+     work) from that copyright holder, and you cure the violation
+     prior to 30 days after your receipt of the notice.
 
      Termination of your rights under this section does not terminate
-     the licenses of parties who have received copies or rights from you
-     under this License.  If your rights have been terminated and not
-     permanently reinstated, receipt of a copy of some or all of the
-     same material does not give you any rights to use it.
+     the licenses of parties who have received copies or rights from
+     you under this License.  If your rights have been terminated and
+     not permanently reinstated, receipt of a copy of some or all of
+     the same material does not give you any rights to use it.
 
   10. FUTURE REVISIONS OF THIS LICENSE
 
      The Free Software Foundation may publish new, revised versions of
      the GNU Free Documentation License from time to time.  Such new
-     versions will be similar in spirit to the present version, but may
-     differ in detail to address new problems or concerns.  See
+     versions will be similar in spirit to the present version, but
+     may differ in detail to address new problems or concerns.  See
      <http://www.gnu.org/copyleft/>.
 
      Each version of the License is given a distinguishing version
      number.  If the Document specifies that a particular numbered
-     version of this License "or any later version" applies to it, you
+     version of this License “or any later version” applies to it, you
      have the option of following the terms and conditions either of
      that specified version or of any later version that has been
-     published (not as a draft) by the Free Software Foundation.  If the
-     Document does not specify a version number of this License, you may
-     choose any version ever published (not as a draft) by the Free
-     Software Foundation.  If the Document specifies that a proxy can
-     decide which future versions of this License can be used, that
-     proxy's public statement of acceptance of a version permanently
-     authorizes you to choose that version for the Document.
+     published (not as a draft) by the Free Software Foundation.  If
+     the Document does not specify a version number of this License,
+     you may choose any version ever published (not as a draft) by the
+     Free Software Foundation.  If the Document specifies that a proxy
+     can decide which future versions of this License can be used,
+     that proxy’s public statement of acceptance of a version
+     permanently authorizes you to choose that version for the
+     Document.
 
   11. RELICENSING
 
-     "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
-     World Wide Web server that publishes copyrightable works and also
-     provides prominent facilities for anybody to edit those works.  A
-     public wiki that anybody can edit is an example of such a server.
-     A "Massive Multiauthor Collaboration" (or "MMC") contained in the
-     site means any set of copyrightable works thus published on the MMC
-     site.
+     “Massive Multiauthor Collaboration Site” (or “MMC Site”) means
+     any World Wide Web server that publishes copyrightable works and
+     also provides prominent facilities for anybody to edit those
+     works.  A public wiki that anybody can edit is an example of such
+     a server.  A “Massive Multiauthor Collaboration” (or “MMC”)
+     contained in the site means any set of copyrightable works thus
+     published on the MMC site.
 
-     "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
-     license published by Creative Commons Corporation, a not-for-profit
-     corporation with a principal place of business in San Francisco,
-     California, as well as future copyleft versions of that license
-     published by that same organization.
+     “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0
+     license published by Creative Commons Corporation, a
+     not-for-profit corporation with a principal place of business in
+     San Francisco, California, as well as future copyleft versions of
+     that license published by that same organization.
 
-     "Incorporate" means to publish or republish a Document, in whole or
-     in part, as part of another Document.
+     “Incorporate” means to publish or republish a Document, in whole
+     or in part, as part of another Document.
 
-     An MMC is "eligible for relicensing" if it is licensed under this
+     An MMC is “eligible for relicensing” if it is licensed under this
      License, and if all works that were first published under this
      License somewhere other than this MMC, and subsequently
      incorporated in whole or in part into the MMC, (1) had no cover
@@ -916,8 +1321,8 @@ ADDENDUM: How to use this License for your documents
 ====================================================
 
 To use this License in a document you have written, include a copy of
-the License in the document and put the following copyright and license
-notices just after the title page:
+the License in the document and put the following copyright and
+license notices just after the title page:
 
        Copyright (C)  YEAR  YOUR NAME.
        Permission is granted to copy, distribute and/or modify this document
@@ -928,7 +1333,7 @@ notices just after the title page:
        Free Documentation License''.
 
    If you have Invariant Sections, Front-Cover Texts and Back-Cover
-Texts, replace the "with...Texts."  line with this:
+Texts, replace the “with...Texts.” line with this:
 
          with the Invariant Sections being LIST THEIR TITLES, with
          the Front-Cover Texts being LIST, and with the Back-Cover Texts
@@ -939,35 +1344,44 @@ combination of the three, merge those two alternatives 
to suit the
 situation.
 
    If your document contains nontrivial examples of program code, we
-recommend releasing these examples in parallel under your choice of free
-software license, such as the GNU General Public License, to permit
-their use in free software.
+recommend releasing these examples in parallel under your choice of
+free software license, such as the GNU General Public License, to
+permit their use in free software.
 
 
 
 Tag Table:
-Node: Top772
-Node: Introduction2846
-Ref: Introduction-Footnote-13597
-Node: Installation3644
-Node: Activation4761
-Ref: Activation-Footnote-15428
-Node: Feedback5554
-Ref: Feedback-Footnote-15972
-Node: Navigation mode6193
-Node: Record navigation7931
-Node: Field navigation8887
-Node: Field folding9563
-Node: Field edition10309
-Node: Searches12103
-Node: Statistics12879
-Node: Data integrity13948
-Node: Edition modes14460
-Ref: Edition modes-Footnote-116349
-Node: Configuration16380
-Node: Finding the recutils16681
-Node: Records appearance17295
-Node: GNU Free Documentation License17798
+Node: Top775
+Node: Introduction3395
+Ref: Introduction-Footnote-14146
+Node: Installation4193
+Node: Activation5342
+Ref: Activation-Footnote-15931
+Node: Feedback6063
+Ref: Feedback-Footnote-16481
+Node: Navigation mode6702
+Node: Record navigation8447
+Node: Field navigation9440
+Node: Field folding10129
+Node: Field edition10880
+Node: Searches12714
+Node: Statistics13520
+Node: Data integrity14611
+Node: Edition modes15137
+Ref: Edition modes-Footnote-117094
+Node: Summary mode17125
+Node: Selecting records19084
+Node: Buffer from selection20327
+Node: Selection mode21267
+Node: Cross referencing23062
+Node: Cross referencing by selection24688
+Node: Configuration25483
+Node: Finding the recutils25845
+Node: Records appearance26512
+Node: Command Index27036
+Node: Key Index29676
+Node: Variable and Concept Index32255
+Node: GNU Free Documentation License34913
 
 End Tag Table
 
diff --git a/rec-mode.texi b/rec-mode.texi
index 3332862..44d1123 100644
--- a/rec-mode.texi
+++ b/rec-mode.texi
@@ -1,10 +1,12 @@
 \input texinfo
 @comment %**start of header
+@documentencoding UTF-8
 @setfilename rec-mode.info
 @settitle rec-mode for Emacs
-@set UPDATED 13 November 2020
+@set UPDATED 27 November 2020
 @set EDITION 1.8.90
 @set VERSION 1.8.90
+@set RECMODEVERSION 1.7.0
 @afourpaper
 @comment %**end of header
 
@@ -15,9 +17,16 @@
 @end macro
 
 @macro reccmd{key,command}
-@item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
+@item \key\
+@itemx M-x \command\
+@kindex \key\
+@findex \command\
+@c
 @end macro
 
+@c Merge variable and concept indexes
+@synindex cp vr
+
 @copying
 This manual is for rec-mode for Emacs, which is part of the GNU
 recutils suite (version @value{VERSION}, @value{UPDATED}).
@@ -54,7 +63,7 @@ Documentation License''.
 @node Top
 @top rec-mode: an Emacs mode for editing recfiles
 
-This manual documents version @value{VERSION} of rec-mode.
+This manual documents version @value{RECMODEVERSION} of rec-mode.
 
 @insertcopying
 @end ifnottex
@@ -63,8 +72,14 @@ This manual documents version @value{VERSION} of rec-mode.
 * Introduction::                Getting started
 * Navigation mode::             User-friendly interface for browing recfiles
 * Edition modes::               Edit recfiles in rec-format
+* Summary mode::                List records in a table.
+* Selecting records::           Run queries on the current buffer.
+* Cross referencing::           Cross reference records.
 * Configuration::               Adapting rec-mode to your needs
-* GNU Free Documentation License:: Distribution terms for this document
+* Command Index::               Command and Function Index
+* Key Index::                   Key (Character) Index
+* Variable and Concept Index::  Variable and Concept Index
+* GNU Free Documentation License::  Distribution terms for this document
 
 @detailmenu
  --- The Detailed Node Listing ---
@@ -77,22 +92,29 @@ Introduction
 
 Navigation mode
 
-* Record navigation::           Moving through records.
-* Field navigation::            Moving through fields in a record.
-* Field folding::               Hiding and showing the values of fields.
-* Field edition::               Changing the values of fields.
-* Searches::                    Finding records fufilling some criteria.
-* Statistics::                  Counting records.
-* Data integrity::              Verifying the integrity of the recfile.
+* Record navigation::           Moving through records
+* Field navigation::            Moving through fields in a record
+* Field folding::               Hiding and showing the values of fields
+* Field edition::               Changing the values of fields
+* Searches::                    Finding records fulfilling some criteria
+* Statistics::                  Counting records
+* Data integrity::              Verifying the integrity of the recfile
 
-Edition modes
+Selecting records
 
-* Edition modes::               Edit recfiles in rec-format
+* Buffer from selection::       Copy the selection into a new recfile buffer.
+* Selection mode::              Navigate the current buffer based on a search.
+
+
+Cross referencing
+
+* Cross referencing by selection:: Cross reference matching selections.
 
 Configuration
 
 * Finding the recutils::        Specifying the location of the recutils.
-* Records appearance::          Setting the way records are displayed.
+* Records appearance::          Setting the way records are displayed
+
 @end detailmenu
 @end menu
 
@@ -123,10 +145,10 @@ rec-mode is implemented in a self-contained elisp file 
called
 @file{rec-mode.el}.  It can be obtained in several ways:
 
 @itemize @minus
-@item As part of a released tarball of recutils.  @file{rec-mode.el}
-can be found in the @file{etc/} directory in the tarball contents.
+@item From @url{https://elpa.gnu.org/packages/rec-mode.html, GNU ELPA}
+using the built-in Emacs package manager. 
 @item As part of the source tree cloned from the development git
-repo.  @file{rec-mode.el} can be found in the @file{etc/} directory in
+repository of rec-mode.  @file{rec-mode.el} can be found in the root directory 
of
 the recutils sources tree.
 @item As a single file downloaded form some other location in
 internet.
@@ -134,9 +156,10 @@ internet.
 distribution.
 @end itemize
 
-@noindent In the first three cases you need to tell Emacs where to locate the
+@noindent In the second case you need to tell Emacs where to locate the
 @file{rec-mode.el} file and to load it.  Add the following to your
 @file{.emacs} file.
+
 @lisp
 (add-to-list 'load-path "~/path/to/recmode/")
 (require 'rec-mode)
@@ -151,19 +174,15 @@ have to @code{require} the package.
 @section Activation
 @cindex activation
 
+rec-mode should automatically activate when opening @file{.rec} files.
 To make sure files with extension @file{.rec} use rec-mode, add the
-following line to your @file{.emacs} file.
-@lisp
-(add-to-list 'auto-mode-alist '("\\.rec\\'" . rec-mode))
-@end lisp
 @noindent rec-mode buffers need font-lock to be turned on - this is
 the default in Emacs@footnote{If you don't use font-lock globally,
 turn it on in the rec buffer with @code{(add-hook 'rec-mode-hook
 'turn-on-font-lock)}}.
 
-With this setup, all files with extension @samp{.rec} will be put into
-rec mode.  As an alternative, make the first line of a recfile look
-like this:
+If the file doesn't end in @file{.rec}, make the first line of a
+recfile look like this:
 
 @example
 # -*- mode: rec -*-
@@ -190,6 +209,8 @@ The subscription can be done online at
 
 @node Navigation mode
 @chapter Navigation mode
+@cindex navigation mode
+@cindex modes, navigation
 
 When a recfile is visited in Emacs and rec-mode is activated, the
 contents of the file are examined and parsed in order to determine if
@@ -232,7 +253,7 @@ following subsections.
 
 The following commands jump to other records in the buffer.
 
-@table @asis
+@table @kbd
 @reccmd{n,rec-cmd-goto-next-rec}
 Display the next record of the same type in the buffer.
 @*`C-u N n' will move next N times.
@@ -256,11 +277,12 @@ display the first record of the selected type.
 The following commands iterate through the fields in a record, and to
 get information about some of the properties of the fields.
 
-@table @asis
+@table @kbd
 @reccmd{TAB, rec-cmd-goto-next-field}
 Move the cursor to the beginning of the name of the next field in the
 current record.  If the cursor is currently located at the last field
 of the record then move it to the beginning of the first field.
+
 @reccmd{t, rec-cmd-show-type}
 Show information about the type of the field under the cursor, if it
 is defined.
@@ -268,13 +290,14 @@ is defined.
 
 @node Field folding
 @section Field folding
+@cindex folding
 
 Fields in recfiles can contain data of any size, and sometimes it is
 difficult to have an overview of the contents of the record.  The
 following commands fold and unfold the value of the field under the
 cursor.
 
-@table @asis
+@table @kbd
 @reccmd{SPC, rec-cmd-toggle-field-visibility}
 Toggle the visibility of the field under the cursor.  When a field is
 folded then three dots are displayed in the buffer instead of the
@@ -287,10 +310,12 @@ appearance}.
 
 @node Field edition
 @section Field edition
+@cindex editing fields
+@cindex edition, fields
 
 The following commands change the value of the field under the cursor.
 
-@table @asis
+@table @kbd
 @reccmd{e, rec-cmd-edit-field}
 Edit the value of the field under the cursor.  The specific action
 depends on the type of the field in the corresponding record
@@ -326,13 +351,13 @@ leading and trailing blank characters.
 The following commands jump to the first record in the buffer
 satisfying some criteria.
 
-@table @asis
-@reccmd{s q, rec-cmd-select-fast}
+@table @kbd
+@reccmd{s q, rec-cmd-jump-to-fast}
 Display the first record having a field whose value matches a given
 fixed pattern.  This is equivalent of using the command line option
 @option{-q} of @command{recsel}.  If a prefix argument is specified
 then the search is case-insensitive.
-@reccmd{s s, rec-cmd-select-sex}
+@reccmd{s s, rec-cmd-jump-to-sex}
 Display the first record in the buffer satisfying a given selection
 expression.  This is equivalent of using the command line option
 @option{-e} of @command{recsel}.  If a prefix argument is specified
@@ -341,11 +366,12 @@ then the search is case-insensitive.
 
 @node Statistics
 @section Statistics
+@cindex counting
 
 The following commands allow to count records in the current buffer
 based on some provided criteria.
 
-@table @asis
+@table @kbd
 @reccmd{I, rec-cmd-show-info}
 Show the number of records in the buffer categorized by type.
 @reccmd{#, rec-cmd-count}
@@ -366,11 +392,12 @@ each of the possible values of the enumerated type.
 
 @node Data integrity
 @section Data integrity
+@cindex fixing records
 
 The integrity of the rec data stored in the file can be checked using
 the following commands.
 
-@table @asis
+@table @kbd
 @reccmd{c, rec-cmd-compile}
 Compile the buffer with @command{recfix} and open a compilation window
 showing the result of the command.  In case some error or warning is
@@ -380,6 +407,8 @@ pressing @kbd{RET} in the compilation window.
 
 @node Edition modes
 @chapter Edition modes
+@cindex edition modes
+@cindex modes, edition
 
 The navigation mode described in a previous chapter is mainly intended
 for browsing recdata and doing changes at the record level: editing
@@ -404,7 +433,7 @@ exceptions to this are the bindings @kbd{c}
 The following commands are used to enter into one of the available
 edition modes from the navigation mode.
 
-@table @asis
+@table @kbd
 @reccmd{R, rec-edit-record}
 Edit the record being navigated.
 @reccmd{T, rec-edit-type}
@@ -416,21 +445,251 @@ Edit the buffer.
 @noindent After doing modifications in the buffer, the user can go
 back to navigation mode by using the following command.
 
-@table @asis
+@table @kbd
 @reccmd{C-c C-c, rec-finish-editing}
 Finish the current edition and return to navigation mode.  If a
 syntactic error was introduced in the edition activity then the error
 is reported in the echo area and navigation mode is not entered.
 @end table
 
+@node Summary mode
+@chapter Summary mode
+@cindex summary
+@cindex modes, summary
+
+Besides the standard viewing modes of buffers, there is also a third
+option called @dfn{summary mode}.  Summary mode is a tabulated list of
+the record in which each record is a row in the table.  The columns in
+the table are determined by user input, or alternatively, by special
+keys in the current file.
+
+@table @kbd
+@reccmd{h, rec-cmd-show-summary}
+Creates a summary buffer from the current type being viewed in the
+recfile. The columns are based on user input (prompted), or if the
+record has either a @code{%summary} or @code{%key} in its descriptor,
+those fields are used.
+@end table
+
+The input for the summary query is a @dfn{field expression}, a
+comma-separated list of column names.  Thus, if your recfile looks
+like the following:
+
+@example
+Name: Ada Lovelace
+Age: 36
+
+Name: Peter the Great
+Age: 53
+
+Name: Matusalem
+Age: 969
+@end example
+
+Then calling @kbd{rec-cmd-show-summary} and entering @code{Name,Age}
+would create a table of all records with those columns.  If your
+record descriptor contains a @code{%summary} like below:
+
+@example
+%summary: Age,Name
+@end example
+
+@noindent then this is used as the field expression instead.
+Similarly, if no @code{%summary} field is defined and a @code{%key}
+field exists, then that field is used.
+
+Calling this command enters @dfn{record summary mode}, which a a major
+mode derived from @dfn{tabulated list mode} (@pxref{Tabulated List
+mode,,,elisp}). In this mode, the following bindings are available:
+
+@table @kbd
+@reccmd{n, rec-summary-cmd-next}
+Go to the next record in the summary.
+@end table
+
+@noindent Navigation inside the summary buffer maintains the position
+of the associated recfile buffer, and vice versa.  The currently
+active record in the recfile is shown highlighted in the buffer.  As a
+result, the summary can be thought of as a useful ``overview''
+overview for any recfile buffer.
+
+@node Selecting records
+@chapter Selecting records
+
+Sometimes it is useful to operate or inspect only a subset of all the
+records on the file.  To this end, rec-mode provides several ways of
+using the searching facilities of recutils.
+
+Selection can be done using two mechanisms:
+
+@itemize @bullet
+@item
+@b{selection expressions}, which are expressions that can be applied
+to a record. These offer a powerful query language for
+records. @xref{Selection Expressions,,,recutils,GNU Recutils manual}.
+
+@item
+@b{fast string searches}, which match records whose field values match
+a string.
+@end itemize
+
+For instance, you can create a new buffer out of the current buffer,
+so that only the records that match your search are copied.  This way
+you can create new recfiles out of existing ones based on selections.
+
+To help navigate the buffer based on a search, you can create a new
+navigation mode where the commands for moving between records only
+move to those matching a search.  This is known as selection mode.
+
+@menu
+* Buffer from selection::       Copy the selection into a new recfile buffer.
+* Selection mode::              Navigate the current buffer based on a search.
+
+@end menu
+
+@node Buffer from selection
+@section Buffer from selection
+@cindex selection, buffer
+
+Creating new recfiles based on selections can be done by creating a
+wholly new buffer using the @dfn{buffer from selection} commands in
+rec-mode.
+
+@table @kbd
+@reccmd{x s, rec-cmd-new-buffer-from-sex}
+Creates a new buffer from a @dfn{selection expression}. @xref{Selection
+Expressions,,,recutils,GNU Recutils Manual}.  Prompts the user for a
+selection expression and then displays a new buffer containing records
+that match the expression. 
+@reccmd{x q, rec-cmd-new-buffer-from-fast-string}
+Creates a new buffer from a @dfn{fast string search}.  Prompts the user
+for a @i{string} and then displays a new buffer which contains all
+records whose any field contains this string.
+@end table
+
+In both of these commands, if the recfile has a @dfn{record descriptor},
+it is copied as well.
+
+@node Selection mode
+@section Selection mode
+@cindex selection mode
+@cindex modes, selection
+
+In both navigation mode and the assorted edition modes,
+@code{rec-cmd-goto-next-rec} and @code{rec-cmd-goto-prev-rec} navigate
+to the next and previous record, respectively.  On large files,
+finding a particular record using these commands only can be quite
+tedious.  To this end, using selections, it is possible to jump to or
+restrict navigation to records matching selections.
+
+@noindent Restricting the navigation commands, typically
+bound to @kbd{n} and @kbd{C-c C-n} (@i{mutatis mutandis} for backward
+movement), to records that match the current selection, can be done
+using what is called @i{record selection mode}.
+
+Record selection mode is a buffer-local minor mode in which the
+commands for next and previous records as described above do not
+behave the usual way: they navigate records that only match
+the currently active selection.
+
+When selection mode is entered, any associated summary buffer
+automatically updates its contents to match that of the current
+selection.  Once selection mode is turned off, the summary buffer
+reverts back to the previous selection.
+
+Record selection mode can be entered by the following commands:
+
+@table @kbd
+@reccmd{/ s, rec-cmd-navigate-current-type-by-sex}
+Prompts the user for a selection expression, runs a query on the
+current buffer and the current type, and then enters record selection
+mode.
+@reccmd{/ q, rec-cmd-navigate-current-type-by-fast-string}
+Same as above, but with a fast string search.
+@end table
+
+@noindent In record selection mode, besides the standard navigation bindings,
+the following additional bindings are defined:
+
+@table @kbd
+
+@reccmd{/ /, rec-cmd-exit-selection}
+Exits record selection mode and restores the normal navigation keybindings.
+@end table
+
+@node Cross referencing
+@chapter Cross referencing
+@cindex cross referencing
+@cindex xref
+
+Besides navigation, edition and selection, rec-mode provides another
+powerful feature for recfiles, known as @dfn{cross referencing}. In
+short, cross referencing is an Emacs term for listing various kinds of
+search results for certain keywords an identifiers. For records, this
+could mean the following:
+
+@enumerate
+@item
+Finding the type definition of a field.
+@item
+Finding the uses of a certain type, the inverse of above.
+@item
+Finding the referred record of a foreign key.  If a field is a key
+referring to another record, you can jump to that record.
+@item
+Finding the @i{referents} of a record if it is a foreign key. 
+@item
+Finding records that match a certain selection expression or fast
+string search.
+@end enumerate
+
+@noindent Emacs provides a unified interface for this called Xref.  @xref{Find
+Identifier Referencs,,,emacs,GNU Emacs Manual}.
+
+Regardless of functionality, if there are more than one search result,
+Xref searches present their results in a special @code{XREF} buffer.
+It is an ordered list of results, similar to compilation mode
+(@pxref{Compilation Mode,,,emacs,GNU Emacs Manual}). Xref makes it
+easy to navigate between search results, as it binds the
+@code{next-error} functionality, letting you navigate the results even
+if you are @i{outside} the rec mode buffer.
+
+As of version @value{RECMODEVERSION}, Xref implements only the last
+functionality, cross referencing records by selection expressions or
+fast string searches.
+
+@menu
+* Cross referencing by selection::
+@end menu
+
+@node Cross referencing by selection
+@section Cross referencing by selection
+@cindex cross referencing, selection
+
+Cross referencing @i{by selection} lets you perform a query and then
+list the results using the Xref buffer.  Rec mode provides two such
+commands:
+
+@table @kbd
+@reccmd{X s, rec-cmd-xref-sex}
+Query the current recfile using a selection expression and the current
+type and then list the results using Xref.  Each results shows a small
+snippet of the matched record making it easier to identify which
+records matched the search.
+@reccmd{X q, rec-cmd-xref-fast-string}
+Like above, but using a fast string.  Instead of previewing the first
+three fields of a record, it shows each field where there was a match.
+@end table
+
 @node Configuration
 @chapter Configuration
 
-TBC
+rec-mode can be configured using the customization facilities of
+Emacs. 
 
 @menu
-* Finding the recutils::     Specifying the location of the recutils.
-* Records appearance::       Setting the way records are displayed
+* Finding the recutils::        Specifying the location of the recutils.
+* Records appearance::          Setting the way records are displayed
 @end menu
 
 @node Finding the recutils
@@ -441,14 +700,17 @@ the recutils.  The following variables tell the mode 
where to find the
 utilities.  The default values of these variables must work if the
 recutils are installed system-wide in the system.
 
-@table @code
-@item rec-recsel
-Name of the @command{recsel} utility from the GNU recutils.
-@item rec-recinf
+@defvar rec-recsel
+Name of the @code{recsel} utility from the GNU recutil.
+@end defvar
+
+@defvar rec-recinf
 Name of the @command{recinf} utility from the GNU recutils.
-@item rec-recfix
+@end defvar
+
+@defvar rec-recfix
 Name of the @command{recfix} utility from the GNU recutils.
-@end table
+@end defvar
 
 @node Records appearance
 @section Records appearance
@@ -456,12 +718,23 @@ Name of the @command{recfix} utility from the GNU 
recutils.
 The appearance of the records in navigation mode can be customised by
 tweaking the value of the following variables.
 
-@table @code
-@item rec-max-lines-in-fields
+@defvar rec-max-lines-in-fields
 Values in fiels having more than the specified number of lines will be
 hidden by default in navigation mode.  When hidden, an ellipsis is
 shown instead of the value of the field.  Default is @code{15}.
-@end table
+@end defvar
+
+@node Command Index
+@unnumbered Command and Function Index
+@printindex fn
+
+@node Key Index
+@unnumbered Key (Character) Index
+@printindex ky
+
+@node Variable and Concept Index
+@unnumbered Variable and Concept Index
+@printindex vr
 
 @node GNU Free Documentation License
 @appendix GNU Free Documentation License



reply via email to

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