Mercurial > emacs
changeset 67933:679e4542aaa9
(bibtex-mode): Make completion-ignore-case
buffer-local because choose-completion-delete-max-match requires
that we set completion-ignore-case (i.e., binding via let is not
sufficient).
(bibtex-complete): Always set completion-ignore-case and
choose-completion-string-functions. The latter is needed because
choose-completion-string-functions keeps its value if we quit the
*Completions* buffer without requesting a completion.
author | Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> |
---|---|
date | Fri, 30 Dec 2005 17:00:32 +0000 |
parents | f894d959817d |
children | 83b7f7a9b7c9 |
files | lisp/textmodes/bibtex.el |
diffstat | 1 files changed, 40 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/textmodes/bibtex.el Fri Dec 30 16:57:55 2005 +0000 +++ b/lisp/textmodes/bibtex.el Fri Dec 30 17:00:32 2005 +0000 @@ -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'."