1. Georg Brandl
  2. dotemacs

Commits

gbrandl  committed 0bb74b2

Remove unused modules.

  • Participants
  • Parent commits 4ba4af2
  • Branches default

Comments (0)

Files changed (18)

File bar-cursor.el

-;;; @(#) bar-cursor.el -- package used to switch block cursor to a bar
-;;; @(#) $Id: bar-cursor.el,v 1.1.1.1 2003/04/04 20:15:55 lolando Exp $
-
-;; This file is not part of Emacs
-
-;; Copyright (C) 2001 by Joseph L. Casadonte Jr.
-;; Author:          Joe Casadonte (emacs@northbound-train.com)
-;; Maintainer:      Joe Casadonte (emacs@northbound-train.com)
-;; Created:         July 1, 2001
-;; Keywords:        bar cursor overwrite
-;; Latest Version:  http://www.northbound-train.com/emacs.html
-
-;; COPYRIGHT NOTICE
-
-;; 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, 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; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-;;
-;;  Simple package to convert the block cursor into a bar cursor.  In
-;;  overwrite mode, the bar cursor changes back into a block cursor.
-;;  This is a quasi-minor mode, meaning that it can be turned on & off
-;;  easily though only globally (hence the quasi-)
-
-;;; Installation:
-;;
-;;  Put this file on your Emacs-Lisp load path and add the following to
-;;  your ~/.emacs startup file
-;;
-;;     (require 'bar-cursor)
-;;     (bar-cursor-mode 1)
-;;
-;;  To add a directory to your load-path, use something like the following:
-;;
-;;      (add-to-list 'load-path (expand-file-name "/some/load/path"))
-
-;;; Usage:
-;;
-;;  M-x `bar-cursor-mode'
-;;      Toggles bar-cursor-mode on & off.  Optional arg turns
-;;      bar-cursor-mode on iff arg is a positive integer.
-
-;;; To Do:
-;;
-;;  o Nothing, at the moment.
-
-;;; Credits:
-;;
-;;  The basis for this code comes from Steve Kemp by way of the
-;;  NTEmacs mailing list.
-
-;;; Comments:
-;;
-;;  Any comments, suggestions, bug reports or upgrade requests are welcome.
-;;  Please send them to Joe Casadonte (emacs@northbound-train.com).
-;;
-;;  This version of bar-cursor was developed and tested with NTEmacs
-;;  20.7.1 under Windows 2000 & NT 4.0 and Emacs 20.7.1 under Linux
-;;  (RH7).  Please, let me know if it works with other OS and versions
-;;  of Emacs.
-
-;;; Change Log:
-;;
-;;  see http://www.northbound-train.com/emacs/bar-cursor.log
-
-;;; **************************************************************************
-;;; **************************************************************************
-;;; **************************************************************************
-;;; **************************************************************************
-;;; **************************************************************************
-;;; Code:
-
-(eval-when-compile
-  ;; silence the old byte-compiler
-  (defvar byte-compile-dynamic nil)
-  (set (make-local-variable 'byte-compile-dynamic) t))
-
-;;; **************************************************************************
-;;; ***** version related routines
-;;; **************************************************************************
-(defconst bar-cursor-version
-  "$Revision: 1.1.1.1 $"
-  "Version number for 'bar-cursor' package.")
-
-;; ---------------------------------------------------------------------------
-(defun bar-cursor-version-number ()
-  "Return 'bar-cursor' version number."
-  (string-match "[0123456789.]+" bar-cursor-version)
-  (match-string 0 bar-cursor-version))
-
-;; ---------------------------------------------------------------------------
-(defun bar-cursor-display-version ()
-  "Display 'bar-cursor' version."
-  (interactive)
-  (message "bar-cursor version <%s>." (bar-cursor-version-number)))
-
-;;; **************************************************************************
-;;; ***** real functions
-;;; **************************************************************************
-(defvar bar-cursor-mode nil "Non-nil if 'bar-cursor-mode' is enabled.")
-
-;;; --------------------------------------------------------------------------
-;;;###autoload
-(defun bar-cursor-mode (&optional arg)
-  "Toggle use of 'bar-cursor-mode'.
-
-This quasi-minor mode changes cursor to a bar cursor in insert mode,
-and a block cursor in overwrite mode.  It may only be turned on and
-off globally, not on a per-buffer basis (hence the quasi- designation).
-
-Optional ARG turns mode on iff ARG is a positive integer."
-  (interactive "P")
-
-  ;; toggle on and off
-  (let ((old-mode bar-cursor-mode))
-	(setq bar-cursor-mode
-		  (if arg (or (listp arg)
-					  (> (prefix-numeric-value arg) 0))
-			(not bar-cursor-mode)))
-
-	(when (not (equal old-mode bar-cursor-mode))
-	  ;; enable/disable advice
-	  (if bar-cursor-mode
-		  (ad-enable-advice 'overwrite-mode 'after 'bar-cursor-overwrite-mode-ad)
-		(ad-disable-advice 'overwrite-mode 'after 'bar-cursor-overwrite-mode-ad))
-
-	  (ad-activate 'overwrite-mode)
-
-	  ;; set the initial cursor type now
-	  (bar-cursor-set-cursor)
-
-	  ;; add or remove to frame hook
-	  (if bar-cursor-mode
-		  (add-hook 'after-make-frame-functions 'bar-cursor-set-cursor)
-		(remove-hook 'after-make-frame-functions 'bar-cursor-set-cursor))
-	  )))
-
-;;;--------------------------------------------------------------------------
-(defadvice overwrite-mode (after bar-cursor-overwrite-mode-ad disable)
-  "Advice that controls what type of cursor is displayed."
-  (bar-cursor-set-cursor))
-
-;;;--------------------------------------------------------------------------
-(defun bar-cursor-set-cursor-type (cursor &optional frame)
-  "Set the cursor-type for the named frame.
-
-CURSOR is the name of the cursor to use (bar or block -- any others?).
-FRAME is optional frame to set the cursor for; current frame is used
-if not passed in."
-  (interactive)
-  (if (not frame)
-	  (setq frame (selected-frame)))
-
-  ;; Do the modification.
-  (modify-frame-parameters frame
-	(list (cons 'cursor-type cursor))))
-
-;;; --------------------------------------------------------------------------
-(defun bar-cursor-set-cursor (&optional frame)
-  "Set the cursor-type according to the insertion mode.
-
-FRAME is optional frame to set the cursor for; current frame is used
-if not passed in."
-  (if (and bar-cursor-mode (not overwrite-mode))
-	  (bar-cursor-set-cursor-type 'bar frame)
-	(bar-cursor-set-cursor-type 'block frame)))
-
-;;; **************************************************************************
-;;; ***** we're done
-;;; **************************************************************************
-(provide 'bar-cursor)
-
-;;; bar-cursor.el ends here
-;;; **************************************************************************
-;;;; *****  EOF  *****  EOF  *****  EOF  *****  EOF  *****  EOF  *************

File column-marker.el

-;;; column-marker.el --- Highlight certain character columns
-;; 
-;; Filename: column-marker.el
-;; Description: Highlight certain character columns
-;; Author: Rick Bielawski <rbielaws@i1.net>
-;; Maintainer: Rick Bielawski <rbielaws@i1.net>
-;; Created: Tue Nov 22 10:26:03 2005
-;; Version: 
-;; Last-Updated: Fri Jan 22 11:28:48 2010 (-0800)
-;;           By: dradams
-;;     Update #: 312
-;; Keywords: tools convenience highlight
-;; Compatibility: GNU Emacs 21, GNU Emacs 22, GNU Emacs 23
-;; 
-;; Features that might be required by this library:
-;;
-;;   None
-;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; 
-;;; Commentary: 
-;; 
-;; Highlights the background at a given character column.
-;; 
-;; Commands `column-marker-1', `column-marker-2', and
-;; `column-marker-3' each highlight a given column (using different
-;; background colors, by default).
-;;
-;; - With no prefix argument, each highlights the current column
-;;   (where the cursor is).
-;;
-;; - With a non-negative numeric prefix argument, each highlights that
-;;   column.
-;;
-;; - With plain `C-u' (no number), each turns off its highlighting.
-;;
-;; - With `C-u C-u', each turns off all column highlighting.
-;;
-;; If two commands highlight the same column, the last-issued
-;; highlighting command shadows the other - only the last-issued
-;; highlighting is seen.  If that "topmost" highlighting is then
-;; turned off, the other highlighting for that column then shows
-;; through.
-;;
-;; Examples:
-;;
-;; M-x column-marker-1 highlights the column where the cursor is, in
-;; face `column-marker-1'.
-;;
-;; C-u 70 M-x column-marker-2 highlights column 70 in face
-;; `column-marker-2'.
-;;
-;; C-u 70 M-x column-marker-3 highlights column 70 in face
-;; `column-marker-3'.  The face `column-marker-2' highlighting no
-;; longer shows.
-;;
-;; C-u M-x column-marker-3 turns off highlighting for column-marker-3,
-;; so face `column-marker-2' highlighting shows again for column 70.
-;;
-;; C-u C-u M-x column-marker-1 (or -2 or -3) erases all column
-;; highlighting.
-;;
-;; These commands use `font-lock-fontify-buffer', so syntax
-;; highlighting (`font-lock-mode') must be turned on.  There might be
-;; a performance impact during refontification.
-;;
-;;
-;; Installation: Place this file on your load path, and put this in
-;; your init file (`.emacs'):
-;;
-;; (require 'column-marker)
-;;
-;; Other init file suggestions (examples):
-;;
-;; ;; Highlight column 80 in foo mode.
-;; (add-hook 'foo-mode-hook (lambda () (interactive) (column-marker-1 80)))
-;;
-;; ;; Use `C-c m' interactively to highlight with face `column-marker-1'.
-;; (global-set-key [?\C-c ?m] 'column-marker-1)
-;;
-;;
-;; Please report any bugs!
-;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; 
-;;; Change log:
-;;
-;; 2009/12/10 dadams
-;;     column-marker-internal: Quote the face.  Thx to Johan Bockgård.
-;; 2009/12/09 dadams
-;;     column-marker-find: fset a symbol to the function, and return the symbol.
-;; 2008/01/21 dadams
-;;     Renamed faces by dropping suffix "-face".
-;; 2006/08/18 dadams
-;;     column-marker-create: Add newlines to doc-string sentences.
-;; 2005/12/31 dadams
-;;     column-marker-create: Add marker to column-marker-vars inside the defun,
-;;       so it is done in the right buffer, updating column-marker-vars buffer-locally.
-;;     column-marker-find: Corrected comment.  Changed or to progn for clarity.
-;; 2005/12/29 dadams
-;;     Updated wrt new version of column-marker.el (multi-column characters).
-;;     Corrected stray occurrences of column-marker-here to column-marker-1.
-;;     column-marker-vars: Added make-local-variable.
-;;     column-marker-create: Changed positive to non-negative.
-;;     column-marker-internal: Turn off marker when col is negative, not < 1.
-;; 2005-12-29 RGB
-;;     column-marker.el now supports multi-column characters.
-;; 2005/11/21 dadams
-;;     Combined static and dynamic. 
-;;     Use separate faces for each marker.  Different interactive spec.
-;; 2005/10/19 RGB
-;;     Initial release of column-marker.el.
-;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;; 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, 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; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
-;; Floor, Boston, MA 02110-1301, USA.
-;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; 
-;;; Code:
-
-;;;;;;;;;;;;;;;;;;;;;;
-
-
-(defface column-marker-1 '((t (:background "gray")))
-  "Face used for a column marker.  Usually a background color."
-  :group 'faces)
-
-(defvar column-marker-1-face 'column-marker-1
-    "Face used for a column marker.  Usually a background color.
-Changing this directly affects only new markers.")
-
-(defface column-marker-2 '((t (:background "cyan3")))
-  "Face used for a column marker.  Usually a background color."
-  :group 'faces)
-
-(defvar column-marker-2-face 'column-marker-2
-    "Face used for a column marker.  Usually a background color.
-Changing this directly affects only new markers." )
-
-(defface column-marker-3 '((t (:background "orchid3")))
-  "Face used for a column marker.  Usually a background color."
-  :group 'faces)
-
-(defvar column-marker-3-face 'column-marker-3
-    "Face used for a column marker.  Usually a background color.
-Changing this directly affects only new markers." )
-
-(defvar column-marker-vars ()
-  "List of all internal column-marker variables")
-(make-variable-buffer-local 'column-marker-vars) ; Buffer local in all buffers.
-
-(defmacro column-marker-create (var &optional face)
-  "Define a column marker named VAR.
-FACE is the face to use.  If nil, then face `column-marker-1' is used."
-  (setq face (or face 'column-marker-1))
-  `(progn
-     ;; define context variable ,VAR so marker can be removed if desired
-     (defvar ,var ()
-       "Buffer local. Used internally to store column marker spec.")
-     ;; context must be buffer local since font-lock is 
-     (make-variable-buffer-local ',var)
-     ;; Define wrapper function named ,VAR to call `column-marker-internal'
-     (defun ,var (arg)
-       ,(concat "Highlight column with face `" (symbol-name face)
-                "'.\nWith no prefix argument, highlight current column.\n"
-                "With non-negative numeric prefix arg, highlight that column number.\n"
-                "With plain `C-u' (no number), turn off this column marker.\n"
-                "With `C-u C-u' or negative prefix arg, turn off all column-marker highlighting.")
-       (interactive "P")
-       (unless (memq ',var column-marker-vars) (push ',var column-marker-vars))
-       (cond ((null arg)          ; Default: highlight current column.
-              (column-marker-internal ',var (1+ (current-column)) ,face))
-             ((consp arg)
-              (if (= 4 (car arg))
-                  (column-marker-internal ',var nil) ; `C-u': Remove this column highlighting.
-                (dolist (var column-marker-vars)
-                  (column-marker-internal var nil)))) ; `C-u C-u': Remove all column highlighting.
-             ((and (integerp arg) (>= arg 0)) ; `C-u 70': Highlight that column.
-              (column-marker-internal ',var (1+ (prefix-numeric-value arg)) ,face))
-             (t           ; `C-u -40': Remove all column highlighting.
-              (dolist (var column-marker-vars)
-                (column-marker-internal var nil)))))))
-
-(defun column-marker-find (col)
-  "Defines a function to locate a character in column COL.
-Returns the function symbol, named `column-marker-move-to-COL'."
-  (let ((fn-symb  (intern (format "column-marker-move-to-%d" col))))
-    (fset `,fn-symb
-          `(lambda (end)
-             (let ((start (point)))
-               (when (> end (point-max)) (setq end (point-max)))
-
-               ;; Try to keep `move-to-column' from going backward, though it still can.
-               (unless (< (current-column) ,col) (forward-line 1))
-
-               ;; Again, don't go backward.  Try to move to correct column.
-               (when (< (current-column) ,col) (move-to-column ,col))
-
-               ;; If not at target column, try to move to it.
-               (while (and (< (current-column) ,col) (< (point) end)
-                           (= 0 (+ (forward-line 1) (current-column)))) ; Should be bol.
-                 (move-to-column ,col))
-
-               ;; If at target column, not past end, and not prior to start,
-               ;; then set match data and return t.  Otherwise go to start
-               ;; and return nil.
-               (if (and (= ,col (current-column)) (<= (point) end) (> (point) start))
-                   (progn (set-match-data (list (1- (point)) (point)))
-                          t)            ; Return t.
-                 (goto-char start)
-                 nil))))                ; Return nil.
-    fn-symb))
-
-(defun column-marker-internal (sym col &optional face)
-  "SYM is the symbol for holding the column marker context.
-COL is the column in which a marker should be set.
-Supplying nil or 0 for COL turns off the marker.
-FACE is the face to use.  If nil, then face `column-marker-1' is used."
-  (setq face (or face 'column-marker-1))
-  (when (symbol-value sym)   ; Remove any previously set column marker
-    (font-lock-remove-keywords nil (symbol-value sym))
-    (set sym nil))
-  (when (or (listp col) (< col 0)) (setq col nil)) ; Allow nonsense stuff to turn off the marker
-  (when col                             ; Generate a new column marker
-    (set sym `((,(column-marker-find col) (0 ',face prepend t))))
-    (font-lock-add-keywords nil (symbol-value sym) t))
-  (font-lock-fontify-buffer))
-
-;; If you need more markers you can create your own similarly.
-;; All markers can be in use at once, and each is buffer-local,
-;; so there is no good reason to define more unless you need more
-;; markers in a single buffer.
-(column-marker-create column-marker-1 column-marker-1-face)
-(column-marker-create column-marker-2 column-marker-2-face)
-(column-marker-create column-marker-3 column-marker-3-face)
-
-;;;###autoload
-(autoload 'column-marker-1 "column-marker" "Highlight a column." t)
-
-;;;;;;;;;;;;;;;;;;
-
-(provide 'column-marker)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; column-marker.el ends here

File completion-ui.el

-
-;;; completion-ui.el --- in-buffer completion user interface
-
-
-;; Copyright (C) 2006-2008 Toby Cubitt
-
-;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.9
-;; Keywords: completion, ui, user interface
-;; URL: http://www.dr-qubit.org/emacs.php
-
-
-;; This file is NOT part of Emacs.
-;;
-;; 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., 51 Franklin Street, Fifth Floor, Boston,
-;; MA 02110-1301, USA.
-
-
-;;; Commentary:
-;;
-;; This package provides a user-interface for in-buffer text
-;; completion. It doesn't find completions itself. Instead, a completion
-;; package can simply set the `completion-function' variable to a
-;; function that takes two arguments, a string PREFIX and an integer
-;; MAXNUM, and returns a list of at most MAXNUM completion candidates
-;; for PREFIX. Completion-UI does the rest.
-;;
-;; That's it! Completion-UI, the auto-completion minor mode, and user
-;; customizations take care of the rest. (Avoid the temptation to set
-;; completion-UI customization variables from Elisp code to alter its
-;; behaviour. The user knows what they want better than you do!)
-;;
-;; Examples are available on the Emacs wiki, at:
-;; www.emacswiki.org/cgi-bin/wiki/CompletionUI
-;;
-;; Why use completion-UI? Typically, a lot of code in packages providing
-;; some kind of text completion deals with the user interface. The
-;; ultimate goal is that all packages providing in-buffer (and possibly
-;; one day also mini-buffer) completion should use this package to
-;; provide a common user interface, freeing them to concentrate on
-;; finding the completion candidates in the first place. The Elisp
-;; programmer benfits by not having to reinvent the wheel, and the Emacs
-;; user benefits by having a standard yet highly customizable
-;; user-interface that they can customize once and for all to to suit
-;; their preferences, for all completion mechanisms they use.
-;;
-;; Various completion user-interfaces are provided, all of which can be
-;; individually enabled, disabled and extensively tweaked via
-;; customization variables:
-;;
-;; * Dynamic completion: provisionally insert the first available
-;;   completion candidate into the buffer.
-;;
-;; * Completion hotkeys: single-key selection of a completion
-;;   candidate.
-;;
-;; * Cycling: cycle through completion candidates.
-;;
-;; * Tab-completion: "traditional" expansion to longest common
-;;   substring.
-;;
-;; * Help-echo: display a list of completion candidates in the
-;;   echo-area.
-;;
-;; * Tooltip: display a list of completion candidates in a tool-tip
-;;   located below the point, from which completions can be selected.
-;;
-;; * Pop-up frame: display a list of completion candidates in a pop-up
-;;   frame located below the point, which can be toggled between display
-;;   some or all completions, and from which completions can be
-;;   selected.
-;;
-;; * Completion menu: allow completion candidates to be selected from
-;;   a drop-down menu located below the point.
-;;
-;; * Completion browser: browse through all possible completion
-;;   candidates in a hierarchical deck-of-cards menu located below the
-;;   point.
-;;
-;; Completion-UI also provides a new minor mode, called
-;; auto-completion-mode. When enabled, Emacs will automatically complete
-;; words as they are typed, using the `completion-function' to find
-;; completion candidates. The same customization variables determine how
-;; those candidates are displayed and can be selected. This works
-;; particularly well with dynamic completion (see above).
-;;
-;; This package will work alongside the auto-overlays package if it's
-;; available, but does not require it.
-
-
-
-;;; Change Log:
-;;
-;; Version 0.9
-;; * added `completion-includes-prefix' variable to indicate that completions
-;;   returned by `completion-function' include the prefix
-;; * added `completion-replaces-prefix' variable to indicate that completions
-;;   should replace the prefix when they're accepted, and made changes to
-;;   almost all of the user-interface functions to cope with this non-prefix
-;;   completion (thanks to Henry Weller for helpful discussions about this)
-;; * move point to appropriate position in parent frame when cycling through
-;;   completions in pop-up frame
-;; * added `completion-show-browser-menu' command
-;;
-;; Version 0.8.2
-;; * prevented `completion-show-tooltip' from moving mouse unless absolutely
-;;   necessary (thanks to Martin Pohlack for reporting this)
-;; * modified `completion-show-tooltip' to ensure tooltip is cancelled before
-;;   (re)displaying it, otherwise `x-show-tip' "magically" moves it to the top
-;;   of the frame! (thanks to Martin Pohlack for reporting this)
-;; * added option to highlight longest common prefix in a dynamic completion
-;;   (thanks to Vagn Johansen for the suggestion)
-;; * actually make use of `completion-popup-frame-function' variable!
-;; * fixed bug in some calls to `completion-reject-functions' that only passed
-;;   two arguments instead of three (thanks to Vagn Johansen for reporting
-;;   this)
-;;
-;; Version 0.8,1
-;; * fix `completion-define-word-syntax-binding' so it creates key binding in
-;;   `auto-completion-dynamic-map' as it should
-;; * fix `completion-setup-overlay' to assign correct keymap to 'keymap
-;;   property, depending on whether `auto-completion-mode' is enabled or not
-;;
-;; Version 0.8
-;; * give completion overlay a non-nil end-advance property, because...
-;; * ...keymap property works for zero-length overlays with non-nil
-;;   end-advance since Emacs 22! So disable work-around from that versions on.
-;;
-;; Version 0.7.5
-;; * added `completion-simulate-overlay-bindings' function that can
-;;   automatically create key bindings to simulate overlay keymap bindings
-;;   using the `completion-run-if-within-overlay' hack
-;;
-;; Version 0.7.4
-;; * split `completion-self-insert' into two: one function, the new
-;;   `completion-self-insert', deals with completion-related stuff if
-;;   auto-completion-mode is disabled, the other,
-;;   `auto-completion-self-insert', does auto-completion as
-;;   before. This allows individual printable characters to invoke
-;;   auto-completion without auto-completion-mode being enabled.
-;; * `auto-completion-self-insert' is now only directly bound to
-;;   printable characters in auto-completion-map
-;; * overlay keymap now binds printable characters to the new
-;;   `completion-self-insert' (which hands off to
-;;   `auto-completion-self-insert' if auto-completion is enabled)
-;;
-;; Version 0.7.3
-;; * fixed bug in `completion-popup-frame-toggle-show-all'
-;; * fixed bug in definition of `completion-tooltip-face'
-;;
-;; Version 0.7.2
-;; * prevent `complete-in-buffer' from auto-displaying the tooltip/menu/pop-up
-;;   frame if there are no completions (otherwise Emacs CVS seems to crash!)
-;; * bug fixes to key bindings and `completion-tab-complete'
-;; * bug fixes to pop-up frames
-;;
-;; Version 0.7.1
-;; * minor key binding fixes
-;; * `complete-in-buffer' can now take an optional prefix argument to override
-;;   automatically determined prefix
-;; * `completion-self-insert' can now take an optional argument that causes
-;;   `auto-completion-syntax-override-alist' to be ignored, as can
-;;   `completion-define-word-constituent-binding'
-;; * bug fixes to `completion-self-insert'
-;; * switched ordering of `auto-completion[-override]-syntax-alist' entries
-;;   back to something closer to old ordering
-;;
-;; Version 0.7
-;; * modified core `complete-in-buffer', `complete-word-at-point',
-;;   `completion-self-insert' and `completion-backward-delete' functions
-;;   to allow `completion-prefix-function' to properly take over prefix
-;;   finding
-;; * created default `completion-prefix' function
-;; * modified same core functions so that completion behaviour is more
-;;   intelligent, especially when a character is inserted within a
-;;   completion overlay
-;; * `completion-overwrite' option now controls whether completions
-;;   over-write the remainder of the word at the point or not
-;; * renamed `completion-dynamic-*syntax-alist' to
-;;   `auto-completion-*syntax-alist' and modified their format somewhat;
-;;   behaviour now accessed through interface macros
-;; * added new pop-up frame completion method (thanks to anon. on the
-;;   Emacs wiki for the suggestion)
-;; * auto-show can now display one out of the tooltip, completion menu,
-;;   or pop-up frame
-;; * `completion-tooltip-delay' and `completion-auto-show-menu' options
-;;   subsumed into `completion-auto-show' and
-;;   `completion-auto-show-delay'
-;; * RET binding now respects customization options
-;;
-;; Version 0.6.5
-;; * bug-fixes to interactive definitions
-;; * moved modification hook setting to end of file
-;;
-;; Version 0.6.4
-;; * defined properties to make delete-selection-mode work correctly
-;;   (thanks to Sivaram for drawing my attention to this)
-;; * minor improvement to text displayed in completion browser bucket
-;;   menu entries
-;;
-;; Version 0.6.3
-;; * fixed M-<space> bindings so that prefix argument is passed to
-;;   `completion-reject', and fixed C-<space> bindings
-;;
-;; Version 0.6.2
-;; * modified the default `completion-dynamic-syntax-alist' to make
-;;   parentheses behave like punctuation
-;; * minor bug-fix to `completion-show-menu-if-within-overlay'
-;; * fixed `completion-self-insert' again so that it works if called with
-;;   an explicit char (auto-fill will not work in that case)
-;; * fixed `complete-dynamic' so that the completion overlay ends up in
-;;   the right place even when modification hooks cause text to be
-;;   inserted in the buffer during its execution
-;;
-;; Version 0.6.1
-;; * modified define-minor-mode usage for auto-completion-mode to work in
-;;   older Emacs versions
-;; * fixed `completion-self-insert' so that auto-fill works again
-;; * if command remapping isn't supported, attempt to simulate it more
-;;   effectively for deletion commands
-;;
-;; Version 0.6
-;; * added `completion-prefix' and `completion-tooltip' variables to
-;;   allow overriding of default methods for determining prefix at point
-;;   and constructing tooltip text
-;; * fixed bugs related to backwards-deletion (thanks to Maciej
-;;   Katafiasz for pointing some of these out)
-;; * added optional arguements to `completion-self-insert' to allow
-;;   automatically determined character and syntax to be overridden, and
-;;   created key bindings to insert characters as word constituents
-;; * modified `completion-backward-delete', created corresponding
-;;   `completion-delete' function, and defined a whole host of deletion
-;;   and kill commands that are substituted for the standard ones
-;; * added convenience function
-;;   `completion-define-word-constituent-binding' for defining bindings
-;;   to insert characters as word-constituents
-;;
-;;
-;; Version 0.5.2
-;; * fixed tooltip face issues, which included defining a new
-;;   `completion-tooltip-face'
-;; * implemented better method of positioning tooltip, avoiding moving
-;;   the mouse (thanks to Nikolaj Schumacher for this!)
-;;
-;; Version 0.5.1
-;; * fixed small bug in `completion-self-insert' (thanks to Nikolaj
-;;   Schumacher for pointing it out)
-;;
-;; Version 0.5
-;; Modifications arising from discussions with rms:
-;; * removed `completion-define-minor-mode' macro; to use completion-UI,
-;;   `completion-function' should just be set appropriately
-;; * auto-completion is now a separate minor mode
-;; * renamed various variables and functions
-;;
-;; Version 0.4.1
-;; * small but important bug-fix to `completion-accept'
-;;
-;; Version 0.4
-;; * accept and reject hooks now called with two or three arguments
-;;   instead of one: the prefix, the full word (this is what was passed
-;;   previously) and possibly the interactive prefix argument.
-;; * moved some anonymous commands into named functions to sanitize
-;;   key-bindings
-;;
-;; Version 0.3.13
-;; * Tried to work around annoying `completion-select' bug
-;;
-;; Version 0.3.12
-;; * added `completion-backward-delete-delay' customization option
-;;
-;; Version 0.3.11
-;; * finally figured out how to prevent list of completions displayed in
-;;   echo area from being logged
-;;
-;; Version 0.3.10
-;; * fixed start-of-word behaviour in `completion-self-insert'
-;;
-;; Version 0.3.9
-;; * `completion-select' now uses the `completion-trap-recursion'
-;;   variable, instead of testing if 'trap-recursion is bound
-;;
-;; Version 0.3.8
-;; * fixed `completion-run-if-within-overlay' so it doesn't error if
-;;   there's no "normal" binding for the key sequence used to invoke it
-;; * defined a new `completion-trap-recursion' variable in case the
-;;   symbol trap-recursion is bound outside
-;;   `completion-run-if-within-overlay'
-;;
-;; Version 0.3.7
-;; * fixed M-<space> binding so it's only active within an overlay
-;;
-;; Version 0.3.6
-;; * fixed bug in `completion-define-minor-mode'
-;;
-;; Version 0.3.5
-;; * added eval-when-compile to prevent bogus compilation errors
-;;
-;; Version 0.3.4
-;; * added function to `after-change-functions' to hide tooltip
-;; * made self-insert behaviour alists more flexible
-;; * minor fix to `completion-cycle' to leave point at end of word if
-;;   dynamic completion is disabled
-;; * `completion-hotkey-list' no longer a customization option, since it
-;;   must be set *before* completion-ui.el is loaded
-;;
-;; Version 0.3.3
-;; * minor bug-fix to `completion-self-insert'
-;; * removed cl dependency
-;;
-;; Version 0.3.2
-;; * bug fixes
-;; * incorporated compatability code
-;;
-;; Version 0.3.1
-;; * bug fixes
-;;
-;; Version 0.3
-;; * incorporated a lot of code from predictive.el
-;; * rewrote things so that all a package needs to do is set
-;;   the `completion-function' variable
-;; * `completon-overlay-at-point' is kludgy no more
-;;
-;; Version 0.2.1
-;; * added commentary
-;; * prevented any attempt to display tooltips and menus when not
-;;   running X
-;;
-;; Version 0.2
-;; * bug fixes (thanks to Mark Zonzon for patch)
-;; * added `completion-min-chars' and `completion-delay' options
-;;   (thanks to Jin Tong for suggestions)
-;; * renamed to `completion-ui.el'
-;;
-;; Version 0.1
-;; * initial release
-
-
-;;; Code:
-
-(provide 'completion-ui)
-(require 'auto-overlay-common nil t)
-
-
-
-
-;;; ============================================================
-;;;                    Customization variables
-
-(defgroup completion-ui nil
-  "Completion user interface."
-  :group 'convenience)
-
-
-(defcustom completion-max-candidates 10
-  "*Maximum number of completion candidates to offer."
-  :group 'completion-ui
-  :type 'integer)
-
-
-(defcustom completion-resolve-behaviour 'accept
-  "*What to do with unfinished completions elsewhere in the buffer:
-
-  'leave:   leave the old completions pending
-  'accept:  automatically accept the old completions
-  'reject:  automatically reject the old completions
-  'ask:     ask what to do with the old completions"
-  :group 'completion-ui
-  :type '(choice (const :tag "leave" leave)
-		 (const :tag "accept" accept)
-		 (const :tag "reject" reject)
-		 (const :tag "ask" ask)))
-
-
-(defcustom completion-overwrite t
-  "*When non-nil, completing in the middle of a word over-writes
-the rest of the word. `completion-word-thing' determines what is
-considered a word."
-  :group 'completion-ui
-  :type 'boolean)
-
-
-(defcustom completion-auto-show 'tooltip
-  "*Display completion tooltip/menu/pop-up frame automatically.
-When null, nothing is auto-displayed. When set to 'tooltip, 'menu
-or 'pop-up, the corresponding completion interface is displayed
-automatically, after a delay of `completion-auto-show-delay' if
-one is set."
-  :group 'completion-ui
-  :type '(choice (const :tag "none" nil)
-		 (const tooltip)
-		 (const menu)
-		 (const :tag "pop-up frame" pop-up))
-)
-
-
-(defcustom completion-auto-show-delay 3
-  "*Number of seconds to wait after completion is invoked
-before auto-displaying tooltip/menu/pop-up frame when
-`completion-auto-show' is enabled."
-  :group 'completion-ui
-  :type '(choice (const :tag "Off" nil)
-		 (float :tag "On")))
-
-
-
-;;; ===== Auto-completion customizations =====
-
-(defcustom auto-completion-min-chars nil
-  "*Minimum number of characters before completions are offered."
-  :group 'completion-ui
-  :type '(choice (const :tag "Off" nil)
-		 (integer :tag "On")))
-
-
-(defcustom auto-completion-delay nil
-  "*Number of seconds to wait before activating completion mechanisms
-in auto-completion mode."
-  :group 'completion-ui
-  :type '(choice (const :tag "Off" nil)
-		 (float :tag "On")))
-
-
-(defcustom auto-completion-backward-delete-delay 0.1
-  "*Number of seconds to wait before activating completion mechanisms
-after deleting backwards in auto-completion mode."
-  :group 'completion-ui
-  :type 'float)
-
-
-(defcustom auto-completion-syntax-alist '(reject . word)
-  "*Associates character syntax with completion behaviour.
-Used by the `auto-completion-self-insert' function to decide what
-to do based on a typed character's syntax.
-
-The predefined choices can be used to set two syntax-dependent
-completion behaviours: how the prefix is chosen when characters
-are typed, and how provisional completions are accepted. These
-are specified by a cons cell, whose cdr is either \"type
-normally\" or \"punctuation accepts\", and controls how
-completions are accepted, and whose car is either \"word\" or
-\"string\", and controls how the prefix is chosen.
-
-If the car is set to \"type normally\", the provisional
-completions that appear as you type are only accepted if you call
-`completion-accept' manually. You are free to ignore them
-entirely and type normally. If the car is instead set to
-\"punctuation accepts\", the provisional completions are
-automatically accepted whenever you type any punctuation or
-whitespace character (as defined by the buffers' syntax
-table). For example, hitting SPC will usually accept the current
-provisional completion and insert a space after it. Once your
-fingers get used to it, this can allow you to type faster as you
-can quickly accept a completion and move onto the next
-word. However, you can no longer entirely ignore the completions
-and type normally, since you may accidentally accept a completion
-you didn't want.
-
-If the cdr is set to \"word\", typing a word-constituent
-character (as defined by the buffers' syntax table) will cause
-the part of the word before point to be completed. That is, the
-completion prefix will be all those characters in the word at
-point that come before the point (`completion-word-thing'
-determines which characters form the word). If the cdr is instead
-set to \"string\", typing a word-constituent character will
-complete the current string that has been built up by typing
-characters. That is, the prefix will consist of the characters
-you've typed sequentially in the buffer. The two behaviours
-usually only differ if you insert characters in the middle or at
-the end of an existing word.
-
-
-Customizing the behaviour for each syntax individually gives more
-fine-grained control over the syntax-dependent completion
-behaviour. In this case, the value of
-`auto-completion-syntax-alist' must be an alist associating
-syntax descriptors (characters) with behaviours (two-element
-lists).
-
-The first element of the list must be one of symbols 'accept,
-'reject or 'add. The first two again have the same meaning as in
-the predefined behaviours, whereas 'add causes characters with
-that syntax to be added to the current completion prefix.
-
-The second element of the list must be one of the symbols 'word,
-'string or 'none. 'word and 'string have the same meaning as in
-the predefined behaviours, though they now apply only to one
-syntax class, whereas 'none prevents characters with that syntax
-from invoking auto-completion.
-
-
-When `auto-completion-syntax-alist' is set from Lisp code, in
-addition to the symbol values described above the list entries
-can also be functions which return one of those symbols. The list
-can also have an additional third entry, which determines whether
-the typed character is inserted or not: the character is inserted
-if it is non-nil, not if it is nil. Again if the third entry is a
-function, its return value determines the insertion behaviour."
-  :group 'completion-ui
-  :type '(choice
-	  (cons :tag "Predefined"
-		(choice :tag "Acceptance behaviour"
-			(const :tag "type normally" reject)
-			(const :tag "punctuation accepts" accept))
-		(choice :tag "Completion behaviour"
-			(const word)
-			(const string)))
-	  (alist :tag "Custom"
-		 :key-type character
-		 :value-type (list
-			      (choice (const accept)
-				      (const reject)
-				      (const add))
-			      (choice (const word)
-				      (const string)
-				      (const none))))))
-
-
-(defcustom auto-completion-override-syntax-alist
-  '((?0 . (reject none))
-    (?1 . (reject none))
-    (?2 . (reject none))
-    (?3 . (reject none))
-    (?4 . (reject none))
-    (?5 . (reject none))
-    (?6 . (reject none))
-    (?7 . (reject none))
-    (?8 . (reject none))
-    (?9 . (reject none)))
-  "*Alist associating characters with completion behaviour.
-Overrides the default behaviour defined by the character's syntax
-in `auto-completion-syntax-alist'. The format is the same as for
-`completion-dynamic-synax-alist', except that the alist keys are
-characters rather than syntax descriptors."
-  :group 'completion-ui
-  :type '(alist :key-type (choice character (const :tag "default" t))
-		:value-type (list (choice (const :tag "accept" accept)
-					  (const :tag "reject" reject)
-					  (const :tag "add" add))
-				  (choice (const :tag "string" string)
-					  (const :tag "word" word)
-					  (const :tag "none" none)))))
-
-
-
-;;; ===== Dynamic completion customizations =====
-
-(defcustom completion-use-dynamic t
-  "*Enable dynamic completion.
-Dynamic completion directly inserts the first completion into the
-buffer without further action required by the user. It is still a
-provisional completion, so until it is accepted all the usual
-mechanisms for selecting completions are still available."
-  :group 'completion-ui
-  :type 'boolean)
-
-
-(defcustom completion-dynamic-highlight-common-prefix t
-  "*Highlight longest common prefix in dynamic completion."
-  :group 'completion-ui
-  :type 'boolean)
-
-
-(defface completion-dynamic-face
-  '((((class color) (background dark))
-     (:background "blue" :foreground "white"))
-    (((class color) (background light))
-     (:background "orange" :foreground "black")))
-  "*Face used for provisional completions during dynamic completion.
-Also used to highlight selected completions in tooltips and
-pop-up frames."
-  :group 'completion-ui)
-
-
-(defface completion-dynamic-common-prefix-face
-  '((((class color) (background dark))
-     (:background "dodger blue" :foreground "white"))
-    (((class color) (background light))
-     (:background "gold" :foreground "black")))
-  "*Face used to highlight common prefix in dynamic completion."
-  :group 'completion-ui)
-
-
-
-;; ===== Hotkey customizations =====
-
-(defcustom completion-use-hotkeys t
-  "*Enable completion hotkeys (single-key selection of completions)."
-  :group 'completion-ui
-  :type 'boolean)
-
-
-;; not a defcustom, since setting it after loading completion-ui.el (as
-;; defcustom typically will) does not work
-(defvar completion-hotkey-list
-  '([?0] [?1] [?2] [?3] [?4] [?5] [?6] [?7] [?8] [?9])
-  "*List of keys (vectors) to use for selecting completions
-when `completion-use-hotkeys' is enabled. This variable must be
-set *before* completion-ui.el is laoded to take effect.")
-
-
-
-;;; ===== Echo-text customizations =====
-
-(defcustom completion-use-echo t
-  "*Display completions in echo area."
-  :group 'completion-ui
-  :type 'boolean)
-
-
-
-;;; ===== Tooltip customizations =====
-
-(defcustom completion-tooltip-timeout 86400
-  "*Number of seconds for wihch to display completion tooltip.
-Unfortunately, there is no way to display a tooltip indefinitely
-in Emacs. You can work around this by using a very large number."
-  :group 'completion-ui
-  :type 'integer)
-
-
-(defcustom completion-tooltip-offset '(0 . 0)
-   "Pixel offset for tooltip.
-This sometimes needs to be tweaked manually to get tooltip in
-correct position on different window systems."
-  :group 'completion-ui
-  :type '(cons (integer :tag "x") (integer :tag "y")))
-
-
-(defface completion-tooltip-face
-  `((t . (:background ,(or (face-attribute 'menu :background) "white")
-	  :foreground ,(or (face-attribute 'menu :foreground) "black"))))
-  "*Face used in tooltip. Only foreground and background attributes are\
- used."
-  :group 'completion-ui)
-
-
-
-;;; ===== Completion menu customizations =====
-
-(defcustom completion-menu-offset '(0 . 0)
-  "*Pixel offset for completion menus.
-This sometimes needs to be tweaked manually to get completion
-menus in correct position on different window systems."
-  :group 'completion-ui
-  :type '(cons (integer :tag "x") (integer :tag "y")))
-
-
-(defcustom completion-browser-max-items 25
-  "*Maximum number of completions to display
-in a completion browser submenu."
-  :group 'predictive
-  :type 'integer)
-
-
-(defcustom completion-browser-buckets 'balance
-  "*Policy for choosing number of buckets in completion browser:
-
-balance:  balance number of buckets and size of content
-maximize: maximize number of buckets, minimize size of contents
-mininize: minimize number of buckets, maximize size of contents"
-  :group 'predictive
-  :type '(choice (const :tag "balance" balance)
-		 (const :tag "maximize" max)
-		 (const :tag "minimize" min)))
-
-
-
-;;; ===== Pop-up frame customizations =====
-
-(defcustom completion-auto-popup-frame t
-  "*Display completion pop-up frame automatically."
-  :group 'completion-ui
-  :type 'boolean)
-
-
-(defcustom completion-popup-frame-max-height 20
-  "*Maximum height of a popup frame"
-  :group 'completion-ui
-  :type 'integer)
-
-
-(defcustom completion-popup-frame-offset '(0 . 0)
-   "Pixel offset for pop-up frame.
-This sometimes needs to be tweaked manually to get the pop-up
-frame in correct position on different window systems."
-  :group 'completion-ui
-  :type '(cons (integer :tag "x") (integer :tag "y")))
-
-
-
-
-;;; ============================================================
-;;;                 Other configuration variables
-
-(defvar completion-function nil
-  "Function that accepts two arguments, PREFIX and MAXNUM,
-and returns a list of at most MAXNUM completion candidates for
-the PREFIX string. If MAXNUM is nil, it should return all
-completion candidates for PREFIX.")
-(make-variable-buffer-local 'completion-function)
-(set-default 'completion-function nil)  ; ensure "global" value is nil
-
-
-(defvar completion-prefix-function 'completion-prefix
-  "Function that finds a prefix to complete at point.
-It should return the prefix as a string.")
-(make-variable-buffer-local 'completion-prefix-function)
-
-
-(defvar completion-includes-prefix t
-  "If nil, the strings returned by calls to `completion-function'
-do *not* include the prefix. If t, then they do. Ignored if
-`completion-replaces-prefix' is non-nil.")
-(make-variable-buffer-local 'completion-includes-prefix)
-
-
-(defvar completion-replaces-prefix nil
-  "If non-nil, completions replace the \"prefix\"
-that was completed. The characters that were being completed (as
-returned by `completion-prefix-function') will be deleted from
-the buffer when a completion is accepted.
-
-Setting this to non-nil allows completion-UI to support things
-other than simple prefix-completion.")
-(make-variable-buffer-local 'completion-replaces-prefix)
-
-
-(defvar completion-word-thing 'word
-  "Symbol used to determine what is considered a word.
-
-Used by `complete-word-at-point' and `completion-backward-delete'
-in calls to `thing-at-point'. See `thing-at-point' for more
-details.
-
-More precisely, it is used by the default
-`completion-prefix-function', `completion-prefix', which is
-called by the above functions to determine the prefix at
-point. So it may be ignored if `completion-prefix-function' is
-set to some other non-default function.")
-(make-variable-buffer-local 'completion-word-thing)
-
-
-(defvar completion-tooltip-function 'completion-construct-tooltip-text
-  "Function to call to construct the tooltip text.
-
-The function is called with three arguments, the prefix,
-completions, and index of the currently active completion. It
-should return a string containing the text to be displayed in the
-tooltip.
-
-Note: this can be overridden by an \"overlay local\" binding (see
-`auto-overlay-local-binding').")
-
-
-(defvar completion-menu 'completion-construct-menu
-  "The completion menu keymap, or a function to call
-to get a completion menu keymap.
-
-If a function, that function is called with two arguments, prefix
-and completions, and should return a menu keymap. Note: this can
-be overridden by an \"overlay local\" binding (see
-`auto-overlay-local-binding').")
-
-
-(defvar completion-browser-menu-function 'completion-construct-browser-menu
-  "Function to call to get a browser menu keymap.
-
-The function is called with two arguments, prefix and
-completions, and should return a menu keymap. Note: this can be
-overridden by an \"overlay local\" binding (see
-`auto-overlay-local-binding').")
-
-
-(defvar completion-popup-frame-function 'completion-construct-popup-frame-text
-  "Function to call to construct pop-up frame text.
-
-The function is called with two arguments, the prefix and
-completions. It should return a list of strings, which are used
-\(in order\) as the lines of text in the pop-up frame. Note: this
-can be overridden by an \"overlay local\" binding (see
-`auto-overlay-local-binding').")
-
-
-(defvar completion-accept-functions nil
-  "Hook run after a completion is accepted.
-
-Completions are accepted by calling `completion-accept',
-selecting one with a hotkey, or selecting one from a
-menu. Functions are passed three arguments: the prefix, the
-complete string that was accepted \(the concatenation of the
-prefix and the accepted completion string\), and any prefix
-argument supplied to and interactive accept command.")
-
-
-(defvar completion-reject-functions nil
-  "Hook run after a completion is rejected.
-
-Completions are rejected by calling
-`completion-reject'. Functions are passed three arguments: the
-prefix, the complete string that was rejected \(the concatenation
-of the prefix and the rejected completion string\), and any
-prefix argument supplied to an interactive rejection command.")
-
-
-;; (defvar completion-tab-complete-functions nil
-;;   "Hook run after tab-completion.
-;; Functions are passed two arguments: the complete string that has
-;; been inserted so far \(prefix and tab-completion combined\).")
-
-
-(defvar completion-map nil
-  "Keymap active when a completion-function is defined.")
-
-(defvar completion-hotkey-map nil
-  "Keymap used for hotkey completion (single-key selection of
-  completions).
-
-  Do NOT bind keys in this keymap directly. The keymap is
-  constructed automatically from `completion-hotkey-list'. You
-  should modify that instead, before `completion-ui.el' is
-  loaded.")
-
-
-(defvar completion-dynamic-map nil
-  "Keymap active in a dynamic completion overlay.")
-
-
-(defvar auto-completion-map nil
-  "Keymap active when auto-completion-mode is enabled.")
-
-
-(defvar auto-completion-dynamic-map nil
-  "Keymap active in a dynamic completion overlay when
-  auto-completion-mode is enabled.")
-
-
-(defvar completion-tooltip-map nil
-  "Keymap used when a tooltip is displayed.")
-
-(defvar completion-popup-frame-mode-map nil
-  "Keymap used by completion pop-up frames.")
-
-
-
-
-;;; ============================================================
-;;;                     Internal variables
-
-(defvar completion-overlay-list nil
-  "List of overlays used during completion")
-(make-variable-buffer-local 'completion-overlay-list)
-
-
-(defvar completion-auto-timer (timer-create)
-  "Timer used to postpone auto-completion or auto-display
-of tooltip/menu/pop-up frame until there's a pause in typing.")
-
-
-(defvar completion-tooltip-active nil
-  "Used to enable `completion-tooltip-map' when a tooltip is displayed.")
-
-(defvar completion-backward-delete-timer nil
-  "Timer used to postpone completion until finished deleting.")
-
-
-(defvar completion-trap-recursion nil
-  "Used to trap recursive calls to certain completion functions")
-
-
-
-
-;;; =================================================================
-;;;            Set properties for delete-selection-mode
-
-(put 'auto-completion-self-insert 'delete-selection t)
-(put 'completion-accept-and-newline 'delete-selection t)
-(put 'completion-backward-delete-char 'delete-selection 'supersede)
-(put 'completion-backward-delete-char-untabify
-     'delete-selection 'supersede)
-(put 'completion-delete-char 'delete-selection 'supersede)
-
-
-
-
-;;; =================================================================
-;;;                     Setup default keymaps
-
-;; Set the default keymap if it hasn't been defined already (most likely
-;; in an init file). This keymap is active whenever `completion-function'
-;; is non-nil.
-(unless completion-map
-  ;; If the current Emacs version doesn't support overlay keybindings
-  ;; half decently and doesn't support command remapping, we're going to
-  ;; have to bind all printable characters in this keymap, so we might as
-  ;; well create a full keymap
-  (if (and (<= emacs-major-version 21)
-	   (not (fboundp 'command-remapping)))
-      (setq completion-map (make-keymap))
-    (setq completion-map (make-sparse-keymap)))
-
-  ;; M-<tab> and M-/ cycle or complete word at point
-  (define-key completion-map [?\M-\t]
-    (lambda ()
-      "Cycle through available completions if there are any,\
- otherwise complete the word at point."
-      (interactive)
-      (if (completion-overlay-at-point)
-	  (completion-cycle)
-	(complete-word-at-point))))
-  (define-key completion-map "\M-/"
-    (lambda ()
-      "Cycle through available completions if there are any,\
- otherwise complete the word at point."
-      (interactive)
-      (if (completion-overlay-at-point)
-	  (completion-cycle)
-	(complete-word-at-point))))
-
-  ;; M-<shift>-<tab> and M-? (usually M-<shift>-/) cycle backwards
-  (define-key completion-map [(meta shift iso-lefttab)]
-    (lambda ()
-      "Cycle backwards through completions if there are any,\
- otherwise complete the word at point."
-      (interactive)
-      (if (completion-overlay-at-point)
-	  (completion-cycle -1)
-	(complete-word-at-point))))
-  (define-key completion-map "\M-?"
-    (lambda ()
-      "Cycle backwards through completions if there are any,\
- otherwise complete the word at point."
-      (interactive)
-      (if (completion-overlay-at-point)
-	  (completion-cycle -1)
-	(complete-word-at-point))))
-
-  ;; RET deals with any pending completion candidate, then runs
-  ;; whatever is usually bound to RET.
-  ;; Note: although this uses `completion-run-if-within-overlay', it is
-  ;;       not a hack to work-around poor overlay keybinding
-  ;;       support. Rather, we are using it to run
-  ;;       `completion-resolve-current' and then run the normal RET
-  ;;       keybinding. We bind it here instead of in the overlay keymap
-  ;;       because it's easier to disable this keymap.
-  (define-key completion-map "\r"
-    (lambda () "Resolve current completion, then run whatever\
- would normally be bound to RET."
-      (interactive)
-      (completion-run-if-within-overlay
-       (lambda () (interactive) (completion-resolve-current nil ?\r ? ))
-       'completion-function 'before)))
-
-  ;; if command remapping is supported, remap delete commands
-  (if (fboundp 'command-remapping)
-      (progn
-	(define-key completion-map [remap delete-char]
-	  'completion-delete-char)
-	(define-key completion-map [remap backward-delete-char]
-	  'completion-backward-delete-char)
-	(define-key completion-map [remap delete-backward-char]
-	  'completion-backward-delete-char)
-	(define-key completion-map [remap backward-delete-char-untabify]
-	  'completion-backward-delete-char-untabify)
-	(define-key completion-map [remap kill-word]
-	  'completion-kill-word)
-	(define-key completion-map [remap backward-kill-word]
-	  'completion-backward-kill-word)
-	(define-key completion-map [remap kill-sentenve]
-	  'completion-kill-sentenve)
-	(define-key completion-map [remap backward-kill-sentenve]
-	  'completion-backward-kill-sentenve)
-	(define-key completion-map [remap kill-sexp]
-	  'completion-kill-sexp)
-	(define-key completion-map [remap backward-kill-sexp]
-	  'completion-backward-kill-sexp)
-	(define-key completion-map [remap kill-paragraphs]
-	  'completion-kill-paragraph)
-	(define-key completion-map [remap backward-kill-paragraph]
-	  'completion-backward-kill-paragraph))
-
-    ;; otherwise, can't do better than define bindings for the keys
-    ;; that are currently bound to them
-    (dolist (key '([delete] [deletechar] [backspace] "\d"
-		   [(control delete)] [(control deletechar)]
-		   [(meta delete)] [(meta deletechar)]
-		   [(control backspace)] [(meta backspace)] "\M-\d"))
-      (catch 'rebound
-	(dolist (binding '((delete-char . completion-delete-char)
-			   (kill-word . completion-kill-word)
-			   (kill-sentence . completion-kill-sentence)
-			   (kill-sexp . completion-kill-sexp)
-			   (kill-paragraph . completion-kill-paragraph)
-			   (backward-delete-char
-			    . completion-backward-delete-char)
-			   (delete-backward-char
-			    . completion-backward-delete-char)
-			   (backward-delete-char-untabify
-			    . completion-backward-delete-char-untabify)
-			   (backward-kill-word
-			    . completion-backward-kill-word)
-			   (backward-kill-sentence
-			    . completion-backward-kill-sentence)
-			   (backward-kill-sexp
-			    . completion-backward-kill-sexp)
-			   (backward-kill-paragraph
-			    . completion-backward-kill-paragraph)))
-	  (when (eq (key-binding key) (car binding))
-	    (define-key completion-map key (cdr binding))
-	    (throw 'rebound t)))))
-    )
-
-
-  ;; ----- Simulated overlay keybindings -----
-
-  ;; Note: could remove this and leave it up to the call to the
-  ;;       `completion-simulate-overlay-keybindings' function at the very end
-  ;;       of this file, if only that function could deal with remappings
-
-  ;; If the current Emacs version doesn't support overlay keybindings
-  ;; half decently, have to simulate them using the
-  ;; `completion-run-if-within-overlay' hack.
-  (when (<= emacs-major-version 21)
-    ;; if we can remap commands, remap `self-insert-command' to
-    ;; `completion-self-insert'
-    (if (fboundp 'command-remapping)
-	(define-key completion-map [remap self-insert-command]
-	  'completion-self-insert)
-      ;; otherwise, rebind all printable characters to
-      ;; `completion-self-insert' manually
-      (completion-bind-printable-chars completion-map
-				       'completion-self-insert))
-
-;;;     ;; C-RET accepts, C-DEL rejects
-;;;     (define-key completion-map [(control return)]
-;;;       'completion-accept-if-within-overlay)
-;;;     (define-key completion-map [(control backspace)]
-;;;       'completion-reject-if-within-overlay)
-
-;;;     ;; <tab> does traditional tab-completion
-;;;     (define-key completion-map "\t"
-;;;       'completion-tab-complete-if-within-overlay)
-
-;;;     ;; C-<tab> scoots ahead
-;;;     (define-key completion-map [(control tab)]
-;;;       'completion-scoot-ahead-if-within-overlay)
-
-;;;     ;; C-<space> abandons
-;;;     (define-key completion-map [?\C- ]
-;;;       'completion-reject-if-within-overlay)
-
-;;;     ;; S-<down>, M-<down> and C-<down> display the compltion tooltip,
-;;;     ;; menu, and pop-up frame
-;;;     (define-key completion-map [S-down]
-;;;       'completion-show-tooltip-if-within-overlay)
-;;;     (define-key completion-map [M-down]
-;;;       'completion-show-menu-if-within-overlay)
-;;;     (define-key completion-map [C-down]
-;;;       'completion-popup-frame-if-within-overlay)
-    )
-)
-
-
-;; make sure completion-map is associated with `completion-function' in
-;; the minor-mode-keymap-alist, so that the bindings are enabled whenever
-;; a completion function is defined
-(let ((existing (assq 'completion-function minor-mode-map-alist)))
-  (if existing
-      (setcdr existing completion-map)
-    (push (cons 'completion-function completion-map)
-	  minor-mode-map-alist)))
-
-
-
-
-;; Set the default bindings for the keymap assigned to the completion
-;; overlays created when dynamic completion is enabled, if it hasn't been
-;; defined already (most likely in an init file).
-(unless completion-dynamic-map
-  ;; Note: rebinding printable characters here is redundant if
-  ;;       `auto-completion-mode' is enabled, since they are also bound
-  ;;       in `auto-completion-map', but we still need to ensure that the
-  ;;       provisional completion is correctly dealt with even if
-  ;;       `auto-completion-mode' is disabled.
-
-  ;; if we can remap commands, remap `self-insert-command' to
-  ;; `completion-self-insert'
-  (if (fboundp 'command-remapping)
-      (progn
-	(setq completion-dynamic-map (make-sparse-keymap))
-	(define-key completion-dynamic-map [remap self-insert-command]
-	  'completion-self-insert))
-    ;; otherwise, create a great big keymap and rebind all printable
-    ;; characters to `completion-self-insert' manually
-    (setq completion-dynamic-map (make-keymap))
-    (completion-bind-printable-chars completion-dynamic-map
-				     'completion-self-insert))
-
-  ;; C-RET accepts, C-DEL rejects
-  (define-key completion-dynamic-map [(control return)] 'completion-accept)
-  (define-key completion-dynamic-map [(control backspace)] 'completion-reject)
-
-  ;; <tab> does traditional tab-completion
-  (define-key completion-dynamic-map "\t" 'completion-tab-complete)
-
-  ;; C-<tab> scoots ahead
-  (define-key completion-dynamic-map [(control tab)]
-    'completion-scoot-ahead)
-
-  ;; C-<space> abandons
-  (define-key completion-dynamic-map [?\C- ] 'completion-reject)
-
-  ;; S-<down>, M-<down> and C-<down> display the completion tooltip,
-  ;; menu, or pop-up frame
-  (define-key completion-dynamic-map [S-down] 'completion-show-tooltip)
-  (define-key completion-dynamic-map [M-down] 'completion-show-menu)
-  (define-key completion-dynamic-map [C-down] 'completion-popup-frame)
-
-  ;; clicking on a completion displays the completion menu
-  (define-key completion-dynamic-map [mouse-2] 'completion-show-menu)
-)
-
-
-
-;; Set the default auto-completion-mode keymap if it hasn't been defined
-;; already (most likely in an init file). This keymap is active when
-;; `auto-completion-mode' is enabled.
-(unless auto-completion-map
-  ;; if we can remap commands, remap `self-insert-command'
-  (if (fboundp 'command-remapping)
-      (progn
-	(setq auto-completion-map (make-sparse-keymap))
-	(define-key auto-completion-map [remap self-insert-command]
-	  'auto-completion-self-insert))
-    ;; otherwise, create a great big keymap where all printable characters run
-    ;; `auto-completion-self-insert', which decides what to do based on the
-    ;; character's syntax
-    (setq auto-completion-map (make-keymap))
-    (completion-bind-printable-chars auto-completion-map
-				     'auto-completion-self-insert))
-
-
-;;;   ;; ----- Simulated overlay keybindings -----
-
-;;;   ;; C-<space> abandons
-;;;   (define-key auto-completion-map [?\C- ]
-;;;     (lambda ()
-;;;       "Reject current provisional completion if any, otherwise
-;;; run whatever would normally be bound to \"C-<SPC>\"."
-;;;       (interactive)
-;;;       (completion-run-if-within-overlay
-;;;        'completion-reject 'auto-completion-mode)))
-
-;;;   ;; M-<space> abandons and inserts a space
-;;;   (define-key auto-completion-map "\M- "
-;;;     (lambda (&optional arg)
-;;;       "Reject any current provisional completion if any and insert a space,
-;;; otherwise run whatever would normally be bound to \"M-<SPC>\"."
-;;;       (interactive "P")
-;;;       (completion-run-if-within-overlay
-;;;        (lambda () (interactive) (completion-reject arg) (insert " "))
-;;;        'auto-completion-mode)))
-
-;;;   ;; M-S-<space> inserts a space as a word-constituent
-;;;   (define-key auto-completion-map [?\M-\S- ]
-;;;     (lambda ()
-;;;       "Insert a space as though it were a word-constituent if
-;;; there's a provisional completion at point, otherwise run whatever
-;;; would normally be bound to \"M-S\\ \"."
-;;;       (interactive)
-;;;       (completion-run-if-within-overlay
-;;;        (lambda () (interactive) (auto-completion-self-insert ?\  ?w t))
-;;;        'auto-completion-mode)))
-
-
-;;;   ;; M-. inserts "." as a word-constituent
-;;;   (define-key auto-completion-map "\M-."
-;;;     (lambda ()
-;;;       "Insert \".\" as though it were a word-constituent if
-;;; there's a provisional completion at point, otherwise run whatever
-;;; would normally be bound to \"M-.\"."
-;;;       (interactive)
-;;;       (completion-run-if-within-overlay
-;;;        (lambda () (interactive) (auto-completion-self-insert ?. ?w t))
-;;;        'auto-completion-mode)))
-
-;;;   ;; M-- inserts "-" as a word-constituent
-;;;   (define-key auto-completion-map "\M--"
-;;;     (lambda ()
-;;;       "Insert \"-\" as though it were a word-constituent if
-;;; there's a provisional completion at point, otherwise run whatever
-;;; would normally be bounds to \"M--\"."
-;;;       (interactive)
-;;;       (completion-run-if-within-overlay
-;;;        (lambda () (interactive) (auto-completion-self-insert ?- ?w t))
-;;;        'auto-completion-mode)))
-
-;;;   ;; M-/ inserts "/" as a word-constituent
-;;;   (define-key auto-completion-map "\M-/"
-;;;     (lambda ()
-;;;       "Insert \"/\" as though it were a word-constituent if
-;;; there's a provisional completion at point, otherwise run whatever
-;;; would normally be bound to \"M-/\"."
-;;;       (interactive)
-;;;       (completion-run-if-within-overlay
-;;;        (lambda () (interactive)
-;;;           (auto-completion-self-insert ?/ ?w t))
-;;;        'auto-completion-mode)))
-)
-
-
-
-;; Set the default bindings for the keymap assigned to the completion overlays
-;; created when dynamic completion and auto-completion are enabled, if it
-;; hasn't been defined already (most likely in an init file).
-(unless auto-completion-dynamic-map
-  ;; inherit all keybindings from completion-dynamic-map, then add
-  ;; auto-completion specific ones below
-  (setq auto-completion-dynamic-map (make-sparse-keymap))
-  (set-keymap-parent auto-completion-dynamic-map completion-dynamic-map)
-
-  ;; M-<space> abandons and inserts a space
-  (define-key auto-completion-dynamic-map "\M- "
-    (lambda (&optional arg)
-      "Reject any current provisional completion and insert a space."
-      (interactive "P")
-      (completion-reject arg)
-      (insert " ")))
-
-  ;; M-S-<space> inserts a space as a word-constituent
-  (define-key auto-completion-dynamic-map [?\M-\S- ]
-    (lambda ()
-      "Insert a space as though it were a word-constituent."
-      (interactive)
-      (auto-completion-self-insert ?\  ?w t)))
-
-  ;; M-. inserts "." as a word-constituent
-  (define-key auto-completion-dynamic-map "\M-."
-    (lambda ()
-      "Insert \".\" as though it were a word-constituent."
-      (interactive)
-      (auto-completion-self-insert ?. ?w t)))
-
-  ;; M-- inserts "-" as a word-constituent
-  (define-key auto-completion-dynamic-map "\M--"
-    (lambda ()
-      "Insert \"-\" as though it were a word-constituent."
-      (interactive)
-      (auto-completion-self-insert ?- ?w t)))
-
-;;;   ;; M-/ inserts "/" as a word-constituent
-;;;   (define-key auto-completion-dynamic-map "\M-/"
-;;;     (lambda ()
-;;;       "Insert \"/\" as though it were a word-constituent."
-;;;       (interactive)
-;;;       (auto-completion-self-insert ?/ ?w t)))
-)
-
-
-
-
-;; Construct the keymap used for hotkey selection from
-;; `completion-hotkey-list'. This keymap is active if
-;; `completion-use-hotkeys' is enabled.
-(setq completion-hotkey-map (make-sparse-keymap))
-(dolist (key completion-hotkey-list)
-  (define-key completion-hotkey-map key
-    'completion-select-if-within-overlay))
-
-;; make sure completion-hotkey-map is in minor-mode-keymap-alist
-(let ((existing (assq 'completion-use-hotkeys minor-mode-map-alist)))
-  (if existing
-      (setcdr existing completion-hotkey-map)
-    (push (cons 'completion-use-hotkeys completion-hotkey-map)
-	  minor-mode-map-alist)))
-
-
-
-;; Note: `completion-tooltip-active' is reset by `pre-command-hook' (see
-;;       end of file), so the keymap below is disabled before every
-;;       command is executed. However, the key bindings are looked up
-;;       before `pre-command-hook' runs, so the first key sequence after
-;;       displaying a tooltip has a chance of running something from
-;;       here. This is exactly what we want, since Emacs hides tooltips
-;;       after every command and we only want this keymap to be active if
-;;       a tooltip is visible.
-;;
-;;       The cycling commands bound below re-display the completion
-;;       tooltip, which causes `completion-tooltip-active' to be set to t
-;;       again. So after they've run, the keymap is left active again for
-;;       the next key sequence.
-
-;; Set default key bindings for the keymap used when a completion tooltip
-;; is displayed, unless it's already been set (most likely in an init
-;; file). This keymap is active when `completion-tooltip-active' is
-;; non-nil.
-(unless completion-tooltip-map
-  (let ((map (make-sparse-keymap)))
-    ;; <up> and <down> cycle completions, which appears to move selection
-    ;; up and down tooltip entries
-    (define-key map [down] 'completion-tooltip-cycle)
-    (define-key map [up]
-      (lambda () (interactive) (completion-tooltip-cycle -1)))
-    (setq completion-tooltip-map map))
-)
-
-
-;; make sure completion-tooltip-map is in minor-mode-keymap-alist
-(let ((existing (assq 'completion-tooltip-active minor-mode-map-alist)))
-  (if existing
-      (setcdr existing completion-tooltip-map)
-    (push (cons 'completion-tooltip-active completion-tooltip-map)
-	  minor-mode-map-alist)))
-
-
-
-;; Set default keybindings for the keymap used in completion pop-up
-;; frames (actually, used by the completion-popup-frame major mode),
-;; unless it's already been set (most likely in an init file).
-(unless completion-popup-frame-mode-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map "\M-n" (lambda (&optional arg) (interactive)
-			     (completion-popup-frame-motion
-			      'next-line arg)))
-    (define-key map "\C-n" (lambda (&optional arg) (interactive)
-			     (completion-popup-frame-motion
-			      'next-line arg)))
-    (define-key map [down] (lambda (&optional arg) (interactive)
-			     (completion-popup-frame-motion
-			      'next-line arg)))
-    (define-key map "\M-p" (lambda (&optional arg) (interactive)
-			     (completion-popup-frame-motion
-			      'previous-line arg)))
-    (define-key map "\C-p" (lambda (&optional arg) (interactive)
-			     (completion-popup-frame-motion
-			      'previous-line arg)))
-    (define-key map [up] (lambda (&optional arg) (interactive)
-			   (completion-popup-frame-motion
-			    'previous-line arg)))
-    (define-key map "\C-v" (lambda (&optional arg) (interactive)
-			     (completion-popup-frame-motion
-			      'scroll-up arg)))
-    (define-key map [next] (lambda (&optional arg) (interactive)
-			     (completion-popup-frame-motion
-			      'scroll-up arg)))
-    (define-key map "\M-v" (lambda (&optional arg) (interactive)
-			     (completion-popup-frame-motion
-			      'scroll-down arg)))
-    (define-key map [prior] (lambda (&optional arg) (interactive)
-			      (completion-popup-frame-motion
-			       'scroll-down arg)))
-    (define-key map [home] (lambda (&optional arg) (interactive)
-			      (completion-popup-frame-motion
-			       'beginning-of-buffer arg)))
-    (define-key map "\M-<" (lambda (&optional arg) (interactive)
-			     (completion-popup-frame-motion
-			      'beginning-of-buffer arg)))
-    (define-key map [end] (lambda (&optional arg) (interactive)
-			    (completion-popup-frame-motion
-			     'end-of-buffer arg)))
-    (define-key map "\M->" (lambda (&optional arg) (interactive)
-			     (completion-popup-frame-motion
-			      'end-of-buffer arg)))
-    (define-key map "\C-u" 'universal-argument)
-    (define-key map [?\C--] 'negative-argument)
-    (define-key map [C-up] 'completion-popup-frame-dismiss)
-    (define-key map [M-up] 'completion-popup-frame-dismiss)
-    (define-key map [?\M-\t] 'completion-popup-frame-toggle-show-all)
-    (define-key map "\M-/" 'completion-popup-frame-toggle-show-all)
-    (define-key map [t] 'completion-popup-frame-unread-key)
-    (setq completion-popup-frame-mode-map map)))
-
-
-
-
-;;; ===============================================================
-;;;                  Keybinding functions
-
-(defun completion-define-word-constituent-binding
-  (key char &optional syntax no-syntax-override)
-  "Setup key binding for KEY so that it inserts character CHAR as
-though it's syntax were SYNTAX. SYNTAX defaults to
-word-constituent, ?w, hence the name of the function, but it can
-be used to set up any syntax.
-
-If NO-SYNTAX-OVERRIDE is non-nil, this binding will cause
-`auto-completion-override-syntax-alist' to be ignored when this
-key binding is used, so that the behaviour is determined only by
-SYNTAX."
-
-  (when (null syntax) (setq syntax ?w))
-  (let ((doc (concat "Insert \"" (string char) "\" as though it were a\
- word-constituent.")))
-
-    ;; create `auto-completion-dynamic-map' binding
-    (define-key auto-completion-dynamic-map key
-      `(lambda () ,doc
-	 (interactive)
-	 (auto-completion-self-insert ,char ,syntax
-				      ,no-syntax-override)))
-
-    ;; if emacs version doesn't support overlay keymaps properly, create
-    ;; binding in `completion-map' to simulate it via
-    ;; `completion-run-if-within-overlay' hack
-    (when (<= emacs-major-version 21)
-      (define-key completion-map key
-	`(lambda () ,doc
-	   (interactive)
-	   (completion-run-if-within-overlay
-	    (lambda () (interactive)
-	      (auto-completion-self-insert ,char ,syntax
-					   ,no-syntax-override))
-	    'completion-function)))))
-)
-
-
-
-(defun completion-bind-printable-chars (map command)
-  "Manually bind printable characters to COMMAND.
-Command remapping is a far better way to do this, so it should only be
-used if the current Emacs version lacks command remapping support."
-  (define-key map "A" command)
-  (define-key map "a" command)
-  (define-key map "B" command)
-  (define-key map "b" command)
-  (define-key map "C" command)
-  (define-key map "c" command)
-  (define-key map "D" command)
-  (define-key map "d" command)
-  (define-key map "E" command)
-  (define-key map "e" command)
-  (define-key map "F" command)
-  (define-key map "f" command)
-  (define-key map "G" command)
-  (define-key map "g" command)
-  (define-key map "H" command)
-  (define-key map "h" command)
-  (define-key map "I" command)
-  (define-key map "i" command)
-  (define-key map "J" command)
-  (define-key map "j" command)
-  (define-key map "K" command)
-  (define-key map "k" command)
-  (define-key map "L" command)
-  (define-key map "l" command)
-  (define-key map "M" command)
-  (define-key map "m" command)
-  (define-key map "N" command)
-  (define-key map "n" command)
-  (define-key map "O" command)
-  (define-key map "o" command)
-  (define-key map "P" command)
-  (define-key map "p" command)
-  (define-key map "Q" command)
-  (define-key map "q" command)
-  (define-key map "R" command)
-  (define-key map "r" command)
-  (define-key map "S" command)
-  (define-key map "s" command)
-  (define-key map "T" command)
-  (define-key map "t" command)
-  (define-key map "U" command)
-  (define-key map "u" command)
-  (define-key map "V" command)
-  (define-key map "v" command)
-  (define-key map "W" command)
-  (define-key map "w" command)
-  (define-key map "X" command)
-  (define-key map "x" command)
-  (define-key map "Y" command)
-  (define-key map "y" command)
-  (define-key map "Z" command)
-  (define-key map "z" command)
-  (define-key map "'" command)
-  (define-key map "-" command)
-  (define-key map "<" command)
-  (define-key map ">" command)
-  (define-key map " " command)
-  (define-key map "." command)
-  (define-key map "," command)
-  (define-key map ":" command)
-  (define-key map ";" command)
-  (define-key map "?" command)
-  (define-key map "!" command)
-  (define-key map "\"" command)
-  (define-key map "0" command)
-  (define-key map "1" command)
-  (define-key map "2" command)
-  (define-key map "3" command)
-  (define-key map "4" command)
-  (define-key map "5" command)
-  (define-key map "6" command)
-  (define-key map "7" command)
-  (define-key map "8" command)
-  (define-key map "9" command)
-  (define-key map "~" command)
-  (define-key map "`" command)
-  (define-key map "@" command)
-  (define-key map "#" command)
-  (define-key map "$" command)
-  (define-key map "%" command)
-  (define-key map "^" command)
-  (define-key map "&" command)
-  (define-key map "*" command)
-  (define-key map "_" command)
-  (define-key map "+" command)
-  (define-key map "=" command)
-  (define-key map "(" command)
-  (define-key map ")" command)
-  (define-key map "{" command)
-  (define-key map "}" command)
-  (define-key map "[" command)
-  (define-key map "]" command)
-  (define-key map "|" command)
-  (define-key map "\\" command)
-  (define-key map "/" command)
-)
-
-
-
-(defun completion-simulate-overlay-bindings (source dest variable
-						    &optional no-parent)
-  ;; Simulate SOURCE overlay keybindings in DEST using the
-  ;; `completion-run-if-within-overlay' hack. DEST should be a symbol whose
-  ;; value is a keymap, SOURCE should be a keymap.
-  ;;
-  ;; VARIABLE should be a symbol that deactivates DEST when its value is
-  ;; (temporarily) set to nil. Usually, DEST will be a minor-mode keymap and
-  ;; VARIABLE will be the minor-mode variable with which it is associated in
-  ;; `minor-mode-map-alist'.
-  ;;
-  ;; NO-PARENT will prevent this recursing into the parent keymap of SOURCE,
-  ;; if it has one.
-
-  ;; if NO-PARENT is specified, remove parent keymap if there is one
-  (when (and no-parent (memq 'keymap (cdr source)))
-    (setq source
-	  (completion--sublist
-	   source 0 (1+ (completion--position 'keymap (cdr source))))))
-
-  ;; map over all bindings in SOURCE
-  (map-keymap
-   (lambda (key binding)
-     ;; don't simulate remappings, and don't simulate parent keymap's bindings
-     (unless (eq key 'remap)
-       ;; usually need to wrap key in an array for define-key
-       (unless (stringp key) (setq key (vector key)))
-       ;; bind key in DEST to simulated overlay keymap binding
-       (define-key dest key
-	 (completion-construct-simulated-overlay-binding binding variable))))
-   source)
-)
-
-
-
-(defun completion-construct-simulated-overlay-binding (binding variable)
-  ;; Return a binding that simulates assigning BINDING to KEY in an overlay
-  ;; keymap, using the `completion-run-if-within-overlay' hack.
-  ;;
-  ;; VARIABLE should be a symbol that deactivates BINDING when its value is
-  ;; (temporarily) set to nil. Typically, BINDING will be bound in a
-  ;; minor-mode keymap and VARIABLE will be the minor-mode variable with which
-  ;; it is associated in `minor-mode-map-alist'.
-  ;;
-  ;; The return value is a command if BINDING was a command, or a keymap if
-  ;; BINDING was a keymap. Any other type of BINDING (e.g. a remapping)
-  ;; returns nil, since there is no easy way to simulate this.
-
-  (cond
-   ;; don't simulate command remappings or keyboard macros
-   ((or (eq binding 'remap) (stringp binding))
-    nil)
-
-
-   ;; if BINDING is a keymap, call ourselves recursively to construct a keymap
-   ;; filled with bindings that simulate an overlay keymap
-   ((keymapp binding)
-    (let ((map (make-sparse-keymap)))
-      (map-keymap
-       (lambda (key bind)
-	 ;; usually need to wrap key in an array for define-key
-	 (unless (stringp key) (setq key (vector key)))
-	 (define-key map key
-	   (completion-construct-simulated-overlay-binding bind variable)))
-       binding)
-      map))
-
-
-   ;; if BINDING is a command, construct an anonymous command that simulates
-   ;; binding that command in an overlay keymap
-   ((or (commandp binding) (and (symbolp binding) (symbol-function binding)))
-    (let (funcdef arglist docstring interactive args)
-
-      ;; get function definition of command
-      (cond
-       ((symbolp binding) (setq funcdef (symbol-function binding)))
-       ((functionp binding) (setq funcdef binding)))
-
-      ;; extract argument list
-      (cond
-       ;; compiled function
-       ((byte-code-function-p funcdef) (setq arglist (aref funcdef 0)))
-       ;; uncompiled function
-       ((listp funcdef) (setq arglist (nth 1 funcdef))))
-
-      ;; extract docstring and interactive definition
-      (setq docstring (documentation binding))
-      (setq interactive (interactive-form binding))
-
-      ;; construct docstring for new binding
-      (setq docstring
-	    (concat "Do different things depending on whether point is "
-		    "within a provisional completion.\n\n"
-		    "If point is within a provisional completion,\n"
-		    (downcase (substring docstring 0 1))
-		    (substring docstring 1)
-		    "\n\n"
-		    "If point is not within a provisional completion,\n"
-		    "run whatever would normally be bound to "
-		    "this key sequence."))
-
-      ;; construct list of argument variable names, removing &optional and
-      ;; &rest
-      (setq args '(list))
-      (mapc (lambda (a)
-	      (unless (or (eq a '&optional) (eq a '&rest))
-		(setq args (append args (list a)))))
-	    arglist)
-
-      ;; construct and return command to simulate overlay keymap binding
-      `(lambda ,(copy-sequence arglist)
-	 "" ;,docstring
-	 ,(copy-sequence interactive)
-	 (completion-run-if-within-overlay
-	  (lambda ,(copy-sequence arglist) ,(copy-sequence interactive)
-	    (apply ',binding ,args))
-	  ',variable))
-      ))
-
-   ;; anything else is an error
-   (t (error (concat "Unexpected binding in "
-		     "`completion-construct-simulated-overlay-binding': %s")
-	     binding))
-   )
-)
-
-
-
-
-;;; ================================================================
-;;;                Replacements for CL functions
-
-(defun completion--sublist (list start &optional end)
-  "Return the sub-list of LIST from START to END.
-If END is omitted, it defaults to the length of the list
-If START or END is negative, it counts from the end."
-  (let (len)
-    ;; sort out arguments
-    (if end
-	(when (< end 0) (setq end (+ end (setq len (length list)))))
-      (setq end (or len (setq len (length list)))))
-    (when (< start 0)
-      (setq start (+ start (or len (length list)))))
-
-    ;; construct sub-list
-    (let (res)
-      (while (< start end)
-	(push (nth start list) res)
-	(setq start (1+ start)))
-      (nreverse res)))
-)
-
-
-
-(defun completion--position (item list)
-  "Find the first occurrence of ITEM in LIST.
-Return the index of the matching item, or nil of not found.
-Comparison is done with 'equal."
-  (let (el (i 0))
-    (catch 'found
-      (while (setq el (nth i list))
-	(when (equal item el) (throw 'found i))
-	(setq i (1+ i))
-	nil)))
-)
-
-
-;;; ================================================================
-;;;                Interface abstraction macros
-
-(defun completion-lookup-behaviour (&optional char syntax)
-  "Return syntax-dependent behaviour
-of character CHAR and/or syntax-class SYNTAX. At least one of
-these must be supplied. If both are supplied, SYNTAX overrides the
-syntax-class of CHAR."
-
-  ;; SYNTAX defaults to syntax-class of CHAR
-  (when (and char (not syntax)) (setq syntax (char-syntax char)))
-
-  ;; get syntax alists
-  (let ((syntax-alist
-	 (if (fboundp 'auto-overlay-local-binding)
-	     (auto-overlay-local-binding
-	      'auto-completion-syntax-alist)
-	   auto-completion-syntax-alist))
-	(override-alist
-	 (if (fboundp 'auto-overlay-local-binding)
-	     (auto-overlay-local-binding
-	      'auto-completion-override-syntax-alist)
-	   auto-completion-override-syntax-alist))
-	behaviour)
-
-    ;; if `auto-completion-syntax-alist' is a predefined behaviour (a
-    ;; cons cell), convert it to an alist
-    (unless (listp (car syntax-alist))
-      (setq syntax-alist
-	    `(;; word constituents add to current completion and