Commits

Anonymous committed b84c10e

RefTeX version 4.09

  • Participants
  • Parent commits 51545fd

Comments (0)

Files changed (19)

+This is the CHANGES file of the RefTeX distribution, version 4.9 
+
+Here are the more important changes made to RefTeX since initial release.
+Minor bug fixes are not mentioned.
+
+Version 4.09
+   - RefTeX maintaines an "Index Phrases" file in which phrases can be 
+     collected.  When the document is ready, RefTeX can search all
+     these phrases and assist indexing all matches.
+   - The variables `reftex-index-macros' and
+     `reftex-index-default-macro' have changed their syntax slightly.
+     The "repeat" parameter has move from the latter to the former.
+     Also calls to `reftex-add-index-macros' from AUCTeX style files
+     need to be adapted.
+   - The variable `reftex-section-levels' no longer contains the
+     default stuff which has been moved to a constant.
+   - Environments like theorems can be placed into the TOC by putting
+     entries for "begin{theorem}" in `reftex-setion-levels'.
+Version 4.07
+   - New option `reftex-toc-max-level' to limit the depth of the toc.
+     The `t' key in the *toc* and *RefTeX Select* buffers also changes
+     this variable.
+Version 4.06
+   - `reftex-section-levels' can now also contain functions to compute 
+     level.
+   - Multiple `thebibliography' environments recognized.
+Version 4.04
+   - New option `reftex-index-default-tag' implements a default for queries.
+Version 4.02
+   - macros ending in `refrange' are considered to contain references.
+   - Index entries made with `reftex-index-selection-or-word' in TeX
+     math mode automatically get enclosing `$' to preserve math mode.
+     See new option `reftex-index-math-format'.  Requires AUCTeX.
+Version 4.01
+   - New command `reftex-index-globally' to index a word in many
+     places in the document.  Also available from the index buffer with
+     the `&' key.
+   - The first item in a @code{reftex-label-alist} entry may now also
+     be a parser function to do non-standard parsing.
+   - `reftex-auto-view-crossref' no longer interferes with
+     `pop-up-frames'.
+Version 4.00
+   Many changes - too much to document them in detail here.  In summary:
+   - RefTeX has been split into 11 smaller lisp files.
+   - Index support, along with many new user options.
+   - The selection of keys for `\ref' and `\cite' now allows to
+     select multiple items by marking entries with the `m' key.
+   - fancyref.sty support.
+Version 3.38
+   - `reftex-view-crossref' no longer moves to find a macro.
+   - Bug fix for XEmacs selection process.
+Version 3.36
+   - New value `window' for option `reftex-auto-view-crossref'.
+Version 3.35
+   - ISO 8859 Latin-1 chars are converted to ASCII to derive better labels.
+     This takes back the related changes in 3.34 for safety reasons.
+   - Fixed bug with non-existing string-width function in XEmacs.
+Version 3.34
+   - Additional flag in `reftex-derive-label-parameters' to make only
+     lowercase labels (default t).
+   - All .rel files have a final newline to avoid queries.
+   - Single byte representations of accented European letters (ISO-8859-1)
+     are legal in labels.  However, general Mule characters are not.
+Version 3.33
+   - Multiple Selection Buffers are now hidden (names start with a space).
+   - Fixed bug with file search when TEXINPUTS was empty.
+Version 3.30
+   - In `reftex-citation', the regexp can be completed on known cite keys.
+   - New keys `a' and `A' in bib selection process to cite all entries.
+   - New command `reftex-renumber-simple-labels' to renumber `eq:13' etc.
+Version 3.28
+   - Auto view crossref for XEmacs uses post-command-hook to restart the
+     timer, since itimer restart is not reliable.
+   - Option `reftex-bibfile-ignore-list' renamed to `-regexps'.
+   - Expansion of recursive tex and bib path rewritten.
+Version 3.27
+   - Macros can define "neutral" labels, just like \label{} itself.
+   - New option `reftex-allow-detached-macro-args', default nil!
+Version 3.26
+   - [X]Emacs 19 support dropped.  Use 3.22 for them.
+   - New hooks `reftex-translate-to-ascii-function',
+     `reftex-string-to-label-function'.
+Version 3.25
+   - Echoing of citation info caches the info for displayed entries.
+     New option `reftex-cache-cite-echo'.
+   - `M-x reftex-reset-mode' now also removes the file with parsing info.
+   - Default of `reftex-revisit-to-follow' changed to nil.
+Version 3.24
+   - New option `reftex-revisit-to-echo'.
+   - Interface with X-Symbol (>=2.6) is now complete and stable.
+   - Adapted to new outline, which uses overlays.
+Version 3.23
+   - Parse files MASTER.rel made compatible between Emacs and XEmacs.
+   - `kill-emacs-hook' and `kill-buffer-hook' now write the parse file.
+   - The cursor inside a \ref or \cite macro now triggers automatic
+     display of crossref information in the echo area.  See variable
+     `reftex-auto-view-crossref'.
+   - AUCTeX interface updates:
+     - AUCTeX 9.9c and later notifies RefTeX about new sections.
+     - RefTeX notifies AUCTeX about new labels.
+     - TeX-arg-ref no longer used (introduction was unnecessary).
+     - `reftex-arg-label' and `reftex-arg-cite' fixed up.
+     - Settings added to RefTeX via style files remain local.
+Version 3.22
+   - `reftex-mouse-view-crossref' is now bound by default at `S-mouse-2'
+   - THIS VERSION IS RECOMMENDED FOR X/EMACS 19.
+Version 3.21
+   - New options for all faces used by RefTeX.  They're in the
+     customization group `reftex-fontification-configurations'.
+Version 3.18
+   - The selection now uses a recursive edit, much like minibuffer input.
+     This removes all restrictions during selection.  E.g. you can now
+     switch buffers at will, use the mouse etc.
+   - New option `reftex-highlight-selection'.
+   - Mouse-2 can be used to select in selection and *toc* buffers.
+   - Fixed some problems regarding the interaction with VIPER mode.
+   - Follow-mode is now only used after point motion.
+   - RefTeX now finally does not fontify temporary files anymore!
+Version 3.17
+   - Additional bindings in selection and *toc* buffers.  `g' redefined. 
+   - New command `reftex-save-all-document-buffers'.
+   - Magic word matching made more intelligent.
+   - Selection process can switch to completion (with TAB).
+   - \appendix is now recognized and influences section numbering.
+   - File commentary shortened considerably (use Info documentation).
+   - New option `reftex-no-include-regexps' to skip some include files.
+   - New option `reftex-revisit-to-follow'.
+Version 3.16
+   - New hooks `reftex-format-label-function', `reftex-format-ref-function',
+     `reftex-format-cite-function'.
+   - TeXInfo documentation completed.
+   - New variable `reftex-default-bibliography'.
+Version 3.14
+   - Selection buffers can be kept between selections: this is faster.
+     See new variable `reftex-use-multiple-selection-buffers'.
+   - Prefix interpretation of reftex-view-crossref changed.
+   - Support for the `varioref' package (`v' key in selection buffer).
+Version 3.12
+   - There are 3 new keymaps for customization: `reftex-toc-map',
+     `reftex-select-label-map', `reftex-select-bib-map'.
+   - Refontification uses more standard font-lock stuff.
+   - When no BibTeX database files are specified, citations can also
+     use \bibitem entries from a `thebibliography' environment.
+Version 3.03
+   - Support for the LaTeX package `xr', for inter-document references.
+   - A few (minor) Mule-related changes.
+   - Fixed bug which could cause HUGE .rel files.
+   - Search for input and .bib files with recursive path definitions.
+Version 3.00
+   - RefTeX should work better for very large projects:
+      - The new parser works without creating a master buffer.
+      - Rescanning can be limited to a part of a multifile document.
+      - Information from the parser can be stored in a file.
+   - RefTeX can deal with macros having a naked label as an argument.
+   - Macros may have white space and newlines between arguments.
+   - Multiple identical section headings no longer confuse `reftex-toc'.
+   - RefTeX should work correctly in combination with buffer-altering
+     packages like outline, folding, x-symbol, iso-cvt, isotex, etc.
+   - All labeled environments discussed in `The LaTeX Companion' by
+     Goossens, Mittelbach & Samarin, Addison-Wesley 1994) are part of
+     RefTeX's defaults.
+Version 2.17
+   - Label prefix expands % escapes with current file name and other stuff.
+   - Citation format now with % escapes.  This is not backward compatible!
+   - TEXINPUTS variable recognized when looking for input files.
+   - Context can be the nth argument of a macro.
+   - Searching in the select buffer is now possible (C-s and C-r).
+   - Display and derive-label can use two different context methods.
+   - AMSmath xalignat and xxalignat added.
+Version 2.14
+   - Variable `reftex-plug-into-AUCTeX' simplifies cooperation with AUCTeX.
+Version 2.11
+   - Submitted for inclusion to Emacs and XEmacs.
+Version 2.07
+   - New functions `reftex-search-document', `reftex-query-replace-document'
+Version 2.05
+   - Support for `custom.el'.
+   - New function `reftex-grep-document' (thanks to Stephen Eglen).
+Version 2.03
+   - Figure*, table*, Sidewaysfigure/table added to default environments.
+   - `reftex-bibfile-ignore-list' introduced (thanks to Rory Molinari).
+   - New functions `reftex-arg-label', `reftex-arg-ref', `reftex-arg-cite'.
+   - Emacs/XEmacs compatibility reworked.  XEmacs 19.15 now is required.
+   - `reftex-add-to-label-alist' (to be called from AUCTeX style files).
+   - Finding context with a hook function.
+   - Sorting BibTeX entries (new variable: `reftex-sort-bibtex-matches').
+Version 2.00
+   - Labels can be derived from context (default for sections).
+   - Configuration of label insertion and label referencing revised.
+   - Crossref fields in BibTeX database entries.
+   - `reftex-toc' introduced (thanks to Stephen Eglen).
+Version 1.09
+   - Support for `tex-main-file', an analogue for `TeX-master'.
+   - MS-DOS support.
+Version 1.07
+   - RefTeX gets its own menu.
+Version 1.05
+   - XEmacs port.
+Version 1.04
+   - Macros as wrappers, AMSTeX support, delayed context parsing for
+     new labels.
+Version 1.00
+   - released on 7 Jan 1997.
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                          675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public 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.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	Appendix: How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
+
+    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 2 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, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+1999-12-08  Jan Vroonhof <jan@xemacs.org>
+	
+	* reftex 4.09.
+
 1999-04-06  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
 
 	* reftex.texi: Add commata after xref to satisfy texinfo 3.12f+'s
+This is the INSTALL file of the RefTeX distribution, version 4.9 
+
+
+1a. INSTALLATION WITH MAKE
+==========================
+
+In order to install RefTeX, unpack the distribution and edit the
+header of the Makefile.  Basically, you need to change the path
+specifications for Emacs lisp files and the info files.  Also, enter
+the name of your Emacs executable (usually either `emacs' or
+`xemacs').
+
+Then, type 
+
+   make
+   make install
+
+to compile and install the code and documentation.
+
+1b. INSTALLATION BY HAND
+========================
+
+If you don't have `make' available, you can do the following to
+install.
+a) Copy the reftex*.el lisp files to a directory on your load path.
+   Make sure that no old copy of reftex.el or reftex.elc shadows these 
+   files.
+b) Byte compile the files.  The sequence of compiling should be:
+   reftex-var.el, reftex.el, and then all the others.
+c) Copy the info files reftex, reftex-1, reftex-2, reftex-3 to the
+   info directory.
+
+
+2. Copy the following lines into your .emacs file:
+==================================================
+
+  (autoload 'reftex-mode     "reftex" "RefTeX Minor Mode" t)
+  (autoload 'turn-on-reftex  "reftex" "RefTeX Minor Mode" nil)
+  (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
+  (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
+  (add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
+  (add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode
+
+That's all!
+
+To get started, read the documentation, in particular the summary
+"RefTeX in a Nutshell".  You can find this summary both in the file
+NUTSHELL and as part of the TeX-Info documentation.
+
+In order to produce a printed version of the documentation, use
+`make dvi' or `make ps' to produce a reftex.dvi or reftex.ps file.
+
+In order to produce the documentation in HTML format, use `make html'.
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.14
-AUTHOR_VERSION = 3.43
-MAINTAINER = Carsten Dominik <dominik@strw.LeidenUniv.nl>
+VERSION = 1.15
+AUTHOR_VERSION = 4.08
+MAINTAINER = Carsten Dominik <dominik@astro.uva.nl>
 PACKAGE = reftex
 PKG_TYPE = regular
 REQUIRES = fsf-compat xemacs-base
 CATEGORY = wp
 
-ELCS = reftex.elc
+LISPFILES  = reftex-vars.el reftex.el reftex-auc.el reftex-cite.el\
+             reftex-global.el reftex-parse.el reftex-ref.el\
+             reftex-sel.el reftex-toc.el reftex-vcr.el reftex-index.el
+ELCS  = $(LISPFILES:.el=.elc)
 
 INFO_FILES = reftex.info*
 TEXI_FILES = reftex.texi
 MANUAL = reftex
 
+DATA_FILES = CHANGES NUTSHELL
+DATA_DEST = $(PACKAGE)
+
 include ../../XEmacs.rules
 
 all:: $(ELCS) auto-autoloads.elc $(PACKAGE).info
+Introduction
+************
+
+   RefTeX is a specialized package for support of labels, references,
+citations, and the index in LaTeX.  RefTeX wraps itself round 4 LaTeX
+macros: `\label', `\ref', `\cite', and `\index'.  Using these macros
+usually requires looking up different parts of the document and
+searching through BibTeX database files.  RefTeX automates these
+time-consuming tasks almost entirely.  It also provides functions to
+display the structure of a document and to move around in this
+structure quickly.
+
+   *Note Imprint::, for information about who to contact for help, bug
+reports or suggestions.
+
+Environment
+===========
+
+   RefTeX needs to access all files which are part of a multifile
+document, and the BibTeX database files requested by the
+`\bibliography' command.  To find these files, RefTeX will require a
+search path, i.e. a list of directories to check.  Normally this list
+is stored in the environment variables `TEXINPUTS' and `BIBINPUTS'
+which are also used by RefTeX.  However, on some systems these
+variables do not contain the full search path.  If RefTeX does not work
+for you because it cannot find some files, read *Note Finding Files::.
+
+Entering RefTeX Mode
+====================
+
+   To turn RefTeX Mode on and off in a particular buffer, use `M-x
+reftex-mode'.  To turn on RefTeX Mode for all LaTeX files, add the
+following lines to your `.emacs' file:
+
+     (add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
+     (add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode
+
+RefTeX in a Nutshell
+====================
+
+  1. Table of Contents
+     Typing `C-c =' (`reftex-toc') will show a table of contents of the
+     document.  This buffer can display sections, labels and index
+     entries defined in the document.  From the buffer, you can jump
+     quickly to every part of your document.  Press `?' to get help.
+
+  2. Labels and References
+     RefTeX helps to create unique labels and to find the correct key
+     for references quickly.  It distinguishes labels for different
+     environments, knows about all standard environments (and many
+     others), and can be configured to recognize any additional labeled
+     environments you have defined yourself (variable
+     `reftex-label-alist').
+
+        * Creating Labels
+          Type `C-c (' (`reftex-label') to insert a label at point.
+          RefTeX will either
+             - derive a label from context (default for section labels)
+
+             - prompt for a label string (default for figures and
+               tables) or
+
+             - insert a simple label made of a prefix and a number (all
+               other environments)
+
+          Which labels are created how is configurable with the variable
+          `reftex-insert-label-flags'.
+
+        * Referencing Labels
+          To make a reference, type `C-c )' (`reftex-reference').  This
+          shows an outline of the document with all labels of a certain
+          type (figure, equation,...) and some label context.
+          Selecting a label inserts a `\ref{LABEL}' macro into the
+          original buffer.
+
+  3. Citations
+     Typing `C-c [' (`reftex-citation') will let you specify a regular
+     expression to search in current BibTeX database files (as
+     specified in the `\bibliography' command) and pull out a list of
+     matches for you to choose from.  The list is _formatted_ and
+     sorted.  The selected article is referenced as `\cite{KEY}' (see
+     the variable `reftex-cite-format' if you want to insert different
+     macros).
+
+  4. Index Support
+     RefTeX helps to enter index entries.  It also compiles all entries
+     into an alphabetically sorted `*Index*' buffer which you can use
+     to check and edit the entries.  RefTeX knows about the standard
+     index macros and can be configured to recognize any additional
+     macros you have defined (`reftex-index-macros').  Multiple indices
+     are supported.
+
+        * Creating Index Entries
+          To index the current selection or the word at point, type
+          `C-c /' (`reftex-index-selection-or-word').  The default macro
+          `reftex-index-default-macro' will be used.  For a more
+          complex entry type `C-c <' (`reftex-index'), select any of
+          the index macros and enter the arguments with completion.
+
+        * The Index Phrases File (Delayed Indexing)
+          Type `C-c \' (`reftex-index-phrase-selection-or-word') to add
+          the current word or selection to a special _index phrase
+          file_.  RefTeX can later search the document for occurrences
+          of these phrases and let you interactively index the matches.
+
+        * Displaying and Editing the Index
+          To display the compiled index in a special buffer, type `C-c
+          >' (`reftex-display-index').  From that buffer you can check
+          and edit all entries.
+
+  5. Viewing Cross-References
+     When point is on the KEY argument of a cross-referencing macro
+     (`\label', `\ref', `\cite', `\bibitem', `\index', and variations)
+     or inside a BibTeX database entry, you can press `C-c &'
+     (`reftex-view-crossref') to display corresponding locations in the
+     document and associated BibTeX database files.
+     When the enclosing macro is `\cite' or `\ref' and no other message
+     occupies the echo area, information about the citation or label
+     will automatically be displayed in the echo area.
+
+  6. Multifile Documents
+     Multifile Documents are fully supported.  The included files must
+     have a file variable `TeX-master' or `tex-main-file' pointing to
+     the master file.  RefTeX provides cross-referencing information
+     from all parts of the document, and across document borders
+     (`xr.sty').
+
+  7. Document Parsing
+     RefTeX needs to parse the document in order to find labels and
+     other information.  It does it automatically once and updates its
+     list internally when `reftex-label' and `reftex-index' are used.
+     To enforce reparsing, call any of the commands described above
+     with a raw `C-u' prefix, or press the `r' key in the label
+     selection buffer, the table of contents buffer, or the index
+     buffer.
+
+  8. AUCTeX
+     If your major LaTeX mode is AUCTeX, RefTeX can cooperate with it
+     (see variable `reftex-plug-into-AUCTeX').  AUCTeX contains style
+     files which trigger appropriate settings in RefTeX, so that for
+     many of the popular LaTeX packages no additional customizations
+     will be necessary.
+
+  9. Useful Settings
+     To make RefTeX faster for large documents, try these:
+          (setq reftex-enable-partial-scans t)
+          (setq reftex-save-parse-info t)
+          (setq reftex-use-multiple-selection-buffers t)
+
+     To integrate with AUCTeX, use
+          (setq reftex-plug-into-AUCTeX t)
+
+     To make your own LaTeX macro definitions known to RefTeX,
+     customize the variables
+          `reftex-label-alist'          (for label macros/environments)
+          `reftex-section-levels'       (for sectioning commands)
+          `reftex-cite-format'          (for `\cite'-like macros)
+          `reftex-index-macros'         (for `\index'-like macros)
+          `reftex-index-default-macro'  (to set the default macro)
+     If you have a large number of macros defined, you may want to write
+     an AUCTeX style file to support them with both AUCTeX and RefTeX.
+
+ 10. Where Next?
+     Go ahead and use RefTeX.  Use its menus until you have picked up
+     the key bindings.  For an overview of what you can do in each of
+     the different special buffers, press `?'.  Read the manual if you
+     get stuck, of if you are curious what else might be available.
+     The first part of the manual explains in a tutorial way how to use
+     and customize RefTeX.  The second part is a command and variable
+     reference.
+
+This is the README file of the RefTeX distribution, version 4.9 
+
+Your kit should contain the following files:
+
+README             This file
+INSTALL            A brief installation guide
+NUTSHELL           A 3-page summary of how to use RefTeX
+CHANGES            The package history
+COPYING            The GNU General Public License
+Makefile           The Makefile to compile and install RefTeX
+reftex.texinfo     The TeX-Info file containing the documentation
+lpath.el           A file needed to compile the lisp files
+
+reftex.el          The basic file with the parser and the mode definitions
+reftex-auc.el      The AUCTeX interface.
+reftex-cite.el     Code for making citations.
+reftex-global.el   Actions on entire multifile documents.
+reftex-index.el    Code to support the Index.
+reftex-parse.el    RefTeX's parser for LaTeX files.
+reftex-ref.el      Code to create and reference labels.
+reftex-sel.el      The selection modes.
+reftex-toc.el      The Table of Contents mode.
+reftex-vars.el     All user variables (defcustom forms).
+reftex-vcr.el      Code to view cross references and citations.
+
+reftex             \
+reftex-1            \
+reftex-2             >  The info files (online documentation)
+reftex-3            /
+reftex-4           /
+
+RefTeX is part of Emacs (version 20.2 and later) and is distributed as
+one of the XEmacs packages.  If you use an earlier version of Emacs,
+this kit can be used to install RefTeX.
+
+The most recent version of RefTeX is available at
+
+    http://www.strw.leidenuniv.nl/~dominik/Tools
+
+
+;;; This file is only used for installing RefTeX
+;;; It is not a part of RefTeX itself.
+
+;; Make sure we get the right files.
+(setq load-path (cons "." load-path)
+      byte-compile-warnings nil)
+
+;;; reftex-auc.el - RefTeX's interface to AUC TeX
+;;; Version: 4.9
+;;;
+;;; See main file reftex.el for licensing information
+
+(eval-when-compile (require 'cl))
+(provide 'reftex-auc)
+(require 'reftex)
+;;;
+
+(defun reftex-plug-flag (which)
+  ;; Tell if a certain flag is set in reftex-plug-into-AUCTeX
+  (or (eq t reftex-plug-into-AUCTeX)
+      (and (listp reftex-plug-into-AUCTeX)
+	   (nth which reftex-plug-into-AUCTeX))))
+
+(defun reftex-arg-label (optional &optional prompt definition)
+  "Use `reftex-label', `reftex-reference' or AUCTeX's code to insert label arg.
+What is being used depends upon `reftex-plug-into-AUCTeX'."
+  (let (label)
+    (cond
+     ((and definition (reftex-plug-flag 1))
+      ;; Create a new label, with a temporary brace for `reftex-what-macro'
+      (unwind-protect
+	  (progn (insert "{") (setq label (or (reftex-label nil t) "")))
+	(delete-backward-char 1)))
+     ((and (not definition) (reftex-plug-flag 2))
+      ;; Reference a label with RefTeX
+      (setq label (reftex-reference nil t)))
+     (t
+      ;; AUCTeX's default mechanism
+      (setq label (completing-read (TeX-argument-prompt optional prompt "Key")
+				   (LaTeX-label-list)))))
+    (if (and definition (not (string-equal "" label)))
+	(LaTeX-add-labels label))
+    (TeX-argument-insert label optional)))
+
+(defun reftex-arg-cite (optional &optional prompt definition)
+  "Use `reftex-citation' or AUCTeX's code to insert a cite-key macro argument.
+What is being used depends upon `reftex-plug-into-AUCTeX'."
+  (let (items)
+    (cond
+     ((and (not definition) (reftex-plug-flag 3))
+      (setq items (list (or (reftex-citation t) ""))))
+     (t
+      (setq prompt (concat (if optional "(Optional) " "")
+			   (if prompt prompt "Add key")
+			   ": (default none) "))
+      (setq items (multi-prompt "," t prompt (LaTeX-bibitem-list)))))
+    (apply 'LaTeX-add-bibitems items)
+    (TeX-argument-insert (mapconcat 'identity items ",") optional)))
+
+
+(defun reftex-arg-index-tag (optional &optional prompt &rest args)
+  "Prompt for an index tag with completion. 
+This is the name of an index, not the entry."
+  (let (tag taglist)
+    (setq prompt (concat (if optional "(Optional) " "")
+			 (if prompt prompt "Index tag")
+			 ": (default none) "))
+    (if (and reftex-support-index (reftex-plug-flag 4))
+	;; Use RefTeX completion
+	(progn
+	  (reftex-access-scan-info nil)
+	  (setq taglist 
+		(cdr (assoc 'index-tags 
+			    (symbol-value reftex-docstruct-symbol)))
+		tag (completing-read prompt (mapcar 'list taglist))))
+      ;; Just ask like AUCTeX does.
+      (setq tag (read-string prompt)))
+    (TeX-argument-insert tag optional)))
+
+(defun reftex-arg-index (optional &optional prompt &rest args)
+  "Prompt for an index entry completing with known entries.
+Completion is specific for just one index, if the macro or a tag
+argument identify one of multiple indices."
+  (let* (tag key)
+    (if (and reftex-support-index (reftex-plug-flag 4))
+	(progn
+	  (reftex-access-scan-info nil)
+	  (setq tag (reftex-what-index-tag)
+		key (reftex-index-complete-key (or tag "idx"))))
+      (setq key (completing-read (TeX-argument-prompt optional prompt "Key")
+				 (LaTeX-index-entry-list))))
+    (unless (string-equal "" key)
+      (LaTeX-add-index-entries key))
+    (TeX-argument-insert key optional)))
+
+(defun reftex-what-index-tag ()
+  ;; Look backward to find out what index the macro at point belongs to
+  (let ((macro (save-excursion
+		 (and (re-search-backward "\\\\[a-zA-Z*]+" nil t)
+		      (match-string 0))))
+	tag entry)
+    (when (and macro
+	       (setq entry (assoc macro reftex-index-macro-alist)))
+      (setq tag (nth 1 entry))
+      (cond
+       ((stringp tag) tag)
+       ((integerp tag)
+	(save-excursion
+	  (goto-char (match-end 1))
+	  (or (reftex-nth-arg tag (nth 6 entry)) "idx")))
+       (t "idx")))))
+
+(defvar LaTeX-label-function)
+(defun reftex-plug-into-AUCTeX ()
+  ;; Replace AUCTeX functions with RefTeX functions.
+  ;; Which functions are replaced is controlled by the variable
+  ;; `reftex-plug-into-AUCTeX'.
+  
+  (if (reftex-plug-flag 0)
+      (setq LaTeX-label-function 'reftex-label)
+    (setq LaTeX-label-function nil))
+
+  (and (or (reftex-plug-flag 1) (reftex-plug-flag 2))
+       (fboundp 'TeX-arg-label)
+       (fset 'TeX-arg-label 'reftex-arg-label))
+
+  (and (reftex-plug-flag 3)
+       (fboundp 'TeX-arg-cite)
+       (fset 'TeX-arg-cite 'reftex-arg-cite))
+  
+  (and (reftex-plug-flag 4) 
+       (fboundp 'TeX-arg-index-tag)
+       (fset 'TeX-arg-index-tag 'reftex-arg-index-tag))
+  (and (reftex-plug-flag 4) 
+       (fboundp 'TeX-arg-index)
+       (fset 'TeX-arg-index 'reftex-arg-index)))
+
+(defun reftex-toggle-plug-into-AUCTeX ()
+  "Toggle Interface between AUCTeX and RefTeX on and off."
+  (interactive)
+  (unless (and (featurep 'tex-site) (featurep 'latex))
+    (error "AUCTeX's LaTeX mode does not seem to be loaded"))
+  (setq reftex-plug-into-AUCTeX (not reftex-plug-into-AUCTeX))
+  (reftex-plug-into-AUCTeX)
+  (if reftex-plug-into-AUCTeX
+      (message "RefTeX has been plugged into AUCTeX.")
+    (message "RefTeX no longer interacts with AUCTeX.")))
+
+(defun reftex-add-label-environments (entry-list)
+  "Add label environment descriptions to `reftex-label-alist-style'.
+The format of ENTRY-LIST is exactly like `reftex-label-alist'.  See there
+for details.
+This function makes it possible to support RefTeX from AUCTeX style files.
+The entries in ENTRY-LIST will be processed after the user settings in
+`reftex-label-alist', and before the defaults (specified in
+`reftex-default-label-alist-entries').  Any changes made to
+`reftex-label-alist-style' will raise a flag to the effect that
+the label information is recompiled on next use."
+  (unless reftex-docstruct-symbol
+    (reftex-tie-multifile-symbols))
+  (when (and reftex-docstruct-symbol
+	     (symbolp reftex-docstruct-symbol))
+    (let ((list (get reftex-docstruct-symbol 'reftex-label-alist-style))
+	  entry changed)
+      (while entry-list
+	(setq entry (pop entry-list))
+	(unless (member entry list)
+	  (setq reftex-tables-dirty t
+		changed t)
+	  (push entry list)))
+      (when changed
+	(put reftex-docstruct-symbol 'reftex-label-alist-style list)))))
+(defalias 'reftex-add-to-label-alist 'reftex-add-label-environments)
+
+(defun reftex-add-section-levels (entry-list)
+  "Add entries to the value of `reftex-section-levels'.
+The added values are kept local to the current document.  The format
+of ENTRY-LIST is a list of cons cells (\"MACRONAME\" . LEVEL).  See
+`reftex-section-levels' for an example."
+  (unless reftex-docstruct-symbol
+    (reftex-tie-multifile-symbols))
+  (when (and reftex-docstruct-symbol
+	     (symbolp reftex-docstruct-symbol))
+    (let ((list (get reftex-docstruct-symbol 'reftex-section-levels))
+	  entry changed)
+      (while entry-list
+	(setq entry (pop entry-list))
+	(unless (member entry list)
+	  (setq reftex-tables-dirty t
+		changed t)
+	  (push entry list)))
+      (when changed
+	(put reftex-docstruct-symbol 'reftex-section-levels list)))))
+
+(defun reftex-notice-new-section ()
+  (reftex-notice-new 1 'force))
+
+;;; reftex-auc.el ends here
+;;; reftex-cite.el - Creating citations with RefTeX
+;;; Version: 4.9
+;;;
+;;; See main file reftex.el for licensing information
+
+(eval-when-compile (require 'cl))
+(provide 'reftex-cite)
+(require 'reftex)
+;;;
+
+;; Variables and constants
+
+;; The history list of regular expressions used for citations
+(defvar reftex-cite-regexp-hist nil)
+
+;; Prompt and help string for citation selection
+(defconst reftex-citation-prompt
+  "Select: [n]ext [p]revious [r]estrict [ ]full_entry [q]uit RET [?]Help+more")
+
+(defconst reftex-citation-help
+  " n / p      Go to next/previous entry (Cursor motion works as well).
+ g / r      Start over with new regexp / Refine with additional regexp.
+ SPC        Show full database entry in other window.
+ f          Toggle follow mode: Other window will follow with full db entry.
+ .          Show insertion point.
+ q          Quit without inserting \\cite macro into buffer.
+ TAB        Enter citation key with completion.
+ RET        Accept current entry (also on mouse-2) and create \\cite macro.
+ m / u      Mark/Unmark the entry.
+ a / A      Put all (marked) entries into one/many \\cite commands.")
+
+;; Find bibtex files
+
+(defun reftex-default-bibliography ()
+  ;; Return the expanded value of `reftex-default-bibliography'.
+  ;; The expanded value is cached.
+  (unless (eq (get 'reftex-default-bibliography :reftex-raw)
+	      reftex-default-bibliography)
+    (put 'reftex-default-bibliography :reftex-expanded
+	 (reftex-locate-bibliography-files 
+	  default-directory reftex-default-bibliography))
+    (put 'reftex-default-bibliography :reftex-raw
+	 reftex-default-bibliography))
+  (get 'reftex-default-bibliography :reftex-expanded))
+
+(defun reftex-get-bibfile-list ()
+  ;; Return list of bibfiles for current document.
+  ;; When using the chapterbib or bibunits package you should either
+  ;; use the same database files everywhere, or separate parts using
+  ;; different databases into different files (included into the mater file).
+  ;; Then this function will return the applicable database files.
+
+  ;; Ensure access to scanning info
+  (reftex-access-scan-info)
+  (or
+   ;; Try inside this file (and its includes)
+   (cdr (reftex-last-assoc-before-elt
+         'bib (list 'eof (buffer-file-name))
+         (member (list 'bof (buffer-file-name))
+                 (symbol-value reftex-docstruct-symbol))))
+   ;; Try after the beginning of this file
+   (cdr (assq 'bib (member (list 'bof (buffer-file-name))
+                           (symbol-value reftex-docstruct-symbol))))
+   ;; Anywhere in the entire document
+   (cdr (assq 'bib (symbol-value reftex-docstruct-symbol)))
+   (error "\\bibliography statement missing or .bib files not found")))
+
+;; Find a certain reference in any of the BibTeX files.
+
+(defun reftex-pop-to-bibtex-entry (key file-list &optional mark-to-kill
+				       highlight item return)
+  ;; Find BibTeX KEY in any file in FILE-LIST in another window.
+  ;; If MARK-TO-KILL is non-nil, mark new buffer to kill.
+  ;; If HIGHLIGHT is non-nil, highlight the match.
+  ;; If ITEM in non-nil, search for bibitem instead of database entry.
+  ;; If RETURN is non-nil, just return the entry.
+
+  (let* ((re
+	  (if item 
+	      (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
+	    (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
+		    "[, \t\r\n}]")))
+	 (buffer-conf (current-buffer))
+         file buf pos)
+
+    (catch 'exit
+      (while file-list
+        (setq file (car file-list)
+              file-list (cdr file-list))
+        (unless (setq buf (reftex-get-file-buffer-force file mark-to-kill))
+          (error "No such file %s" file))
+        (set-buffer buf)
+        (widen)
+        (goto-char (point-min))
+        (when (re-search-forward re nil t)
+          (goto-char (match-beginning 0))
+	  (setq pos (point))
+	  (when return
+	    ;; Just return the relevant entry
+	    (if item (goto-char (match-end 0)))
+	    (setq return (buffer-substring 
+			  (point) (reftex-end-of-bib-entry item)))
+	    (set-buffer buffer-conf)
+	    (throw 'exit return))
+	  (switch-to-buffer-other-window buf)
+	  (goto-char pos)
+          (recenter 0)
+          (if highlight
+              (reftex-highlight 0 (match-beginning 0) (match-end 0)))
+          (throw 'exit (selected-window))))
+      (set-buffer buffer-conf)
+      (if item
+	  (error "No \\bibitem with citation key %s" key)
+	(error "No BibTeX entry with citation key %s" key)))))
+
+(defun reftex-end-of-bib-entry (item)
+  (save-excursion 
+    (condition-case nil
+	(if item 
+	    (progn (end-of-line)
+		   (re-search-forward
+		    "\\\\bibitem\\|\\end{thebibliography}")
+		   (1- (match-beginning 0)))
+	  (progn (forward-list 1) (point)))
+      (error (min (point-max) (+ 300 (point)))))))
+
+;; Parse bibtex buffers
+
+(defun reftex-extract-bib-entries (buffers)
+  ;; Extract bib entries which match regexps from BUFFERS.
+  ;; BUFFERS is a list of buffers or file names.
+  ;; Return list with entries."
+  (let* (re-list first-re rest-re
+                 (buffer-list (if (listp buffers) buffers (list buffers)))
+                 found-list entry buffer1 buffer alist
+                 key-point start-point end-point)
+
+    ;; Read a regexp, completing on known citation keys.
+    (setq re-list 
+	  (split-string 
+	   (completing-read 
+	    "RegExp [ && RegExp...]: "
+	    (if reftex-mode
+		(if (fboundp 'LaTeX-bibitem-list)
+		    (LaTeX-bibitem-list)
+		  (cdr (assoc 'bibview-cache 
+			      (symbol-value reftex-docstruct-symbol))))
+	      nil)
+	    nil nil nil 'reftex-cite-regexp-hist)
+	   "[ \t]*&&[ \t]*"))
+
+    (setq first-re (car re-list)    ; We'll use the first re to find things,
+          rest-re  (cdr re-list))   ; the others to narrow down.
+    (if (string-match "\\`[ \t]*\\'" (or first-re ""))
+        (error "Empty regular expression"))
+
+    (save-excursion
+      (save-window-excursion
+
+        ;; Walk through all bibtex files
+        (while buffer-list
+          (setq buffer (car buffer-list)
+                buffer-list (cdr buffer-list))
+          (if (and (bufferp buffer)
+                   (buffer-live-p buffer))
+              (setq buffer1 buffer)
+            (setq buffer1 (reftex-get-file-buffer-force
+                           buffer (not reftex-keep-temporary-buffers))))
+          (if (not buffer1)
+              (message "No such BibTeX file %s (ignored)" buffer)
+            (message "Scanning bibliography database %s" buffer1))
+
+          (set-buffer buffer1)
+          (save-excursion
+            (goto-char (point-min))
+            (while (re-search-forward first-re nil t)
+              (catch 'search-again
+                (setq key-point (point))
+                (unless (re-search-backward
+                         "\\(\\`\\|[\n\r]\\)[ \t]*@\\([a-zA-Z]+\\)[ \t\n\r]*[{(]" nil t)
+                  (throw 'search-again nil))
+                (setq start-point (point))
+                (goto-char (match-end 0))
+                (condition-case nil
+                    (up-list 1)
+                  (error (goto-char key-point)
+                          (throw 'search-again nil)))
+                (setq end-point (point))
+
+                ;; Ignore @string, @comment and @c entries or things
+                ;; outside entries
+                (when (or (string= (downcase (match-string 2)) "string")
+                          (string= (downcase (match-string 2)) "comment")
+                          (string= (downcase (match-string 2)) "c")
+                          (< (point) key-point)) ; this means match not in {}
+                  (goto-char key-point)
+                  (throw 'search-again nil))
+
+                ;; Well, we have got a match
+                (setq entry (concat
+                             (buffer-substring start-point (point)) "\n"))
+
+                ;; Check if other regexp match as well
+                (setq re-list rest-re)
+                (while re-list
+                  (unless (string-match (car re-list) entry)
+                    ;; nope - move on
+                    (throw 'search-again nil))
+                  (pop re-list))
+
+                (setq alist (reftex-parse-bibtex-entry
+                             nil start-point end-point))
+                (push (cons "&entry" entry) alist)
+
+                ;; check for crossref entries
+                (if (assoc "crossref" alist)
+                    (setq alist
+                          (append
+                           alist (reftex-get-crossref-alist alist))))
+
+                ;; format the entry
+                (push (cons "&formatted" (reftex-format-bib-entry alist))
+                      alist)
+
+		;; make key the first element
+		(push (reftex-get-bib-field "&key" alist) alist)
+
+                ;; add it to the list
+                (push alist found-list))))
+          (reftex-kill-temporary-buffers))))
+    (setq found-list (nreverse found-list))
+
+    ;; Sorting
+    (cond
+     ((eq 'author reftex-sort-bibtex-matches)
+      (sort found-list 'reftex-bib-sort-author))
+     ((eq 'year   reftex-sort-bibtex-matches)
+      (sort found-list 'reftex-bib-sort-year))
+     ((eq 'reverse-year reftex-sort-bibtex-matches)
+      (sort found-list 'reftex-bib-sort-year-reverse))
+     (t found-list))))
+
+(defun reftex-bib-sort-author (e1 e2)
+  (let ((al1 (reftex-get-bib-names "author" e1))
+        (al2 (reftex-get-bib-names "author" e2)))
+    (while (and al1 al2 (string= (car al1) (car al2)))
+      (pop al1)
+      (pop al2))
+    (if (and (stringp (car al1))
+             (stringp (car al2)))
+        (string< (car al1) (car al2))
+      (not (stringp (car al1))))))
+
+(defun reftex-bib-sort-year (e1 e2)
+  (< (string-to-int (cdr (assoc "year" e1)))
+     (string-to-int (cdr (assoc "year" e2)))))
+
+(defun reftex-bib-sort-year-reverse (e1 e2)
+  (> (string-to-int (or (cdr (assoc "year" e1)) "0"))
+     (string-to-int (or (cdr (assoc "year" e2)) "0"))))
+
+(defun reftex-get-crossref-alist (entry)
+  ;; return the alist from a crossref entry
+  (let ((crkey (cdr (assoc "crossref" entry)))
+        start)
+    (save-excursion
+      (save-restriction
+        (widen)
+        (if (re-search-forward
+             (concat "@\\w+[{(][ \t\n\r]*" (regexp-quote crkey)
+                     "[ \t\n\r]*,") nil t)
+            (progn
+              (setq start (match-beginning 0))
+              (condition-case nil
+                  (up-list 1)
+                (error nil))
+              (reftex-parse-bibtex-entry nil start (point)))
+          nil)))))
+
+;; Parse the thebibliography environment
+(defun reftex-extract-bib-entries-from-thebibliography (files)
+  ;; Extract bib-entries from the \begin{thebibliography} environment.
+  ;; Parsing is not as good as for the BibTeX database stuff.
+  ;; The environment should be located in file FILE.
+
+  (let* (start end buf entries re re-list file)
+    (unless files
+      (error "Need file name to find thebibliography environment"))
+    (while (setq file (pop files))
+      (setq buf (reftex-get-file-buffer-force 
+		 file (not reftex-keep-temporary-buffers)))
+      (unless buf
+	(error "No such file %s" file))
+      (message "Scanning thebibliography environment in %s" file)
+
+      (save-excursion
+	(set-buffer buf)
+	(save-restriction
+	  (widen)
+	  (goto-char (point-min))
+	  (while (re-search-forward 
+		  "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
+	    (beginning-of-line 2)
+	    (setq start (point))
+	    (if (re-search-forward 
+		 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
+		(progn
+		  (beginning-of-line 1)
+		  (setq end (point))))
+	    (when (and start end)
+	      (setq entries 
+		    (append entries
+                      (mapcar 'reftex-parse-bibitem
+			(delete ""
+				(split-string 
+				 (buffer-substring-no-properties start end)
+				 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))
+	    (goto-char end)))))
+    (unless entries
+      (error "No bibitems found"))
+
+    (setq re-list (split-string 
+		   (read-string "RegExp [ && RegExp...]: "
+				nil 'reftex-cite-regexp-hist)
+		   "[ \t]*&&[ \t]*"))
+    (if (string-match "\\`[ \t]*\\'" (car re-list))
+        (error "Empty regular expression"))
+
+    (while (and (setq re (pop re-list)) entries)
+      (setq entries 
+	    (delq nil (mapcar
+		       (lambda (x)
+			 (if (string-match re (cdr (assoc "&entry" x)))
+			     x nil))
+		       entries))))
+    (setq entries 
+	  (mapcar 
+	    (lambda (x)
+	      (push (cons "&formatted" (reftex-format-bibitem x)) x)
+	      (push (reftex-get-bib-field "&key" x) x)
+	      x)
+	   entries))
+
+    entries))
+
+;; Parse and format individual entries
+
+(defun reftex-get-bib-names (field entry)
+  ;; Return a list with the author or editor names in ENTRY
+  (let ((names (reftex-get-bib-field field entry)))
+    (if (equal "" names)
+        (setq names (reftex-get-bib-field "editor" entry)))
+    (while (string-match "\\band\\b[ \t]*" names)
+      (setq names (replace-match "\n" nil t names)))
+    (while (string-match "[\\.a-zA-Z\\-]+\\.[ \t]*\\|,.*\\|[{}]+" names)
+      (setq names (replace-match "" nil t names)))
+    (while (string-match "^[ \t]+\\|[ \t]+$" names)
+      (setq names (replace-match "" nil t names)))
+    (while (string-match "[ \t][ \t]+" names)
+      (setq names (replace-match " " nil t names)))
+    (split-string names "\n")))
+
+(defun reftex-parse-bibtex-entry (entry &optional from to)
+  (let (alist key start field)
+    (save-excursion
+      (save-restriction
+        (if entry
+            (progn
+              (set-buffer (get-buffer-create " *RefTeX-scratch*"))
+              (fundamental-mode)
+              (erase-buffer)
+              (insert entry))
+          (widen)
+          (narrow-to-region from to))
+        (goto-char (point-min))
+
+        (if (re-search-forward
+             "@\\(\\w+\\)[ \t\n\r]*[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t)
+            (setq alist
+                  (list
+                   (cons "&type" (downcase (reftex-match-string 1)))
+                   (cons "&key"  (reftex-match-string 2)))))
+        (while (re-search-forward "\\(\\w+\\)[ \t\n\r]*=[ \t\n\r]*" nil t)
+          (setq key (downcase (reftex-match-string 1)))
+          (cond
+           ((= (following-char) ?{)
+            (forward-char 1)
+            (setq start (point))
+            (condition-case nil
+                (up-list 1)
+              (error nil)))
+           ((= (following-char) ?\")
+            (forward-char 1)
+            (setq start (point))
+            (while (and (search-forward "\"" nil t)
+                        (= ?\\ (char-after (- (point) 2))))))
+           (t
+            (setq start (point))
+            (re-search-forward "[ \t]*[\n\r,}]" nil 1)))
+          (setq field (buffer-substring-no-properties start (1- (point))))
+          ;; remove extra whitespace
+          (while (string-match "[\n\t\r]\\|[ \t][ \t]+" field)
+            (setq field (replace-match " " nil t field)))
+          ;; remove leading garbage
+          (if (string-match "^[ \t{]+" field)
+              (setq field (replace-match "" nil t field)))
+          ;; remove trailing garbage
+          (if (string-match "[ \t}]+$" field)
+              (setq field (replace-match "" nil t field)))
+          (push (cons key field) alist))))
+    alist))
+
+(defun reftex-get-bib-field (fieldname entry &optional format)
+  ;; Extract the field FIELDNAME from an ENTRY
+  (let ((cell (assoc fieldname entry)))
+    (if cell
+	(if format
+	    (format format (cdr cell))
+	  (cdr cell))
+      "")))
+
+(defun reftex-format-bib-entry (entry)
+  ;; Format a BibTeX ENTRY so that it is nice to look at
+  (let*
+      ((auth-list (reftex-get-bib-names "author" entry))
+       (authors (mapconcat 'identity auth-list ", "))
+       (year      (reftex-get-bib-field "year" entry))
+       (title     (reftex-get-bib-field "title" entry))
+       (type      (reftex-get-bib-field "&type" entry))
+       (key       (reftex-get-bib-field "&key"  entry))
+       (extra
+        (cond
+         ((equal type "article")
+          (concat (reftex-get-bib-field "journal" entry) " "
+                  (reftex-get-bib-field "volume" entry) ", "
+                  (reftex-get-bib-field "pages" entry)))
+         ((equal type "book")
+          (concat "book (" (reftex-get-bib-field "publisher" entry) ")"))
+         ((equal type "phdthesis")
+          (concat "PhD: " (reftex-get-bib-field "school" entry)))
+         ((equal type "mastersthesis")
+          (concat "Master: " (reftex-get-bib-field "school" entry)))
+         ((equal type "inbook")
+          (concat "Chap: " (reftex-get-bib-field "chapter" entry)
+                  ", pp. " (reftex-get-bib-field "pages"   entry)))
+         ((or (equal type "conference")
+              (equal type "incollection")
+              (equal type "inproceedings"))
+          (reftex-get-bib-field "booktitle" entry "in: %s"))
+         (t ""))))
+    (setq authors (reftex-truncate authors 30 t t))
+    (when (reftex-use-fonts)
+      (put-text-property 0 (length key)     'face
+			 (reftex-verified-face reftex-label-face
+					       'font-lock-constant-face
+					       'font-lock-reference-face)
+                         key)
+      (put-text-property 0 (length authors) 'face reftex-bib-author-face
+                         authors)
+      (put-text-property 0 (length year)    'face reftex-bib-year-face
+                         year)
+      (put-text-property 0 (length title)   'face reftex-bib-title-face
+                         title)
+      (put-text-property 0 (length extra)   'face reftex-bib-extra-face
+                         extra))
+    (concat key "\n     " authors " " year " " extra "\n     " title "\n\n")))
+
+(defun reftex-parse-bibitem (item)
+  ;; Parse a \bibitem entry
+  (let ((key "") (text ""))
+    (when (string-match "\\`{\\([^}]+\\)}\\([\001-\255]*\\)" item)
+      (setq key (match-string 1 item)
+	    text (match-string 2 item)))
+    ;; Clean up the text a little bit
+    (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text)
+      (setq text (replace-match " " nil t text)))
+    (if (string-match "\\`[ \t]+" text)
+	(setq text (replace-match "" nil t text)))
+    (list
+     (cons "&key" key)
+     (cons "&text" text)
+     (cons "&entry" (concat key " " text)))))
+
+(defun reftex-format-bibitem (item)
+  ;; Format a \bibitem entry so that it is (relatively) nice to look at.
+  (let ((text (reftex-get-bib-field "&text" item))
+	(key  (reftex-get-bib-field "&key" item))
+	(lines nil))
+
+    ;; Wrap the text into several lines.
+    (while (and (> (length text) 70)
+		(string-match " " (substring text 60)))
+	(push (substring text 0 (+ 60 (match-beginning 0))) lines)
+	(setq text (substring text (+ 61 (match-beginning 0)))))
+    (push text lines)
+    (setq text (mapconcat 'identity (nreverse lines) "\n     "))
+
+    (when (reftex-use-fonts)
+      (put-text-property 0 (length text) 'face reftex-bib-author-face text))
+    (concat key "\n     " text "\n\n")))
+
+;; Make a citation
+
+;;;###autoload
+(defun reftex-citation (&optional no-insert format-key)
+  "Make a citation using BibTeX database files.
+After prompting for a regular expression, scans the buffers with
+bibtex entries (taken from the \\bibliography command) and offers the
+matching entries for selection.  The selected entry is formated according
+to `reftex-cite-format' and inserted into the buffer.
+
+If NO-INSERT is non-nil, nothing is inserted, only the selected key returned.
+
+FORAT-KEY can be used to pre-select a citation format.
+
+When called with one or two `C-u' prefixes, first rescans the document.
+When called with a numeric prefix, make that many citations.  When
+called with point inside the braces of a `\cite' command, it will
+add another key, ignoring the value of `reftex-cite-format'.
+
+The regular expression uses an expanded syntax: && is interpreted as `and'.
+Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'.
+While entering the regexp, completion on knows citation keys is possible.
+`=' is a good regular expression to match all entries in all files."
+
+  (interactive)
+
+  ;; check for recursive edit
+  (reftex-check-recursive-edit)
+
+  ;; This function may also be called outside reftex-mode.
+  ;; Thus look for the scanning info only if in reftex-mode.
+
+  (when reftex-mode
+    (reftex-access-scan-info current-prefix-arg))
+
+  ;; Call reftex-do-citation, but protected
+  (unwind-protect
+      (reftex-do-citation current-prefix-arg no-insert format-key)
+    (reftex-kill-temporary-buffers)))
+
+(defun reftex-do-citation (&optional arg no-insert format-key)
+  ;; This really does the work of reftex-citation.
+
+  (let* ((format (reftex-figure-out-cite-format arg no-insert format-key))
+	 (docstruct-symbol reftex-docstruct-symbol)
+	 (selected-entries (reftex-offer-bib-menu))
+	 (insert-entries selected-entries)
+	 entry string cite-view)
+
+    (unless selected-entries (error "Quit"))
+
+    (if (stringp selected-entries)
+	;; Nonexistent entry
+	(setq selected-entries nil
+	      insert-entries (list (list selected-entries
+					 (cons "&key" selected-entries))))
+      ;; It makes sense to compute the cite-view strings.
+      (setq cite-view t))
+
+    (when (eq (car selected-entries) 'concat)
+      ;; All keys go into a single command - we need to trick a little
+      (pop selected-entries)
+      (let ((concat-keys (mapconcat 'car selected-entries ",")))
+	(setq insert-entries 
+	      (list (list concat-keys (cons "&key" concat-keys))))))
+    
+    (unless no-insert
+
+      ;; We shall insert this into the buffer...
+      (message "Formatting...")
+
+      (while (setq entry (pop insert-entries))
+	;; Format the citation and insert it
+	(setq string (if reftex-format-cite-function
+			 (funcall reftex-format-cite-function
+				  (reftex-get-bib-field "&key" entry)
+				  format)
+		       (reftex-format-citation entry format)))
+	(insert string))
+
+      ;; Reposition cursor?
+      (when (string-match "\\?" string)
+	(search-backward "?")
+	(delete-char 1))
+
+      ;; Tell AUCTeX
+      (when (and reftex-mode 
+		 (fboundp 'LaTeX-add-bibitems)
+		 reftex-plug-into-AUCTeX)
+	(apply 'LaTeX-add-bibitems (mapcar 'car selected-entries)))
+      
+      ;; Produce the cite-view strings
+      (when (and reftex-mode reftex-cache-cite-echo cite-view)
+	(mapcar (lambda (entry) 
+		  (reftex-make-cite-echo-string entry docstruct-symbol))
+		selected-entries))
+
+      (message ""))
+
+    (set-marker reftex-select-return-marker nil)
+    (reftex-kill-buffer "*RefTeX Select*")
+    
+    ;; Check if the prefix arg was numeric, and call recursively
+    (when (integerp arg)
+      (if (> arg 1)
+	  (progn      
+	    (skip-chars-backward "}")
+	    (decf arg)
+	    (reftex-do-citation arg))
+	(forward-char 1)))
+    
+    ;; Return the citation key
+    (car (car selected-entries))))
+
+(defun reftex-figure-out-cite-format (arg &optional no-insert format-key)
+  ;; Check if there is already a cite command at point and change cite format
+  ;; in order to only add another reference in the same cite command.
+  (let ((macro (car (reftex-what-macro 1)))
+	(cite-format-value (reftex-get-cite-format))
+	key format)
+    (cond
+     (no-insert
+      ;; Format does not really matter because nothing will be inserted.
+      (setq format "%l"))
+     
+     ((and (stringp macro)
+	   (string-match "\\`\\\\cite\\|cite\\'" macro))
+      ;; We are already inside a cite macro
+      (if (or (not arg) (not (listp arg)))
+	  (setq format
+		(concat
+		 (if (member (preceding-char) '(?\{ ?,)) "" ",")
+		 "%l"
+		 (if (member (following-char) '(?\} ?,)) "" ",")))
+	(setq format "%l")))
+     (t
+      ;; Figure out the correct format
+      (setq format
+            (if (and (symbolp cite-format-value)
+		     (assq cite-format-value reftex-cite-format-builtin))
+		(nth 2 (assq cite-format-value reftex-cite-format-builtin))
+	      cite-format-value))
+      (when (listp format)
+	(setq key
+	      (or format-key
+		  (reftex-select-with-char 
+		   "" (concat "SELECT A CITATION FORMAT\n\n"
+			      (mapconcat
+			       (lambda (x)
+				 (format "[%c] %s  %s" (car x)
+					 (if (> (car x) 31) " " "")
+					 (cdr x)))
+			       format "\n")))))
+	(if (assq key format)
+	    (setq format (cdr (assq key format)))
+	  (error "No citation format associated with key `%c'" key)))))
+    format))
+
+(defun reftex-citep ()
+  "Call `reftex-citation' with a format selector `?p'."
+  (interactive)
+  (reftex-citation nil ?p))
+
+(defun reftex-citet ()
+  "Call `reftex-citation' with a format selector `?t'."
+  (interactive)
+  (reftex-citation nil ?t))
+
+(defvar reftex-select-bib-map)
+(defun reftex-offer-bib-menu ()
+  ;; Offer bib menu and return list of selected items
+
+  (let (found-list rtn key data selected-entries)
+    (while 
+	(not 
+	 (catch 'done
+	   ;; Scan bibtex files
+	   (setq found-list
+	      (cond
+	       ((assq 'bib (symbol-value reftex-docstruct-symbol))
+		;; using BibTeX database files.
+		(reftex-extract-bib-entries (reftex-get-bibfile-list)))
+	       ((assq 'thebib (symbol-value reftex-docstruct-symbol))
+		;; using thebibliography environment.
+		(reftex-extract-bib-entries-from-thebibliography
+		 (reftex-uniquify
+		  (mapcar 'cdr
+			  (reftex-all-assq 
+			   'thebib (symbol-value reftex-docstruct-symbol))))))
+	       (reftex-default-bibliography
+		(message "Using default bibliography")
+		(reftex-extract-bib-entries (reftex-default-bibliography)))
+	       (t (error "No valid bibliography in this document, and no default available"))))
+	   
+	   (unless found-list
+	     (error "Sorry, no matches found"))
+    
+	  ;; Remember where we came from
+	  (setq reftex-call-back-to-this-buffer (current-buffer))
+	  (set-marker reftex-select-return-marker (point))
+    
+	  ;; Offer selection
+	  (save-window-excursion
+	    (delete-other-windows)
+	    (let ((default-major-mode 'reftex-select-bib-mode))
+	      (reftex-kill-buffer "*RefTeX Select*")
+	      (switch-to-buffer-other-window "*RefTeX Select*")
+	      (unless (eq major-mode 'reftex-select-bib-mode)
+		(reftex-select-bib-mode))
+	      (let ((buffer-read-only nil))
+		(erase-buffer)
+		(reftex-insert-bib-matches found-list)))
+	    (setq buffer-read-only t)
+	    (if (= 0 (buffer-size))
+		(error "No matches found"))
+	    (setq truncate-lines t)
+	    (goto-char 1)
+	    (while t
+	      (setq rtn
+		    (reftex-select-item
+		     reftex-citation-prompt
+		     reftex-citation-help
+		     reftex-select-bib-map
+		     nil
+		     'reftex-bibtex-selection-callback nil))
+	      (setq key (car rtn)
+		    data (nth 1 rtn))
+	      (unless key (throw 'done t))
+	      (cond
+	       ((eq key ?g)
+		;; Start over
+		(throw 'done nil))
+	       ((eq key ?r)
+		;; Restrict with new regular expression
+		(setq found-list (reftex-restrict-bib-matches found-list))
+		(let ((buffer-read-only nil))
+		  (erase-buffer)
+		  (reftex-insert-bib-matches found-list))
+		(goto-char 1))
+	       ((eq key ?A)
+		;; Take all (marked)
+		(setq selected-entries 
+		      (if reftex-select-marked
+			  (mapcar 'car (nreverse reftex-select-marked))
+			found-list))
+		(throw 'done t))
+	       ((eq key ?a)
+		;; Take all (marked), and push the symbol 'concat
+		(setq selected-entries 
+		      (cons 'concat 
+			    (if reftex-select-marked
+				(mapcar 'car (nreverse reftex-select-marked))
+			      found-list)))
+		(throw 'done t))
+	       ((or (eq key ?\C-m)
+		    (eq key 'return))
+		;; Take selected
+		(setq selected-entries 
+		      (if reftex-select-marked
+			  (cons 'concat 
+				(mapcar 'car (nreverse reftex-select-marked)))
+			(if data (list data) nil)))
+		(throw 'done t))
+	       ((stringp key)
+		;; Got this one with completion
+		(setq selected-entries key)
+		(throw 'done t))
+	       (t
+		(ding))))))))
+    selected-entries))
+
+(defun reftex-restrict-bib-matches (found-list)
+  ;; Limit FOUND-LIST with more regular expressions
+  (let ((re-list (split-string (read-string
+				"RegExp [ && RegExp...]: "
+				nil 'reftex-cite-regexp-hist)
+			       "[ \t]*&&[ \t]*"))
+	(found-list-r found-list)
+	re)
+    (while (setq re (pop re-list))
+      (setq found-list-r
+	    (delq nil
+		  (mapcar
+		   (lambda (x)
+		     (if (string-match
+			  re (cdr (assoc "&entry" x)))
+			 x
+		       nil))
+		   found-list-r))))
+    (if found-list-r
+	found-list-r
+      (ding)
+      found-list)))
+
+(defun reftex-insert-bib-matches (list)
+  ;; Insert the bib matches and number them correctly
+  (let ((mouse-face
+	 (if (memq reftex-highlight-selection '(mouse both))
+	     reftex-mouse-selected-face
+	   nil))
+	tmp len)
+    (mapcar 
+     (lambda (x)
+       (setq tmp (cdr (assoc "&formatted" x))
+	     len (length tmp))
+       (put-text-property 0 len :data x tmp)
+       (put-text-property 0 (1- len) 'mouse-face mouse-face tmp)
+       (insert tmp))
+     list))
+  (run-hooks 'reftex-display-copied-context-hook))
+
+(defun reftex-format-names (namelist n)
+  (let (last (len (length namelist)))
+    (cond
+     ((< len 1) "")
+     ((= 1 len) (car namelist))
+     ((> len n) (concat (car namelist) (nth 2 reftex-cite-punctuation)))
+     (t
+      (setq n (min len n)
+            last (nth (1- n) namelist))
+      (setcdr (nthcdr (- n 2) namelist) nil)
+      (concat
+       (mapconcat 'identity namelist (nth 0 reftex-cite-punctuation))
+       (nth 1 reftex-cite-punctuation)
+       last)))))
+
+(defun reftex-format-citation (entry format)
+  ;; Format a citation from the info in the BibTeX ENTRY
+
+  (unless (stringp format) (setq format "\\cite{%l}"))
+
+  (if (and reftex-comment-citations
+           (string-match "%l" reftex-cite-comment-format))
+      (error "reftex-cite-comment-format contains illegal %%l"))
+
+  (while (string-match
+          "\\(\\`\\|[^%]\\)\\(\\(%\\([0-9]*\\)\\([a-zA-Z]\\)\\)[.,;: ]*\\)"
+          format)
+    (let ((n (string-to-int (match-string 4 format)))
+          (l (string-to-char (match-string 5 format)))
+          rpl b e)
+      (save-match-data
+        (setq rpl
+              (cond
+               ((= l ?l) (concat
+                          (reftex-get-bib-field "&key" entry)
+                          (if reftex-comment-citations
+                              reftex-cite-comment-format
+                            "")))
+               ((= l ?a) (reftex-format-names
+                          (reftex-get-bib-names "author" entry)
+                          (or n 2)))
+               ((= l ?A) (car (reftex-get-bib-names "author" entry)))
+               ((= l ?b) (reftex-get-bib-field "booktitle" entry "in: %s"))
+               ((= l ?B) (reftex-abbreviate-title
+			  (reftex-get-bib-field "booktitle" entry "in: %s")))
+               ((= l ?c) (reftex-get-bib-field "chapter" entry))
+               ((= l ?d) (reftex-get-bib-field "edition" entry))
+               ((= l ?e) (reftex-format-names
+                          (reftex-get-bib-names "editor" entry)
+                          (or n 2)))
+               ((= l ?E) (car (reftex-get-bib-names "editor" entry)))
+               ((= l ?h) (reftex-get-bib-field "howpublished" entry))
+               ((= l ?i) (reftex-get-bib-field "institution" entry))
+               ((= l ?j) (reftex-get-bib-field "journal" entry))
+               ((= l ?k) (reftex-get-bib-field "key" entry))
+               ((= l ?m) (reftex-get-bib-field "month" entry))
+               ((= l ?n) (reftex-get-bib-field "number" entry))
+               ((= l ?o) (reftex-get-bib-field "organization" entry))
+               ((= l ?p) (reftex-get-bib-field "pages" entry))
+               ((= l ?P) (car (split-string
+                               (reftex-get-bib-field "pages" entry)
+                               "[- .]+")))
+               ((= l ?s) (reftex-get-bib-field "school" entry))
+               ((= l ?u) (reftex-get-bib-field "publisher" entry))
+               ((= l ?r) (reftex-get-bib-field "address" entry))
+               ((= l ?t) (reftex-get-bib-field "title" entry))
+               ((= l ?T) (reftex-abbreviate-title
+			  (reftex-get-bib-field "title" entry)))
+               ((= l ?v) (reftex-get-bib-field "volume" entry))
+               ((= l ?y) (reftex-get-bib-field "year" entry)))))
+
+      (if (string= rpl "")
+          (setq b (match-beginning 2) e (match-end 2))
+        (setq b (match-beginning 3) e (match-end 3)))
+      (setq format (concat (substring format 0 b) rpl (substring format e)))))
+  (while (string-match "%%" format)
+    (setq format (replace-match "%" t t format)))
+  (while (string-match "[ ,.;:]*%<" format)
+    (setq format (replace-match "" t t format)))
+  format)
+
+(defun reftex-make-cite-echo-string (entry docstruct-symbol)
+  ;; Format a bibtex entry for the echo area and cache the result.
+  (let* ((key (reftex-get-bib-field "&key" entry))
+	 (string 
+	  (let* ((reftex-cite-punctuation '(" " " & " " etal.")))
+	    (reftex-format-citation entry reftex-cite-view-format)))
+	 (cache (assq 'bibview-cache (symbol-value docstruct-symbol)))
+	 (cache-entry (assoc key (cdr cache))))
+    (unless cache
+      ;; This docstruct has no cache - make one.
+      (set docstruct-symbol (cons (cons 'bibview-cache nil)
+				  (symbol-value docstruct-symbol))))
+    (when reftex-cache-cite-echo
+      (setq key (copy-sequence key))
+      (set-text-properties 0 (length key) nil key)
+      (set-text-properties 0 (length string) nil string)
+      (if cache-entry
+	  (unless (string= (cdr cache-entry) string)
+	    (setcdr cache-entry string)
+	    (put reftex-docstruct-symbol 'modified t))
+	(push (cons key string) (cdr cache))
+	(put reftex-docstruct-symbol 'modified t)))
+    string))
+
+(defun reftex-bibtex-selection-callback (data ignore no-revisit)
+  ;; Callback function to be called from the BibTeX selection, in
+  ;; order to display context.  This function is relatively slow and not
+  ;; recommended for follow mode.  It works OK for individual lookups.
+  (let ((win (selected-window))
+        (key (reftex-get-bib-field "&key" data))
+        bibfile-list item)
+
+    (catch 'exit
+      (save-excursion
+	(set-buffer reftex-call-back-to-this-buffer)
+	(cond
+	 ((assq 'bib (symbol-value reftex-docstruct-symbol))
+	  (setq bibfile-list (reftex-get-bibfile-list)))
+	 ((assq 'thebib (symbol-value reftex-docstruct-symbol))
+	  (setq bibfile-list
+		(reftex-uniquify
+		 (mapcar 'cdr
+			 (reftex-all-assq 
+			  'thebib (symbol-value reftex-docstruct-symbol))))
+		item t))
+	 (reftex-default-bibliography
+	  (setq bibfile-list (reftex-default-bibliography)))
+	 (t (ding) (throw 'exit))))
+
+      (when no-revisit
+	(setq bibfile-list (reftex-visited-files bibfile-list)))
+
+      (condition-case nil
+	  (reftex-pop-to-bibtex-entry 
+	   key bibfile-list (not reftex-keep-temporary-buffers) t item)
+	(error (ding))))
+      
+    (select-window win)))
+
+;;; reftex-cite.el ends here
+;;; reftex-global.el - Operations on entire documents with RefTeX
+;;; Version: 4.9
+;;;
+;;; See main file reftex.el for licensing information
+
+(eval-when-compile (require 'cl))
+(provide 'reftex-global)
+(require 'reftex)
+;;;
+
+(defun reftex-create-tags-file ()
+  "Create TAGS file by running `etags' on the current document.
+The TAGS file is also immediately visited with `visit-tags-table'."
+  (interactive)
+  (reftex-access-scan-info current-prefix-arg)
+  (let* ((master (reftex-TeX-master-file))
+         (files  (reftex-all-document-files))
+         (cmd    (format "etags %s" (mapconcat 'identity files " "))))
+    (save-excursion
+      (set-buffer (reftex-get-buffer-visiting master))
+      (message "Running etags to create TAGS file...")
+      (shell-command cmd)
+      (visit-tags-table "TAGS"))))
+
+;; History of grep commands.
+(defvar reftex-grep-history nil)
+(defvar reftex-grep-command "grep -n "
+  "Last grep command used in \\[reftex-grep-document]; default for next grep.")
+
+(defun reftex-grep-document (grep-cmd)
+  "Run grep query through all files related to this document.
+With prefix arg, force to rescan document.
+No active TAGS table is required."
+
+  (interactive
+   (list (read-from-minibuffer "Run grep on document (like this): "
+                               reftex-grep-command nil nil
+                               'reftex-grep-history)))
+  (reftex-access-scan-info current-prefix-arg)
+  (let* ((files  (reftex-all-document-files t))
+         (cmd    (format
+                  "%s %s" grep-cmd
+                  (mapconcat 'identity files " "))))
+    (grep cmd)))
+
+(defun reftex-search-document (&optional regexp)
+  "Regexp search through all files of the current document.
+Starts always in the master file.  Stops when a match is found.
+To continue searching for next match, use command \\[tags-loop-continue].
+No active TAGS table is required."
+  (interactive)
+  (let ((default (reftex-this-word)))
+    (unless regexp
+      (setq regexp (read-string (format "Search regexp in document [%s]: "
+                                        default))))
+    (if (string= regexp "") (setq regexp (regexp-quote default)))
+
+    (reftex-access-scan-info current-prefix-arg)
+    (tags-search regexp (list 'reftex-all-document-files))))
+
+(defun reftex-query-replace-document (&optional from to delimited)
+  "Run a query-replace-regexp of FROM with TO over the entire document.
+Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
+If you exit (\\[keyboard-quit] or ESC), you can resume the query replace
+with the command \\[tags-loop-continue].
+No active TAGS table is required."
+  (interactive)
+  (let ((default (reftex-this-word)))
+    (unless from
+      (setq from (read-string (format "Replace regexp in document [%s]: "
+                                      default)))
+      (if (string= from "") (setq from (regexp-quote default))))
+    (unless to
+      (setq to (read-string (format "Replace regexp %s with: " from))))
+    (reftex-access-scan-info current-prefix-arg)
+    (tags-query-replace from to (or delimited current-prefix-arg)
+                        (list 'reftex-all-document-files))))
+
+(defun reftex-find-duplicate-labels ()
+  "Produce a list of all duplicate labels in the document."
+
+  (interactive)
+
+  ;; Rescan the document to make sure
+  (reftex-access-scan-info t)
+
+  (let ((master (reftex-TeX-master-file))
+	(cnt 0)
+        (dlist
+         (mapcar
+	  (lambda (x)
+	    (let (x1)
+	      (cond
+	       ((memq (car x)
+		      '(toc bof eof bib thebib label-numbers xr xr-doc
+			    master-dir file-error bibview-cache appendix
+			    is-multi index))
+		nil)
+	       (t
+		(setq x1 (reftex-all-assoc-string
+			  (car x) (symbol-value reftex-docstruct-symbol)))
+		(if (< 1 (length x1))
+		    (append (list (car x))
+			    (mapcar (lambda(x)
+				      (abbreviate-file-name (nth 3 x)))
+				    x1))
+		  (list nil))))))
+          (reftex-uniquify-by-car (symbol-value reftex-docstruct-symbol)))))
+
+    (setq dlist (reftex-uniquify-by-car dlist))
+    (if (null dlist) (error "No duplicate labels in document"))
+    (switch-to-buffer-other-window "*Duplicate Labels*")
+    (set (make-local-variable 'TeX-master) master)
+    (erase-buffer)
+    (insert "                MULTIPLE LABELS IN CURRENT DOCUMENT:\n")
+    (insert 
+     " Move point to label and type `r' to run a query-replace on the label\n"
+     " and its references.  Type `q' to exit this buffer.\n\n")
+    (insert " LABEL               FILE\n")
+    (insert " -------------------------------------------------------------\n")
+    (use-local-map (make-sparse-keymap))
+    (local-set-key [?q] (lambda () "Kill this buffer." (interactive)
+			  (kill-buffer (current-buffer)) (delete-window)))
+    (local-set-key [?r] 'reftex-change-label)
+    (while dlist
+      (when (and (car (car dlist))
+                 (cdr (car dlist)))
+	(incf cnt)
+        (insert (mapconcat 'identity (car dlist) "\n    ") "\n"))
+      (pop dlist))
+    (goto-char (point-min))
+    (when (= cnt 0)
+      (kill-buffer (current-buffer))
+      (delete-window)
+      (message "Document does not contain duplicate labels."))))
+
+(defun reftex-change-label (&optional from to)
+  "Query replace FROM with TO in all \\label and \\ref commands.
+Works on the entire multifile document.
+If you exit (\\[keyboard-quit] or ESC), you can resume the query replace
+with the command \\[tags-loop-continue].
+No active TAGS table is required."
+  (interactive)
+  (let ((default (reftex-this-word "-a-zA-Z0-9_*.:")))
+    (unless from
+      (setq from (read-string (format "Replace label globally [%s]: "
+                                      default))))
+    (if (string= from "") (setq from default))
+    (unless to
+      (setq to (read-string (format "Replace label %s with: "
+                                    from))))
+    (reftex-query-replace-document
+     (concat "\\\\\\(label\\|[a-z]*ref\\){" (regexp-quote from) "}")
+     (format "\\\\\\1{%s}" to))))
+
+(defun reftex-renumber-simple-labels ()
+  "Renumber all simple labels in the document to make them sequentially.
+Simple labels are the ones created by RefTeX, consisting only of the
+prefix and a number.  After the command completes, all these labels will
+have sequential numbers throughout the document.  Any references to
+the labels will be changed as well.  For this, RefTeX looks at the
+arguments of any macros which either start or end in the string `ref'.
+This command should be used with care, in particular in multifile