bug-recutils
[Top][All Lists]
Advanced

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

[PATCH v2] Selection improvements -- rec-selection-mode and cross refere


From: Antoine Kalmbach
Subject: [PATCH v2] Selection improvements -- rec-selection-mode and cross referencing
Date: Mon, 30 Nov 2020 12:57:41 +0200

Implements several new features, these being rec-selection-mode
and cross referencing selections.

For changes in this commit please see the git diff, as the ChangeLog entry list
was getting too large.
---
 .elpaignore          |    1 +
 aux/gendocs.sh       |  510 +++++++++++++++++++
 aux/gendocs_template |  101 ++++
 rec-mode.el          |  844 ++++++++++++++++++++++++++++---
 rec-mode.info        | 1147 ++++++++++++++++++++++++++----------------
 rec-mode.texi        |  260 +++++++++-
 6 files changed, 2356 insertions(+), 507 deletions(-)
 create mode 100644 .elpaignore
 create mode 100755 aux/gendocs.sh
 create mode 100644 aux/gendocs_template

diff --git a/.elpaignore b/.elpaignore
new file mode 100644
index 0000000..0af7029
--- /dev/null
+++ b/.elpaignore
@@ -0,0 +1 @@
+aux/
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/rec-mode.el b/rec-mode.el
index 1598874..e79b572 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.
 
@@ -62,7 +62,9 @@
 (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.
@@ -77,8 +79,19 @@ The default is t."
   "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.")
@@ -98,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"
@@ -192,14 +219,22 @@ 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 C-/ h") 'rec-cmd-show-summary-for-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)
@@ -225,12 +260,20 @@ 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 "/ h") 'rec-cmd-show-summary-for-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 C-t") 'rec-find-type)
     (define-key map [remap undo] 'rec-cmd-undo)
@@ -494,7 +537,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))))
-      (setf (rec-field-value field) value))))
+      (setf (slot-value field 'value) value)
+      field)))
 
 ;;;; Get entities under pointer
 ;;
@@ -690,7 +734,7 @@ DONT-GO-FUNDAMENTAL is non-nil, don't switch to 
fundamental."
                                  :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))
+(cl-defmethod rec-record-to-descriptor ((_record rec-record-descriptor))
   rec-record-descriptor)
 
 (defun rec--parse-sexp-records (records)
@@ -712,7 +756,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.
@@ -729,9 +772,11 @@ this function returns nil."
                        (goto-char (point-max))
                        (insert ")")
                        (unwind-protect
-                           (setq descriptors
+                           (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 (read 
(point-min-marker)))))
+                                             (rec--parse-sexp-records 
result))))
                          (kill-buffer buffer))))
             (kill-buffer buffer)
             nil))))
@@ -983,6 +1028,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))
@@ -992,7 +1038,7 @@ descriptor record.  If nil, the descriptor is skipped."
   (setq buffer-read-only t)
   (rec-narrow-to-record)
   (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
@@ -1265,13 +1311,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."
@@ -1340,14 +1398,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.
@@ -1356,7 +1431,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.
@@ -1370,6 +1446,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)
@@ -1394,7 +1508,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.
@@ -1421,9 +1536,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
@@ -1455,8 +1574,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)
@@ -1468,15 +1589,28 @@ 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))
-
-;;;; SELECTION of 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
 ;;
 ;; The following functions implement selection of records, which
 ;; maintains a subset of the records in the current buffer.
@@ -1502,29 +1636,396 @@ 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 exp)
+  "Generate a new buffer for SELECTION and switch to it."
+  (when 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))))
+
+(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)
+            (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
+    (when (buffer-live-p rec-summary-buffer)
+      (rec-select-summary
+        ;; If the summary was active for a selection,
+        (when rec-summary-selection
+          (rec-summary-quit))))
+    (rec-selection-mode -1)
+    (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))))
+
+(defun rec-cmd-show-summary-for-selection ()
+  "Show a summary for the records only in the currently active selection."
+  (interactive)
+  (when rec-selection-mode
+    (rec-cmd-show-summary t)))
+
+;;;;; 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
@@ -1822,7 +2323,8 @@ Optional argument N specifies number of records to skip."
          (message "%s" (concat "No more records of type "
                                (rec-record-type)))))))
   (unless (derived-mode-p 'rec-edit-mode)
-    (rec-show-record)))
+    (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.
@@ -1848,7 +2350,8 @@ Optional argument N specifies number of records to skip."
          (message "%s" (concat "No more records of type "
                                (rec-record-type)))))))
   (unless (derived-mode-p 'rec-edit-mode)
-    (rec-show-record)))
+    (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."
@@ -1868,6 +2371,11 @@ Optional argument N specifies number of records to skip."
         (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)
@@ -1875,7 +2383,8 @@ Optional argument N specifies number of records to skip."
   (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))
 
