reftex: Optimizations

 
 13 Optimizations
 ****************
 
 Note added 2002.  Computers have gotten a lot faster, so most of the
 optimizations discussed below will not be necessary on new machines.  I
 am leaving this stuff in the manual for people who want to write thick
 books, where some of it still might be useful.
 
    Implementing the principle of least surprises, the default settings
 of RefTeX ensure a safe ride for beginners and casual users.  However,
 when using RefTeX for a large project and/or on a small computer, there
 are ways to improve speed or memory usage.
 
    • Removing Lookup Buffers
      RefTeX will load other parts of a multifile document as well as
      BibTeX database files for lookup purposes.  These buffers are kept,
      so that subsequent use of the same files is fast.  If you can’t
      afford keeping these buffers around, and if you can live with a
      speed penalty, try
 
           (setq reftex-keep-temporary-buffers nil)
 
    • Partial Document Scans
      A ‘C-u’ prefix on the major RefTeX commands ‘reftex-label’ (‘C-u
      C-c (’), ‘reftex-reference’ (‘C-u C-c )’), ‘reftex-citation’ (‘C-u
      C-c [’), ‘reftex-toc’ (‘C-u C-c =’), and ‘reftex-view-crossref’
      (‘C-u C-c &’) initiates re-parsing of the entire document in order
      to update the parsing information.  For a large document this can
      be unnecessary, in particular if only one file has changed.  RefTeX
      can be configured to do partial scans instead of full ones.  ‘C-u’
      re-parsing then does apply only to the current buffer and files
      included from it.  Likewise, the ‘r’ key in both the label
      selection buffer and the table-of-contents buffer will only prompt
      scanning of the file in which the label or section macro near the
      cursor was defined.  Re-parsing of the entire document is still
      available by using ‘C-u C-u’ as a prefix, or the capital ‘R’ key in
      the menus.  To use this feature, try
 
           (setq reftex-enable-partial-scans t)
 
    • Saving Parser Information
      Even with partial scans enabled, RefTeX still has to make one full
      scan, when you start working with a document.  To avoid this,
      parsing information can be stored in a file.  The file ‘MASTER.rel’
      is used for storing information about a document with master file
      ‘MASTER.tex’.  It is written automatically when you kill a buffer
      in ‘reftex-mode’ or when you exit Emacs.  The information is
      restored when you begin working with a document in a new editing
      session.  To use this feature, put into ‘.emacs’:
 
           (setq reftex-save-parse-info t)
 
    • Identifying label types by prefix
      RefTeX normally parses around each label to check in which
      environment this label is located, in order to assign a label type
      to the label.  If your document contains thousands of labels,
      document parsing will take considerable time.  If you have been
      using label prefixes like tab: and fn: consistently, you can tell
      RefTeX to get the label type directly from the prefix, without
      additional parsing.  This will be faster and also allow labels to
      end up in the correct category if for some reason it is not
      possible to derive the correct type from context.  For example, to
      enable this feature for footnote and equation labels, use
 
           (setq reftex-trust-label-prefix '("fn:" "eq:"))
 
    • Automatic Document Scans
      At rare occasions, RefTeX will automatically rescan a part of the
      document.  If this gets into your way, it can be turned off with
 
           (setq reftex-allow-automatic-rescan nil)
 
      RefTeX will then occasionally annotate new labels in the selection
      buffer, saying that their position in the label list in uncertain.
      A manual document scan will fix this.
 
    • Multiple Selection Buffers
      Normally, the selection buffer ‘*RefTeX Select*’ is re-created for
      every selection process.  In documents with very many labels this
      can take several seconds.  RefTeX provides an option to create a
      separate selection buffer for each label type and to keep this
      buffer from one selection to the next.  These buffers are updated
      automatically only when a new label has been added in the buffers
      category with ‘reftex-label’.  Updating the buffer takes as long as
      recreating it - so the time saving is limited to cases where no new
      labels of that category have been added.  To turn on this feature,
      use
 
           (setq reftex-use-multiple-selection-buffers t)
 
      You can also inhibit the automatic updating entirely.  Then the
      selection buffer will always pop up very fast, but may not contain
      the most recently defined labels.  You can always update the buffer
      by hand, with the ‘g’ key.  To get this behavior, use instead
 
           (setq reftex-use-multiple-selection-buffers t
                 reftex-auto-update-selection-buffers nil)
 
 As a summary, here are the settings I recommend for heavy use of RefTeX
 with large documents:
 
      (setq reftex-enable-partial-scans t
            reftex-save-parse-info t
            reftex-use-multiple-selection-buffers t)