]> code.delx.au - gnu-emacs/blobdiff - lisp/completion.el
Add 2013 to yet more FSF copyright years
[gnu-emacs] / lisp / completion.el
index 6a5c06a62b62d02bf5533d3aea113897500f0c7d..974d59c9af5729a8fc35b50660fc9375c71203bc 100644 (file)
@@ -1,7 +1,7 @@
 ;;; completion.el --- dynamic word-completion code
 
-;; Copyright (C) 1990, 1993, 1995, 1997, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1993, 1995, 1997, 2001-2013 Free Software
+;; Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: abbrev convenience
 ;; superior to that of the LISPM version.
 ;;
 ;;-----------------------------------------------
-;; Acknowledgements
+;; Acknowledgments
 ;;-----------------------------------------------
 ;;  Cliff Lasser (cal@think.com), Kevin Herbert (kph@cisco.com),
 ;;  eero@media-lab, kgk@cs.brown.edu, jla@ai.mit.edu,
@@ -296,13 +296,7 @@ See also `save-completions-retention-time'."
   :group 'completion)
 
 (defcustom save-completions-file-name
-  (let ((olddef (convert-standard-filename "~/.completions")))
-    (cond
-     ((file-readable-p olddef) olddef)
-     ((file-directory-p user-emacs-directory)
-      (convert-standard-filename
-       (expand-file-name "completions" user-emacs-directory)))
-     (t olddef)))
+  (locate-user-emacs-file "completions" ".completions")
   "The filename to save completions to."
   :type 'file
   :group 'completion)
@@ -350,18 +344,18 @@ are automatically added to the completion database."
   :group 'completion)
 
 ;;(defvar *record-cmpl-statistics-p* nil
-;;  "*If non-nil, record completion statistics.")
+;;  "If non-nil, record completion statistics.")
 
 ;;(defvar *completion-auto-save-period* 1800
-;;  "*The period in seconds to wait for emacs to be idle before autosaving
+;;  "The period in seconds to wait for emacs to be idle before autosaving
 ;;the completions.  Default is a 1/2 hour.")
 
 (defvar completion-min-length 6
-  "*The minimum length of a stored completion.
+  "The minimum length of a stored completion.
 DON'T CHANGE WITHOUT RECOMPILING !  This is used by macros.")
 
 (defvar completion-max-length 200
-  "*The maximum length of a stored completion.
+  "The maximum length of a stored completion.
 DON'T CHANGE WITHOUT RECOMPILING !  This is used by macros.")
 
 (defvar completion-prefix-min-length 3
@@ -701,7 +695,7 @@ Returns nil if there isn't one longer than `completion-min-length'."
 ;; Conditionalizing code on *record-cmpl-statistics-p*
 ;;-----------------------------------------------
 ;; All statistics code outside this block should use this
