-;;; This is a Completion system for GNU Emacs
-;;;
-;;; E-Mail:
-;;; Internet: completion@think.com, bug-completion@think.com
-;;; UUCP: {rutgers,harvard,mit-eddie}!think!completion
-;;;
-;;; If you are a new user, we'd appreciate knowing your site name and
-;;; any comments you have.
-;;;
-;;;
-;;; NO WARRANTY
-;;;
-;;; This software is distributed free of charge and is in the public domain.
-;;; Anyone may use, duplicate or modify this program. Thinking Machines
-;;; Corporation does not restrict in any way the use of this software by
-;;; anyone.
-;;;
-;;; Thinking Machines Corporation provides absolutely no warranty of any kind.
-;;; The entire risk as to the quality and performance of this program is with
-;;; you. In no event will Thinking Machines Corporation be liable to you for
-;;; damages, including any lost profits, lost monies, or other special,
-;;; incidental or consequential damages arising out of the use of this program.
-;;;
-;;; You must not restrict the distribution of this software.
-;;;
-;;; Please keep this notice and author information in any copies you make.
-;;;
-;;; 4/90
-;;;
-;;;
-;;; Advertisement
-;;;---------------
-;;; Try using this. If you are like most you will be happy you did.
-;;;
-;;; What to put in .emacs
-;;;-----------------------
-;;; (load "completion") ;; If it's not part of the standard band.
-;;; (initialize-completions)
-;;;
-;;; For best results, be sure to byte-compile the file first.
-;;;
-\f
-;;; Authors
-;;;---------
-;;; Jim Salem {salem@think.com}
-;;; Brewster Kahle {brewster@think.com}
-;;; Thinking Machines Corporation
-;;; 245 First St., Cambridge MA 02142 (617) 876-1111
-;;;
-;;; Mailing Lists
-;;;---------------
-;;;
-;;; Bugs to bug-completion@think.com
-;;; Comments to completion@think.com
-;;; Requests to be added completion-request@think.com
-;;;
-;;; Availability
-;;;--------------
-;;; Anonymous FTP from think.com
-;;;
-\f
-;;;---------------------------------------------------------------------------
-;;; Documentation [Slightly out of date]
-;;;---------------------------------------------------------------------------
-;;; (also check the documentation string of the functions)
-;;;
-;;; Introduction
-;;;---------------
-;;;
-;;; After you type a few characters, pressing the "complete" key inserts
-;;; the rest of the word you are likely to type.
-;;;
-;;; This watches all the words that you type and remembers them. When
-;;; typing a new word, pressing "complete" (meta-return) "completes" the
-;;; word by inserting the most recently used word that begins with the
-;;; same characters. If you press meta-return repeatedly, it cycles
-;;; through all the words it knows about.
-;;;
-;;; If you like the completion then just continue typing, it is as if you
-;;; entered the text by hand. If you want the inserted extra characters
-;;; to go away, type control-w or delete. More options are described below.
-;;;
-;;; The guesses are made in the order of the most recently "used". Typing
-;;; in a word and then typing a separator character (such as a space) "uses"
-;;; the word. So does moving a cursor over the word. If no words are found,
-;;; it uses an extended version of the dabbrev style completion.
-;;;
-;;; You automatically save the completions you use to a file between
-;;; sessions.
-;;;
-;;; Completion enables programmers to enter longer, more descriptive
-;;; variable names while typing fewer keystrokes than they normally would.
-;;;
-;;;
-;;; Full documentation
-;;;---------------------
-;;;
-;;; A "word" is any string containing characters with either word or symbol
-;;; syntax. [E.G. Any alphanumeric string with hypens, underscores, etc.]
-;;; Unless you change the constants, you must type at least three characters
-;;; for the word to be recognized. Only words longer than 6 characters are
-;;; saved.
-;;;
-;;; When you load this file, completion will be on. I suggest you use the
-;;; compiled version (because it is noticibly faster).
-;;;
-;;; M-X completion-mode toggles whether or not new words are added to the
-;;; database by changing the value of *completep*.
-;;;
-;;; SAVING/LOADING COMPLETIONS
-;;; Completions are automatically saved from one session to another
-;;; (unless *save-completions-p* or *completep* is nil).
-;;; Loading this file (or calling initialize-completions) causes EMACS
-;;; to load a completions database for a saved completions file
-;;; (default: ~/.completions). When you exit, EMACS saves a copy of the
-;;; completions that you
-;;; often use. When you next start, EMACS loads in the saved completion file.
-;;;
-;;; The number of completions saved depends loosely on
-;;; *saved-completions-decay-factor*. Completions that have never been
-;;; inserted via "complete" are not saved. You are encouraged to experiment
-;;; with different functions (see compute-completion-min-num-uses).
-;;;
-;;; Some completions are permanent and are always saved out. These
-;;; completions have their num-uses slot set to T. Use
-;;; add-permanent-completion to do this
-;;;
-;;; Completions are saved only if *completep* is T. The number of old
-;;; versions kept of the saved completions file is controlled by
-;;; *completion-file-versions-kept*.
-;;;
-;;; COMPLETE KEY OPTIONS
-;;; The complete function takes a numeric arguments.
-;;; control-u :: leave the point at the beginning of the completion rather
-;;; than the middle.
-;;; a number :: rotate through the possible completions by that amount
-;;; `-' :: same as -1 (insert previous completion)
-;;;
-;;; HOW THE DATABASE IS MAINTAINED
-;;; <write>
-;;;
-;;; UPDATING THE DATABASE MANUALLY
-;;; m-x kill-completion
-;;; kills the completion at point.
-;;; m-x add-completion
-;;; m-x add-permanent-completion
-;;;
-;;; UPDATING THE DATABASE FROM A SOURCE CODE FILE
-;;; m-x add-completions-from-buffer
-;;; Parses all the definition names from a C or LISP mode buffer and
-;;; adds them to the completion database.
-;;;
-;;; m-x add-completions-from-lisp-file
-;;; Parses all the definition names from a C or Lisp mode file and
-;;; adds them to the completion database.
-;;;
-;;; UPDATING THE DATABASE FROM A TAGS TABLE
-;;; m-x add-completions-from-tags-table
-;;; Adds completions from the current tags-table-buffer.
-;;;
-;;; HOW A COMPLETION IS FOUND
-;;; <write>
-;;;
-;;; STRING CASING
-;;; Completion is string case independent if case-fold-search has its
-;;; normal default of T. Also when the completion is inserted the case of the
-;;; entry is coerced appropriately.
-;;; [E.G. APP --> APPROPRIATELY app --> appropriately
-;;; App --> Appropriately]
-;;;
-;;; INITIALIZATION
-;;; The form `(initialize-completions)' initializes the completion system by
-;;; trying to load in the user's completions. After the first cal, further
-;;; calls have no effect so one should be careful not to put the form in a
-;;; site's standard site-init file.
-;;;
-;;;---------------------------------------------------------------------------
-;;;
-;;;
-\f
-;;;-----------------------------------------------
-;;; Porting Notes
-;;;-----------------------------------------------
-;;;
-;;; Should run on 18.49, 18.52, and 19.0
-;;; Tested on vanilla version.
-;;; This requires the standard cl.el file. It could easily rewritten to not
-;;; require it. It defines remove which is not in cl.el.
-;;;
-;;; FUNCTIONS BASHED
-;;; The following functions are bashed but it is done carefully and should not
-;;; cause problems ::
-;;; kill-region, next-line, previous-line, newline, newline-and-indent,
-;;; kill-emacs
-;;;
-;;;
-;;;---------------------------------------------------------------------------
-;;; Functions you might like to call
-;;;---------------------------------------------------------------------------
-;;;
-;;; add-completion string &optional num-uses
-;;; Adds a new string to the database
-;;;
-;;; add-permanent-completion string
-;;; Adds a new string to the database with num-uses = T
-;;;
-
-;;; kill-completion string
-;;; Kills the completion from the database.
-;;;
-;;; clear-all-completions
-;;; Clears the database
-;;;
-;;; list-all-completions
-;;; Returns a list of all completions.
-;;;
-;;;
-;;; next-completion string &optional index
-;;; Returns a completion entry that starts with string.
-;;;
-;;; find-exact-completion string
-;;; Returns a completion entry that exactly matches string.
-;;;
-;;; complete
-;;; Inserts a completion at point
-;;;
-;;; initialize-completions
-;;; Loads the completions file and sets up so that exiting emacs will
-;;; save them.
-;;;
-;;; save-completions-to-file &optional filename
-;;; load-completions-from-file &optional filename
-;;;
-;;;-----------------------------------------------
-;;; Other functions
-;;;-----------------------------------------------
-;;;
-;;; get-completion-list string
-;;;
-;;; These things are for manipulating the structure
-;;; make-completion string num-uses
-;;; completion-num-uses completion
-;;; completion-string completion
-;;; set-completion-num-uses completion num-uses
-;;; set-completion-string completion string
-;;;
-;;;
-\f
-;;;-----------------------------------------------
-;;; To Do :: (anybody ?)
-;;;-----------------------------------------------
-;;;
-;;; Implement Lookup and keyboard interface in C
-;;; Add package prefix smarts (for Common Lisp)
-;;; Add autoprompting of possible completions after every keystroke (fast
-;;; terminals only !)
-;;; Add doc. to texinfo
-;;;
-;;;
-;;;-----------------------------------------------
-;;; History ::
-;;;-----------------------------------------------
-;;; Sometime in '84 Brewster implemented a somewhat buggy version for
-;;; Symbolics LISPMs.
-;;; Jan. '85 Jim became enamored of the idea and implemented a faster,
-;;; more robust version.
-;;; With input from many users at TMC, (rose, craig, and gls come to mind),
-;;; the current style of interface was developed.
-;;; 9/87, Jim and Brewster took terminals home. Yuck. After
-;;; complaining for a while Brewester implemented a subset of the current
-;;; LISPM version for GNU Emacs.
-;;; 8/88 After complaining for a while (and with sufficient
-;;; promised rewards), Jim reimplemented a version of GNU completion
-;;; superior to that of the LISPM version.
-;;;
-;;;-----------------------------------------------
-;;; Acknowlegements
-;;;-----------------------------------------------
-;;; Cliff Lasser (cal@think.com), Kevin Herbert (kph@cisco.com),
-;;; eero@media-lab, kgk@cs.brown.edu, jla@ai.mit.edu,
-;;;
-;;;-----------------------------------------------
-;;; Change Log
-;;;-----------------------------------------------
-;;; From version 9 to 10
-;;; - Allowance for non-integral *completion-version* nos.
-;;; - Fix cmpl-apply-as-top-level for keyboard macros
-;;; - Fix broken completion merging (in save-completions-to-file)
-;;; - More misc. fixes for version 19.0 of emacs
-;;;
-;;; From Version 8 to 9
-;;; - Ported to version 19.0 of emacs (backcompatible with version 18)
-;;; - Added add-completions-from-tags-table (with thanks to eero@media-lab)
-;;;
-;;; From Version 7 to 8
-;;; - Misc. changes to comments
-;;; - new completion key bindings: c-x o, M->, M-<, c-a, c-e
-;;; - cdabbrev now checks all the visible window buffers and the "other buffer"
-;;; - `%' is now a symbol character rather than a separator (except in C mode)
-;;;
-;;; From Version 6 to 7
-;;; - Fixed bug with saving out .completion file the first time
-;;;
-;;; From Version 5 to 6
-;;; - removed statistics recording
-;;; - reworked advise to handle autoloads
-;;; - Fixed fortran mode support
-;;; - Added new cursor motion triggers
-;;;
-;;; From Version 4 to 5
-;;; - doesn't bother saving if nothing has changed
-;;; - auto-save if haven't used for a 1/2 hour
-;;; - save period extended to two weeks
-;;; - minor fix to capitalization code
-;;; - added *completion-auto-save-period* to variables recorded.
-;;; - added reenter protection to cmpl-record-statistics-filter
-;;; - added backup protection to save-completions-to-file (prevents
-;;; problems with disk full errors)
-\f
-;;;-----------------------------------------------
-;;; Requires
-;;; Version
-;;;-----------------------------------------------