changeset 106385:cd8b405d57c6

(bibtex-complete-internal): Use completion-in-region. (bibtex-text-in-field-bounds): Remove unused var `opoint'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 03 Dec 2009 05:41:17 +0000
parents 8272f561b710
children d1166d927ca2
files lisp/ChangeLog lisp/textmodes/bibtex.el
diffstat 2 files changed, 12 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Dec 03 04:08:08 2009 +0000
+++ b/lisp/ChangeLog	Thu Dec 03 05:41:17 2009 +0000
@@ -1,3 +1,9 @@
+2009-12-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* textmodes/bibtex.el (bibtex-complete-internal):
+	Use completion-in-region.
+	(bibtex-text-in-field-bounds): Remove unused var `opoint'.
+
 2009-12-03  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	Support applying stashes.  Improve UI.
--- a/lisp/textmodes/bibtex.el	Thu Dec 03 04:08:08 2009 +0000
+++ b/lisp/textmodes/bibtex.el	Thu Dec 03 05:41:17 2009 +0000
@@ -1513,8 +1513,8 @@
       (save-excursion
         (goto-char (bibtex-start-of-text-in-field bounds))
         (let ((epoint (bibtex-end-of-text-in-field bounds))
-              content opoint)
-          (while (< (setq opoint (point)) epoint)
+              content)
+          (while (< (point) epoint)
             (if (looking-at bibtex-field-const)
                 (let ((mtch (match-string-no-properties 0)))
                   (push (or (if bibtex-expand-strings
@@ -2702,35 +2702,13 @@
 of a word, all strings are listed.  Return completion."
   ;; Return value is used by cleanup functions.
   ;; Code inspired by `lisp-complete-symbol'.
-  (let* ((case-fold-search t)
-         (beg (save-excursion
+  (let ((beg (save-excursion
                 (re-search-backward "[ \t{\"]")
                 (forward-char)
                 (point)))
-         (end (point))
-         (pattern (buffer-substring-no-properties beg end))
-         (completion (try-completion pattern completions)))
-    (cond ((not completion)
-           (error "Can't find completion for `%s'" pattern))
-          ((eq completion t)
-           pattern)
-          ((not (string= pattern completion))
-           (delete-region beg end)
-           (insert completion)
-           ;; Don't leave around a completions buffer that's out of date.
-           (let ((win (get-buffer-window "*Completions*" 0)))
-             (if win (with-selected-window win (bury-buffer))))
-           completion)
-          (t
-           (let ((minibuf-is-in-use
-                  (eq (minibuffer-window) (selected-window))))
-             (unless minibuf-is-in-use (message "Making completion list..."))
-             (with-output-to-temp-buffer "*Completions*"
-               (display-completion-list
-                (sort (all-completions pattern completions) 'string<) pattern))
-             (unless minibuf-is-in-use
-               (message "Making completion list...done")))
-           nil))))
+        (end (point)))
+    (when (completion-in-region beg end completions)
+      (buffer-substring beg (point)))))
 
 (defun bibtex-complete-string-cleanup (str compl)
   "Cleanup after inserting string STR.