;;; completion.el --- dynamic word-completion code
-;; Copyright (C) 1990, 1993, 1995, 1997, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1993, 1995, 1997, 2001-2012
+;; Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: abbrev convenience
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs 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 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
: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)
;; 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)
(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.
(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)))
"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)))
(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))
;; 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))
(save-excursion
(goto-char (point-min))
(let (string)
- (condition-case e
+ (condition-case nil
(while t
(search-forward "\177")
(backward-char 3)
(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))
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
(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))
(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))
(provide 'completion)
-;; arch-tag: 6990dafe-4abd-4a1f-8c42-ffb25e120f5e
;;; completion.el ends here