aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-12-03 05:41:17 +0000
committerStefan Monnier2009-12-03 05:41:17 +0000
commit842d73a12ebe59c92c5140799c135a6d19d04cc8 (patch)
tree2e0b15882ac7f7d04b111071d2ea3297ffed7cfe
parent7fa4876f18cdbd6a70898835df8c01615801c2fa (diff)
downloademacs-842d73a12ebe59c92c5140799c135a6d19d04cc8.tar.gz
emacs-842d73a12ebe59c92c5140799c135a6d19d04cc8.zip
(bibtex-complete-internal): Use completion-in-region.
(bibtex-text-in-field-bounds): Remove unused var `opoint'.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/textmodes/bibtex.el34
2 files changed, 12 insertions, 28 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dd43a497686..e4e9696ab8b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12009-12-03 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * textmodes/bibtex.el (bibtex-complete-internal):
4 Use completion-in-region.
5 (bibtex-text-in-field-bounds): Remove unused var `opoint'.
6
12009-12-03 Dan Nicolaescu <dann@ics.uci.edu> 72009-12-03 Dan Nicolaescu <dann@ics.uci.edu>
2 8
3 Support applying stashes. Improve UI. 9 Support applying stashes. Improve UI.
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index bede8184e88..0f2674cd99e 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -1513,8 +1513,8 @@ If `bibtex-expand-strings' is non-nil, also expand BibTeX strings."
1513 (save-excursion 1513 (save-excursion
1514 (goto-char (bibtex-start-of-text-in-field bounds)) 1514 (goto-char (bibtex-start-of-text-in-field bounds))
1515 (let ((epoint (bibtex-end-of-text-in-field bounds)) 1515 (let ((epoint (bibtex-end-of-text-in-field bounds))
1516 content opoint) 1516 content)
1517 (while (< (setq opoint (point)) epoint) 1517 (while (< (point) epoint)
1518 (if (looking-at bibtex-field-const) 1518 (if (looking-at bibtex-field-const)
1519 (let ((mtch (match-string-no-properties 0))) 1519 (let ((mtch (match-string-no-properties 0)))
1520 (push (or (if bibtex-expand-strings 1520 (push (or (if bibtex-expand-strings
@@ -2702,35 +2702,13 @@ COMPLETIONS is an alist of strings. If point is not after the part
2702of a word, all strings are listed. Return completion." 2702of a word, all strings are listed. Return completion."
2703 ;; Return value is used by cleanup functions. 2703 ;; Return value is used by cleanup functions.
2704 ;; Code inspired by `lisp-complete-symbol'. 2704 ;; Code inspired by `lisp-complete-symbol'.
2705 (let* ((case-fold-search t) 2705 (let ((beg (save-excursion
2706 (beg (save-excursion
2707 (re-search-backward "[ \t{\"]") 2706 (re-search-backward "[ \t{\"]")
2708 (forward-char) 2707 (forward-char)
2709 (point))) 2708 (point)))
2710 (end (point)) 2709 (end (point)))
2711 (pattern (buffer-substring-no-properties beg end)) 2710 (when (completion-in-region beg end completions)
2712 (completion (try-completion pattern completions))) 2711 (buffer-substring beg (point)))))
2713 (cond ((not completion)
2714 (error "Can't find completion for `%s'" pattern))
2715 ((eq completion t)
2716 pattern)
2717 ((not (string= pattern completion))
2718 (delete-region beg end)
2719 (insert completion)
2720 ;; Don't leave around a completions buffer that's out of date.
2721 (let ((win (get-buffer-window "*Completions*" 0)))
2722 (if win (with-selected-window win (bury-buffer))))
2723 completion)
2724 (t
2725 (let ((minibuf-is-in-use
2726 (eq (minibuffer-window) (selected-window))))
2727 (unless minibuf-is-in-use (message "Making completion list..."))
2728 (with-output-to-temp-buffer "*Completions*"
2729 (display-completion-list
2730 (sort (all-completions pattern completions) 'string<) pattern))
2731 (unless minibuf-is-in-use
2732 (message "Making completion list...done")))
2733 nil))))
2734 2712
2735(defun bibtex-complete-string-cleanup (str compl) 2713(defun bibtex-complete-string-cleanup (str compl)
2736 "Cleanup after inserting string STR. 2714 "Cleanup after inserting string STR.