emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/textmodes/bibtex.el


From: Roland Winkler
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/bibtex.el
Date: Fri, 30 Dec 2005 17:00:32 +0000

Index: emacs/lisp/textmodes/bibtex.el
diff -u emacs/lisp/textmodes/bibtex.el:1.106 
emacs/lisp/textmodes/bibtex.el:1.107
--- emacs/lisp/textmodes/bibtex.el:1.106        Thu Dec 29 17:10:53 2005
+++ emacs/lisp/textmodes/bibtex.el      Fri Dec 30 17:00:32 2005
@@ -2470,6 +2470,7 @@
   "Complete word fragment before point to longest prefix of COMPLETIONS.
 COMPLETIONS is an alist of strings.  If point is not after the part
 of a word, all strings are listed.  Return completion."
+  ;; Return value is used by cleanup functions.
   (let* ((case-fold-search t)
          (beg (save-excursion
                 (re-search-backward "[ \t{\"]")
@@ -2492,7 +2493,6 @@
              (display-completion-list (all-completions part-of-word 
completions)
                                      part-of-word))
            (message "Making completion list...done")
-           ;; return value is handled by choose-completion-string-functions
            nil))))
 
 (defun bibtex-complete-string-cleanup (str compl)
@@ -2783,6 +2783,7 @@
         (list (list nil bibtex-entry-head bibtex-key-in-head))
         imenu-case-fold-search t)
   (make-local-variable 'choose-completion-string-functions)
+  (make-local-variable 'completion-ignore-case)
   ;; XEmacs needs easy-menu-add, Emacs does not care
   (easy-menu-add bibtex-edit-menu)
   (easy-menu-add bibtex-entry-menu)
@@ -4152,41 +4153,53 @@
 
     (cond ((eq compl 'key)
            ;; key completion: no cleanup needed
-           (let (completion-ignore-case)
-             (bibtex-complete-internal (bibtex-global-key-alist))))
+           (setq choose-completion-string-functions nil
+                 completion-ignore-case nil)
+           (bibtex-complete-internal (bibtex-global-key-alist)))
 
           ((eq compl 'crossref-key)
            ;; crossref key completion
-           (let (completion-ignore-case)
-             (setq choose-completion-string-functions
-                   (lambda (choice buffer mini-p base-size)
-                     (let ((choose-completion-string-functions nil))
-                       (choose-completion-string choice buffer base-size))
-                     (bibtex-complete-crossref-cleanup choice)
-                     ;; return t (needed by choose-completion-string-functions)
-                     t))
-             (bibtex-complete-crossref-cleanup (bibtex-complete-internal
-                                                (bibtex-global-key-alist)))))
+           ;;
+           ;; If we quit the *Completions* buffer without requesting
+           ;; a completion, `choose-completion-string-functions' is still
+           ;; non-nil. Therefore, `choose-completion-string-functions' is
+           ;; always set (either to non-nil or nil) when a new completion
+           ;; is requested.
+           ;; Also, `choose-completion-delete-max-match' requires
+           ;; that we set `completion-ignore-case' (i.e., binding via `let'
+           ;; is not sufficient).
+           (setq completion-ignore-case nil
+                 choose-completion-string-functions
+                 (lambda (choice buffer mini-p base-size)
+                   (setq choose-completion-string-functions nil)
+                   (choose-completion-string choice buffer base-size)
+                   (bibtex-complete-crossref-cleanup choice)
+                   t)) ; needed by choose-completion-string-functions
+
+           (bibtex-complete-crossref-cleanup (bibtex-complete-internal
+                                              (bibtex-global-key-alist))))
 
           ((eq compl 'string)
            ;; string key completion: no cleanup needed
-           (let ((completion-ignore-case t))
-             (bibtex-complete-internal bibtex-strings)))
+           (setq choose-completion-string-functions nil
+                 completion-ignore-case t)
+           (bibtex-complete-internal bibtex-strings))
 
           (compl
            ;; string completion
-           (let ((completion-ignore-case t))
-             (setq choose-completion-string-functions
-                   `(lambda (choice buffer mini-p base-size)
-                      (let ((choose-completion-string-functions nil))
-                        (choose-completion-string choice buffer base-size))
-                      (bibtex-complete-string-cleanup choice ',compl)
-                      ;; return t (needed by 
choose-completion-string-functions)
-                      t))
-             (bibtex-complete-string-cleanup (bibtex-complete-internal compl)
-                                             compl)))
-
-          (t (error "Point outside key or BibTeX field")))))
+           (setq completion-ignore-case t
+                 choose-completion-string-functions
+                 `(lambda (choice buffer mini-p base-size)
+                    (setq choose-completion-string-functions nil)
+                    (choose-completion-string choice buffer base-size)
+                    (bibtex-complete-string-cleanup choice ',compl)
+                    t)) ; needed by choose-completion-string-functions
+           (bibtex-complete-string-cleanup (bibtex-complete-internal compl)
+                                             compl))
+
+          (t (setq choose-completion-string-functions nil
+                   completion-ignore-case nil) ; default
+             (error "Point outside key or BibTeX field")))))
 
 (defun bibtex-Article ()
   "Insert a new BibTeX @Article entry; see also `bibtex-entry'."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]