-(defmacro cmpl-statistics-block (&rest body))
+(defmacro cmpl-statistics-block (&rest _body))
 ;;  "Only executes body if we are recording statistics."
 ;;  (list 'cond
 ;;     (list* '*record-cmpl-statistics-p* body)
@@ -1169,7 +1163,7 @@ Returns the completion entry."
 (defun add-completion-to-head (completion-string)
   "If COMPLETION-STRING is not in the database, add it to prefix list.
 We add COMPLETION-STRING to the head of the appropriate prefix list,
-or it to the head of the list.
+or to the head of the list.
 COMPLETION-STRING must be longer than `completion-prefix-min-length'.
 Updates the saved string with the supplied string.
 This must be very fast.
@@ -1307,17 +1301,17 @@ String must be longer than `completion-prefix-min-length'."
 
 (defun check-completion-length (string)
   (if (< (length string) completion-min-length)
-      (error "The string `%s' is too short to be saved as a completion"
-            string)
+      (user-error "The string `%s' is too short to be saved as a completion"
+                  string)
       (list string)))
 
 (defun add-completion (string &optional num-uses last-use-time)
   "Add STRING to completion list, or move it to head of list.
-The completion is altered appropriately if num-uses and/or last-use-time is
-specified."
+The completion is altered appropriately if NUM-USES and/or LAST-USE-TIME
+are specified."
   (interactive (interactive-completion-string-reader "Completion to add"))
   (check-completion-length string)
-  (let* ((current-completion-source (if (interactive-p)
+  (let* ((current-completion-source (if (called-interactively-p 'interactive)
                                        cmpl-source-interactive
                                        current-completion-source))
         (entry (add-completion-to-head string)))
@@ -1330,7 +1324,7 @@ specified."
   "Add STRING if it isn't already listed, and mark it permanent."
   (interactive
     (interactive-completion-string-reader "Completion to add permanently"))
-  (let ((current-completion-source (if (interactive-p)
+  (let ((current-completion-source (if (called-interactively-p 'interactive)
                                       cmpl-source-interactive
                                       current-completion-source)))
     (add-completion string nil t)))
@@ -1463,7 +1457,7 @@ STRING must be longer than `completion-prefix-min-length'."
 (defun completion-search-next (index)
   "Return the next completion entry.
 If INDEX is out of sequence, reset and start from the top.
-If there are no more entries, try cdabbrev and returns only a string."
+If there are no more entries, try cdabbrev and return only a string."
   (cond
     ((= index (setq cmpl-last-index (1+ cmpl-last-index)))
      (completion-search-peek t))
@@ -1699,7 +1693,7 @@ Prefix args ::
 
 ;; User interface
 (defun add-completions-from-file (file)
-  "Parse possible completions from a FILE and add them to data base."
+  "Parse possible completions from a FILE and add them to database."
   (interactive "fFile: ")
   (setq file (expand-file-name file))
   (let* ((buffer (get-file-buffer file))
@@ -1757,7 +1751,7 @@ Prefix args ::
   (save-excursion
     (goto-char (point-min))
     (let (string)
-      (condition-case e
+      (condition-case nil
           (while t
             (search-forward "\177")
             (backward-char 3)
@@ -1794,7 +1788,7 @@ Prefix args ::
   (let (string)
     (save-excursion
       (goto-char (point-min))
-      (condition-case e
+      (condition-case nil
           (while t
             (re-search-forward *lisp-def-regexp*)
             (and (setq string (symbol-under-point))
@@ -2048,7 +2042,7 @@ If file name is not specified, use `save-completions-file-name'."
                                                    last-use-time)) "\n"))))
 
            ;; write the buffer
-           (condition-case e
+           (condition-case nil
                (let ((file-exists-p (file-exists-p filename)))
                  (if file-exists-p
                      (progn
@@ -2114,7 +2108,7 @@ If file is not specified, then use `save-completions-file-name'."
                    (aref completion-add-count-vector cmpl-source-file-parsing)))
                  (total-in-file 0) (total-perm 0))
              ;; insert the file into a buffer
-             (condition-case e
+             (condition-case nil
                  (progn (insert-file-contents filename t)
                         (setq insert-okay-p t))
 
@@ -2126,7 +2120,7 @@ If file is not specified, then use `save-completions-file-name'."
                  (progn
                    (goto-char (point-min))
 
-                   (condition-case e
+                   (condition-case nil
                        (while t
                          (setq entry (read buffer))
                          (setq total-in-file (1+ total-in-file))
@@ -2343,7 +2337,10 @@ TYPE is the type of the wrapper to be added.  Can be :before or :under."
 
 ;;;###autoload
 (define-minor-mode dynamic-completion-mode
-  "Enable dynamic word-completion."
+  "Toggle dynamic word-completion on or off.
+With a prefix argument ARG, enable the mode if ARG is positive,
+and disable it otherwise.  If called from Lisp, enable the mode
+if ARG is omitted or nil."
   :global t
   ;; This is always good, not specific to dynamic-completion-mode.
   (define-key function-key-map [C-return] [?\C-\r])
@@ -2470,11 +2467,6 @@ TYPE is the type of the wrapper to be added.  Can be :before or :under."
 (defvaralias 'cmpl-syntax-table 'completion-syntax-table)
 (defalias 'initialize-completions 'completion-initialize)
 
-(dolist (x '("^To complete, the point must be after a symbol at least [0-9]* character long\\.$"
-       "^The string \".*\" is too short to be saved as a completion\\.$"))
-  (add-to-list 'debug-ignored-errors x))
-
 (provide 'completion)
 
-;; arch-tag: 6990dafe-4abd-4a1f-8c42-ffb25e120f5e
 ;;; completion.el ends here