]> code.delx.au - gnu-emacs/blobdiff - lisp/completion.el
(save-completions-flag): Doc fix.
[gnu-emacs] / lisp / completion.el
index 15274bdc5062bb72dc5f313e4f684fb95d09804d..f087031b266a3bbb95c8d03eb54f22cb05fe1c49 100644 (file)
@@ -1,6 +1,6 @@
 ;;; completion.el --- dynamic word-completion code
 
-;; Copyright (C) 1990, 1993, 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1993, 1995, 1997 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: abbrev
 ;;
 ;;
 ;;-----------------------------------------------
-;; Change Log:
+;;; Change Log:
 ;;-----------------------------------------------
 ;;    Sometime in '84 Brewster implemented a somewhat buggy version for 
 ;; Symbolics LISPMs.
 ;; User changeable parameters
 ;;---------------------------------------------------------------------------
 
-(defvar enable-completion t
+(defgroup completion nil
+  "Dynamic word-completion code."
+  :group 'matching)
+
+
+(defcustom enable-completion t
   "*Non-nil means enable recording and saving of completions.
-If nil, no new words added to the database or saved to the init file.")
+If nil, no new words added to the database or saved to the init file."
+  :type 'boolean
+  :group 'completion)
 
-(defvar save-completions-flag t
+(defcustom save-completions-flag t
   "*Non-nil means save most-used completions when exiting Emacs.
-See also `saved-completions-retention-time'.")
+See also `save-completions-retention-time'."
+  :type 'boolean
+  :group 'completion)
 
-(defvar save-completions-file-name (convert-standard-filename "~/.completions")
-  "*The filename to save completions to.")
+(defcustom save-completions-file-name (convert-standard-filename "~/.completions")
+  "*The filename to save completions to."
+  :type 'file
+  :group 'completion)
 
-(defvar save-completions-retention-time 336
+(defcustom save-completions-retention-time 336
   "*Discard a completion if unused for this many hours.
 \(1 day = 24, 1 week = 168).  If this is 0, non-permanent completions
-will not be saved unless these are used.  Default is two weeks.")
+will not be saved unless these are used.  Default is two weeks."
+  :type 'integer
+  :group 'completion)
 
-(defvar completion-on-separator-character nil
+(defcustom completion-on-separator-character nil
   "*Non-nil means separator characters mark previous word as used.
-This means the word will be saved as a completion.")
+This means the word will be saved as a completion."
+  :type 'boolean
+  :group 'completion)
 
-(defvar completions-file-versions-kept kept-new-versions
-  "*Number of versions to keep for the saved completions file.")
+(defcustom completions-file-versions-kept kept-new-versions
+  "*Number of versions to keep for the saved completions file."
+  :type 'integer
+  :group 'completion)
 
-(defvar completion-prompt-speed-threshold 4800
-  "*Minimum output speed at which to display next potential completion.")
+(defcustom completion-prompt-speed-threshold 4800
+  "*Minimum output speed at which to display next potential completion."
+  :type 'integer
+  :group 'completion)
 
-(defvar completion-cdabbrev-prompt-flag nil
+(defcustom completion-cdabbrev-prompt-flag nil
   "*If non-nil, the next completion prompt does a cdabbrev search.
-This can be time consuming.")
+This can be time consuming."
+  :type 'boolean
+  :group 'completion)
 
-(defvar completion-search-distance 15000
+(defcustom completion-search-distance 15000
   "*How far to search in the buffer when looking for completions.
-In number of characters.  If nil, search the whole buffer.")
+In number of characters.  If nil, search the whole buffer."
+  :type 'integer
+  :group 'completion)
 
-(defvar completions-merging-modes '(lisp c)
+(defcustom completions-merging-modes '(lisp c)
   "*List of modes {`c' or `lisp'} for automatic completions merging.
 Definitions from visited files which have these modes
-are automatically added to the completion database.")
+are automatically added to the completion database."
+  :type '(set (const lisp) (const c))
+  :group 'completion)
 
 ;;(defvar *record-cmpl-statistics-p* nil
 ;;  "*If non-nil, record completion statistics.")
@@ -470,9 +495,7 @@ Used to decide whether to save completions.")
 \f
 (defun cmpl-hours-since-origin ()
   (let ((time (current-time)))
-    (truncate
-     (+ (* (/ (car time) 3600.0) (lsh 1 16))
-       (/ (nth 2 time) 3600.0)))))
+    (floor (+ (* 65536.0 (nth 0 time)) (nth 1 time)) 3600)))
 \f
 ;;---------------------------------------------------------------------------
 ;; "Symbol" parsing functions
@@ -528,8 +551,13 @@ Used to decide whether to save completions.")
 ;;-----------------------------------------------
 
 (defun cmpl-make-standard-completion-syntax-table ()
-  (let ((table (make-syntax-table)) ;; default syntax is whitespace
+  (let ((table (make-syntax-table))
        i)
+    ;; Default syntax is whitespace.
+    (setq i 0)
+    (while (< i 256)
+      (modify-syntax-entry i " " table)
+      (setq i (1+ i)))
     ;; alpha chars
     (setq i 0)
     (while (< i 26)
@@ -2612,6 +2640,10 @@ TYPE is the type of the wrapper to be added.  Can be :before or :under."
 (define-key lisp-mode-map "=" 'self-insert-command)
 (define-key lisp-mode-map "^" 'self-insert-command)
 
+;; Avoid warnings.
+(defvar c-mode-map)
+(defvar fortran-mode-map)
+
 ;; C mode diffs.
 (defun completion-c-mode-hook ()
   (def-completion-wrapper electric-c-semi :separator)
@@ -2671,4 +2703,6 @@ TYPE is the type of the wrapper to be added.  Can be :before or :under."
 (cmpl-statistics-block
   (record-completion-file-loaded))
 
+(provide 'completion)
+
 ;;; completion.el ends here