(describe-function): Add blank line above doc string.
[bpt/emacs.git] / lisp / completion.el
index 9d478e7..8203cbe 100644 (file)
@@ -1,3 +1,10 @@
+;;; completion.el --- dynamic word-completion code
+
+;; Maintainer: bug-completion@think.com
+;; Keywords: abbrev
+
+;;; Commentary:
+
 ;;; This is a Completion system for GNU Emacs
 ;;;
 ;;;  E-Mail: 
 ;;;
 ;;;
 ;;;-----------------------------------------------
-;;; History ::
+;;; Change Log:
 ;;;-----------------------------------------------
 ;;;    Sometime in '84 Brewster implemented a somewhat buggy version for 
 ;;; Symbolics LISPMs.
 ;;;  - added backup protection to save-completions-to-file (prevents 
 ;;;    problems with disk full errors)
 \f
+;;; Code:
+
 ;;;-----------------------------------------------
 ;;; Requires
 ;;; Version
@@ -1494,7 +1503,8 @@ Sets up cmpl-db-downcase-string and cmpl-db-symbol."
        ))
 
 (defun find-cmpl-prefix-entry (prefix-string)
-  "Returns the prefix entry for string. Sets cmpl-db-prefix-symbol.
+  "Returns the prefix entry for string.
+Sets cmpl-db-prefix-symbol.
 Prefix-string must be exactly *completion-prefix-min-length* long
 and downcased.  Sets up cmpl-db-prefix-symbol."
   (and (boundp (setq cmpl-db-prefix-symbol
@@ -1505,8 +1515,9 @@ and downcased.  Sets up cmpl-db-prefix-symbol."
 ;; used to trap lossage in silent error correction
 
 (defun locate-completion-entry (completion-entry prefix-entry)
-  "Locates the completion entry.  Returns a pointer to the element
-before the completion entry or nil if the completion entry is at the head.
+  "Locates the completion entry.
+Returns a pointer to the element before the completion entry or nil if
+the completion entry is at the head.
 Must be called after find-exact-completion."
   (let ((prefix-list (cmpl-prefix-entry-head prefix-entry))
         next-prefix-list
@@ -1562,9 +1573,10 @@ Must be called after find-exact-completion."
 
 ;;; WRITES
 (defun add-completion-to-tail-if-new (string)
-  "If the string is not in the database it is added to the end of the
-approppriate prefix list with num-uses = 0.  The database is unchanged if it 
-is there.  string must be longer than *completion-prefix-min-length*.
+  "If STRING is not in the database add it to appropriate prefix list.
+STRING is added to the end of the approppriate prefix list with
+num-uses = 0.  The database is unchanged if it is there.  STRING must be
+longer than *completion-prefix-min-length*.
 This must be very fast.
 Returns the completion entry."
   (or (find-exact-completion string)
@@ -1595,9 +1607,10 @@ Returns the completion entry."
        )))
 
 (defun add-completion-to-head (string)
-  "If the string is not in the database it is added to the head of the
-approppriate prefix list.  Otherwise it is moved to the head of the list.
-string must be longer than *completion-prefix-min-length*.
+  "If STRING is not in the database, add it to prefix list.
+STRING is added to the head of the approppriate prefix list.  Otherwise
+it is moved to the head of the list.  STRING must be longer than
+*completion-prefix-min-length*.
 Updates the saved string with the supplied string.
 This must be very fast.
 Returns the completion entry."
@@ -1653,8 +1666,8 @@ Returns the completion entry."
       )))
       
 (defun delete-completion (string)
-  "Deletes the completion from the database.  string must be longer than
-*completion-prefix-min-length*."
+  "Deletes the completion from the database.
+String must be longer than *completion-prefix-min-length*."
   ;; Handle pending acceptance
   (if completion-to-accept (accept-completion))
   (if (setq cmpl-db-entry (find-exact-completion string))
@@ -1804,30 +1817,28 @@ completion-search-reset."
     ))
 
 (defun use-completion-under-point ()
-  "Call this to add the completion symbol underneath the point into
-the completion buffer."
+  "Adds the completion symbol underneath the point into the completion buffer."
   (let ((string (and *completep* (symbol-under-point)))
        (current-completion-source cmpl-source-cursor-moves))
     (if string (add-completion-to-head string))))
        
 (defun use-completion-before-point ()
-  "Call this to add the completion symbol before point into
+  "Adds the completion symbol before point into
 the completion buffer."
   (let ((string (and *completep* (symbol-before-point)))
        (current-completion-source cmpl-source-cursor-moves))
     (if string (add-completion-to-head string))))
 
 (defun use-completion-under-or-before-point ()
-  "Call this to add the completion symbol before point into
-the completion buffer."
+  "Adds the completion symbol before point into the completion buffer."
   (let ((string (and *completep* (symbol-under-or-before-point)))
        (current-completion-source cmpl-source-cursor-moves))
     (if string (add-completion-to-head string))))
 
 (defun use-completion-before-separator ()
-  "Call this to add the completion symbol before point into
-the completion buffer.  Completions added this way will automatically be
-saved if *separator-character-uses-completion-p* is non-nil."
+  "Adds the completion symbol before point into the completion buffer.
+Completions added this way will automatically be saved if
+*separator-character-uses-completion-p* is non-nil."
   (let ((string (and *completep* (symbol-before-point)))
        (current-completion-source cmpl-source-separator)
        entry)
@@ -1917,9 +1928,9 @@ String must be longer than *completion-prefix-min-length*."
        ))
 
 (defun completion-search-next (index)
-  "Returns the next completion entry.  If index is out of sequence it resets
-and starts from the top.  If there are no more entries it tries cdabbrev and 
-returns only a string."
+  "Returns the next completion entry.
+If index is out of sequence it resets and starts from the top.
+If there are no more entries it tries cdabbrev and returns only a string."
   (cond
     ((= index (setq cmpl-last-index (1+ cmpl-last-index)))
      (completion-search-peek t))
@@ -2509,8 +2520,7 @@ completion database."
 ;;;---------------------------------------------------------------------------
 
 (defun kill-emacs-save-completions ()
-  "The version of save-completions-to-file called at kill-emacs
-time."
+  "The version of save-completions-to-file called at kill-emacs time."
   (when (and *save-completions-p* *completep* cmpl-initialized-p)
     (cond
       ((not cmpl-completions-accepted-p)
@@ -2534,8 +2544,8 @@ time."
   (concat filename ".BAK"))
 
 (defun save-completions-to-file (&optional filename)
-  "Saves a completion init file.  If file is not specified,
-   then *saved-completions-filename* is used."
+  "Saves a completion init file.
+If file is not specified, then *saved-completions-filename* is used."
   (interactive)
   (setq filename (expand-file-name (or filename *saved-completions-filename*)))
   (when (file-writable-p filename)
@@ -2641,8 +2651,8 @@ time."
 (pushnew 'autosave-completions cmpl-emacs-idle-time-hooks)
 
 (defun load-completions-from-file (&optional filename no-message-p)
-  "loads a completion init file.  If file is not specified,
-   then *saved-completions-filename* is used"
+  "Loads a completion init file.
+If file is not specified, then *saved-completions-filename* is used."
   (interactive)
   (setq filename (expand-file-name (or filename *saved-completions-filename*)))
   (let* ((backup-filename (completion-backup-filename filename))
@@ -2745,8 +2755,8 @@ time."
          )))))
 
 (defun initialize-completions ()
-  "Loads the default completions file and sets up so that exiting emacs will
-automatically save the file."
+  "Loads the default completions file.
+Also sets up so that exiting emacs will automatically save the file."
   (interactive)
   (cond ((not cmpl-initialized-p)
         (load-completions-from-file)
@@ -2832,8 +2842,8 @@ Patched to remove the most recent completion."
   (use-completion-before-separator)
   (self-insert-command arg)
   (and (> (current-column) fill-column)
-       auto-fill-hook
-       (funcall auto-fill-hook))
+       auto-fill-function
+       (funcall auto-fill-function))
   )
 
 ;;;-----------------------------------------------
@@ -2844,9 +2854,8 @@ Patched to remove the most recent completion."
 ;;; the functions defined with this macro get byte compiled.
 
 (defmacro def-completion-wrapper (function-name type &optional new-name)
-  "Add a call to update the completion database before the function is
-executed.  TYPE is the type of the wrapper to be added.  Can be :before or
-:under."
+  "Add a call to update the completion database before function execution.
+TYPE is the type of the wrapper to be added.  Can be :before or :under."
   (completion-advise-1
    function-name ':before
    (ecase type
@@ -3111,3 +3120,5 @@ and KILLP is t if prefix arg is was specified."
 
 (cmpl-statistics-block
   (record-completion-file-loaded))
+
+;;; completion.el ends here