@@ -1890,7 +2399,8 @@ Optional argument N specifies number of records to skip."
   (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."
@@ -1900,7 +2410,8 @@ Optional argument N specifies number of records to skip."
   (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 ()
@@ -1923,7 +2434,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))
+    (rec-update-mode-line)
     (message "End of edition")))
 
 (defun rec-cmd-show-descriptor ()
@@ -2118,51 +2629,164 @@ 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* ((base-buffer-name (concat (buffer-name (current-buffer)) " Summary"))
+         (summary-buffer-name (if use-selection
+                                  (concat base-buffer-name
+                                          " for "
+                                          (rec-selection-stringify
+                                           rec-selection-current-selection))
+                                base-buffer-name))
+         (current-record (save-excursion
+                           (rec-beginning-of-record)
+                           (rec-current-record))))
+    (if (buffer-live-p (or rec-summary-buffer (get-buffer 
summary-buffer-name)))
+        (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 :type (rec-record-type)
-                                     :fex (string-join summary-fields ",")))
-                   (summary-list (mapcar (lambda (rec)
-                                           (let* ((entry-marker (make-marker)))
-                                             (set-marker entry-marker
-                                                         (slot-value rec 
'position))
-                                             (list entry-marker
-                                                   (vconcat (rec-record-values 
rec summary-fields)))))
-                                         (rec--parse-sexp-records query))))
+            (let* ((fex (string-join summary-fields ","))
+                   (query (if (and use-selection 
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-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 ()
@@ -2181,6 +2805,7 @@ function returns nil."
               (rec-field-value (car (slot-value record 'fields)))))
         (rec-field-value (car (slot-value record 'fields)))))))
 
+
 ;;;; Definition of modes
 
 (defvar font-lock-defaults)
@@ -2193,15 +2818,41 @@ function returns nil."
 (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 of same type"     rec-cmd-goto-next-rec t]
-    ["Previous record of same type" rec-cmd-goto-previous-rec t]
-    ["Next field"                   rec-cmd-goto-next-field t]
-    ["Go to record descriptor"       rec-cmd-show-descriptor t]
+    ["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."]
+     "---"
+     ["Show summary for selection" rec-cmd-show-summary-for-selection 
+      :help "Show a summary of the records matching the currently active 
selection."
+      :enable rec-selection-mode]
+     ["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))]
@@ -2233,6 +2884,9 @@ function returns nil."
   (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))
@@ -2252,7 +2906,8 @@ mode and show the output of recfix in a separated buffer."
           (rec-show-type (car (rec-buffer-types))))
       ;; Edit mode
       (rec-edit-mode)
-      (rec-set-mode-line "Edit buffer"))))
+      (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.
@@ -2274,6 +2929,29 @@ See Info node `(rec-mode)Editing Mode'.
 (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 993556c..e9bef84 100644
--- a/rec-mode.info
+++ b/rec-mode.info
@@ -1,8 +1,8 @@
 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 © 2012-2020 Free Software Foundation, Inc.
 
@@ -23,10 +23,10 @@ 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 © 2012-2020 Free Software Foundation, Inc.
 
@@ -42,6 +42,9 @@ recutils suite (version 1.8.90, 13 November 2020).
 * 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
 * Command Index::               Command and Function Index
 * Key Index::                   Key (Character) Index
@@ -66,6 +69,16 @@ Navigation mode
 * Statistics::                  Counting records
 * Data integrity::              Verifying the integrity of the recfile
 
+Selecting records
+
+* 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.
@@ -124,8 +137,8 @@ file.
 
 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.
+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
@@ -148,8 +161,8 @@ 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
@@ -177,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
@@ -226,16 +240,16 @@ The following commands jump to other records in the 
buffer.
      ‘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
+     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’
 ‘M-x rec-cmd-jump-back’
      Display the record previously displayed in the buffer.
 ‘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.
+     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
@@ -249,9 +263,9 @@ get information about some of the properties of the fields.
 ‘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.
+     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’
@@ -271,13 +285,13 @@ cursor.
 
 ‘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.
+     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
@@ -289,32 +303,32 @@ The following commands change the value of the field 
under the cursor.
 
 ‘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.
+     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.
+          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.
+     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
@@ -322,21 +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.
+The following commands jump to the first record in the buffer
+satisfying some criteria.
 
 ‘s q’
-‘M-x 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.
+‘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-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.
+‘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
@@ -354,18 +368,18 @@ based on some provided criteria.
 ‘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.
+     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
@@ -380,33 +394,33 @@ the following commands.
 ‘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.
@@ -436,12 +450,236 @@ navigation mode by using the following command.
    (1) Exceptuating font-lock
 
 
-File: rec-mode.info,  Node: Configuration,  Next: Command Index,  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.
 
-4 Configuration
+   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.
+
+
+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
 ***************
 
-rec-mode can be configured using the customization facilities of Emacs.
+rec-mode can be configured using the customization facilities of
+Emacs.
 
 * Menu:
 
@@ -451,7 +689,7 @@ rec-mode can be configured using the customization 
facilities of Emacs.
 
 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
@@ -471,16 +709,17 @@ recutils are installed system-wide in the system.
 
 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.
 
  -- 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’.
+     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
@@ -491,26 +730,41 @@ 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-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-select-fast:                   Searches.             (line 11)
-* rec-cmd-select-sex:                    Searches.             (line 17)
-* rec-cmd-show-descriptor:               Record navigation.    (line 18)
-* rec-cmd-show-info:                     Statistics.           (line 11)
-* 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-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-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
@@ -521,26 +775,40 @@ Key (Character) Index
 [index]
 * Menu:
 
-* #:                                     Statistics.           (line 14)
-* %:                                     Statistics.           (line 25)
-* 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)
-* I:                                     Statistics.           (line 11)
-* m:                                     Field edition.        (line 34)
-* n:                                     Record navigation.    (line 10)
-* 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)
+* #:                                     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
@@ -551,18 +819,41 @@ Variable and Concept Index
 [index]
 * Menu:
 
-* activation:                            Activation.           (line  6)
-* author:                                Feedback.             (line  6)
-* bug reports:                           Feedback.             (line  6)
-* feedback:                              Feedback.             (line  6)
-* jumping, to records:                   Record navigation.    (line  6)
-* maintainer:                            Feedback.             (line  6)
-* motion, between records:               Record navigation.    (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)
+* 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: Variable 
and Concept Index,  Up: Top
@@ -570,7 +861,7 @@ File: rec-mode.info,  Node: GNU Free Documentation License, 
 Prev: Variable and
 Appendix A GNU Free Documentation License
 *****************************************
 
-                     Version 1.3, 3 November 2008
+                    Version 1.3, 3 November 2008
 
      Copyright © 2000, 2001, 2002, 2007, 2008, 2020 Free Software
      Foundation, Inc.
@@ -581,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
      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.
+     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.
+     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.
+     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.
+     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.
@@ -714,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
@@ -732,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
@@ -783,8 +1080,8 @@ 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
@@ -794,30 +1091,32 @@ Appendix A GNU Free Documentation License
 
        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.
+          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.
@@ -830,52 +1129,52 @@ Appendix A GNU Free Documentation License
 
      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
@@ -887,56 +1186,57 @@ Appendix A GNU Free Documentation License
 
      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.
+     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.
+     Preserve its Title (section 1) will typically require changing
+     the actual title.
 
   9. TERMINATION
 
@@ -947,30 +1247,30 @@ 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
@@ -978,32 +1278,33 @@ Appendix A GNU Free Documentation License
      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.
+     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
      License, and if all works that were first published under this
@@ -1020,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
@@ -1043,38 +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: Top775
-Node: Introduction2945
-Ref: Introduction-Footnote-13696
-Node: Installation3743
-Node: Activation4892
-Ref: Activation-Footnote-15481
-Node: Feedback5613
-Ref: Feedback-Footnote-16031
-Node: Navigation mode6252
-Node: Record navigation7998
-Node: Field navigation8992
-Node: Field folding9681
-Node: Field edition10433
-Node: Searches12269
-Node: Statistics13073
-Node: Data integrity14164
-Node: Edition modes14690
-Ref: Edition modes-Footnote-116647
-Node: Configuration16678
-Node: Finding the recutils17036
-Node: Records appearance17703
-Node: Command Index18222
-Node: Key Index19854
-Node: Variable and Concept Index21489
-Node: GNU Free Documentation License22567
+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 c8989de..14f9f58 100644
--- a/rec-mode.texi
+++ b/rec-mode.texi
@@ -3,9 +3,10 @@
 @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
 
@@ -62,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
@@ -71,6 +72,9 @@ 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
 * Command Index::               Command and Function Index
 * Key Index::                   Key (Character) Index
@@ -96,6 +100,16 @@ Navigation mode
 * Statistics::                  Counting records
 * Data integrity::              Verifying the integrity of the recfile
 
+Selecting records
+
+* 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.
@@ -195,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
@@ -274,6 +290,7 @@ 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
@@ -293,6 +310,8 @@ 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.
 
@@ -333,12 +352,12 @@ The following commands jump to the first record in the 
buffer
 satisfying some criteria.
 
 @table @kbd
-@reccmd{s q, rec-cmd-select-fast}
+@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
@@ -347,6 +366,7 @@ 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.
@@ -372,6 +392,7 @@ 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.
@@ -386,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
@@ -429,6 +452,235 @@ 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.
+
+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
+
+@cindex summary, selection
+@reccmd{/ h, rec-cmd-show-summary-for-selection}
+Creates a summary buffer (@pxref{Summary mode}) with the contents from
+the selection instead of the current buffer.
+
+@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
 
-- 
2.24.3 (Apple Git-128)




reply via email to

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