diff options
| author | Roland Winkler | 2005-12-30 17:00:32 +0000 |
|---|---|---|
| committer | Roland Winkler | 2005-12-30 17:00:32 +0000 |
| commit | 5e860c2408d5ba7c81b33fba29b74cb095ec7191 (patch) | |
| tree | 82f5fca550c1af5051ca291e95146cc92e33cd6e | |
| parent | 07467c092d1a88bacd23a50512da2c49e3d93858 (diff) | |
| download | emacs-5e860c2408d5ba7c81b33fba29b74cb095ec7191.tar.gz emacs-5e860c2408d5ba7c81b33fba29b74cb095ec7191.zip | |
(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.
| -rw-r--r-- | lisp/textmodes/bibtex.el | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index fd84d749b86..10b2ca206e9 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el | |||
| @@ -2470,6 +2470,7 @@ already set." | |||
| 2470 | "Complete word fragment before point to longest prefix of COMPLETIONS. | 2470 | "Complete word fragment before point to longest prefix of COMPLETIONS. |
| 2471 | COMPLETIONS is an alist of strings. If point is not after the part | 2471 | COMPLETIONS is an alist of strings. If point is not after the part |
| 2472 | of a word, all strings are listed. Return completion." | 2472 | of a word, all strings are listed. Return completion." |
| 2473 | ;; Return value is used by cleanup functions. | ||
| 2473 | (let* ((case-fold-search t) | 2474 | (let* ((case-fold-search t) |
| 2474 | (beg (save-excursion | 2475 | (beg (save-excursion |
| 2475 | (re-search-backward "[ \t{\"]") | 2476 | (re-search-backward "[ \t{\"]") |
| @@ -2492,7 +2493,6 @@ of a word, all strings are listed. Return completion." | |||
| 2492 | (display-completion-list (all-completions part-of-word completions) | 2493 | (display-completion-list (all-completions part-of-word completions) |
| 2493 | part-of-word)) | 2494 | part-of-word)) |
| 2494 | (message "Making completion list...done") | 2495 | (message "Making completion list...done") |
| 2495 | ;; return value is handled by choose-completion-string-functions | ||
| 2496 | nil)))) | 2496 | nil)))) |
| 2497 | 2497 | ||
| 2498 | (defun bibtex-complete-string-cleanup (str compl) | 2498 | (defun bibtex-complete-string-cleanup (str compl) |
| @@ -2783,6 +2783,7 @@ if that value is non-nil. | |||
| 2783 | (list (list nil bibtex-entry-head bibtex-key-in-head)) | 2783 | (list (list nil bibtex-entry-head bibtex-key-in-head)) |
| 2784 | imenu-case-fold-search t) | 2784 | imenu-case-fold-search t) |
| 2785 | (make-local-variable 'choose-completion-string-functions) | 2785 | (make-local-variable 'choose-completion-string-functions) |
| 2786 | (make-local-variable 'completion-ignore-case) | ||
| 2786 | ;; XEmacs needs easy-menu-add, Emacs does not care | 2787 | ;; XEmacs needs easy-menu-add, Emacs does not care |
| 2787 | (easy-menu-add bibtex-edit-menu) | 2788 | (easy-menu-add bibtex-edit-menu) |
| 2788 | (easy-menu-add bibtex-entry-menu) | 2789 | (easy-menu-add bibtex-entry-menu) |
| @@ -4152,41 +4153,53 @@ An error is signaled if point is outside key or BibTeX field." | |||
| 4152 | 4153 | ||
| 4153 | (cond ((eq compl 'key) | 4154 | (cond ((eq compl 'key) |
| 4154 | ;; key completion: no cleanup needed | 4155 | ;; key completion: no cleanup needed |
| 4155 | (let (completion-ignore-case) | 4156 | (setq choose-completion-string-functions nil |
| 4156 | (bibtex-complete-internal (bibtex-global-key-alist)))) | 4157 | completion-ignore-case nil) |
| 4158 | (bibtex-complete-internal (bibtex-global-key-alist))) | ||
| 4157 | 4159 | ||
| 4158 | ((eq compl 'crossref-key) | 4160 | ((eq compl 'crossref-key) |
| 4159 | ;; crossref key completion | 4161 | ;; crossref key completion |
| 4160 | (let (completion-ignore-case) | 4162 | ;; |
| 4161 | (setq choose-completion-string-functions | 4163 | ;; If we quit the *Completions* buffer without requesting |
| 4162 | (lambda (choice buffer mini-p base-size) | 4164 | ;; a completion, `choose-completion-string-functions' is still |
| 4163 | (let ((choose-completion-string-functions nil)) | 4165 | ;; non-nil. Therefore, `choose-completion-string-functions' is |
| 4164 | (choose-completion-string choice buffer base-size)) | 4166 | ;; always set (either to non-nil or nil) when a new completion |
| 4165 | (bibtex-complete-crossref-cleanup choice) | 4167 | ;; is requested. |
| 4166 | ;; return t (needed by choose-completion-string-functions) | 4168 | ;; Also, `choose-completion-delete-max-match' requires |
| 4167 | t)) | 4169 | ;; that we set `completion-ignore-case' (i.e., binding via `let' |
| 4168 | (bibtex-complete-crossref-cleanup (bibtex-complete-internal | 4170 | ;; is not sufficient). |
| 4169 | (bibtex-global-key-alist))))) | 4171 | (setq completion-ignore-case nil |
| 4172 | choose-completion-string-functions | ||
| 4173 | (lambda (choice buffer mini-p base-size) | ||
| 4174 | (setq choose-completion-string-functions nil) | ||
| 4175 | (choose-completion-string choice buffer base-size) | ||
| 4176 | (bibtex-complete-crossref-cleanup choice) | ||
| 4177 | t)) ; needed by choose-completion-string-functions | ||
| 4178 | |||
| 4179 | (bibtex-complete-crossref-cleanup (bibtex-complete-internal | ||
| 4180 | (bibtex-global-key-alist)))) | ||
| 4170 | 4181 | ||
| 4171 | ((eq compl 'string) | 4182 | ((eq compl 'string) |
| 4172 | ;; string key completion: no cleanup needed | 4183 | ;; string key completion: no cleanup needed |
| 4173 | (let ((completion-ignore-case t)) | 4184 | (setq choose-completion-string-functions nil |
| 4174 | (bibtex-complete-internal bibtex-strings))) | 4185 | completion-ignore-case t) |
| 4186 | (bibtex-complete-internal bibtex-strings)) | ||
| 4175 | 4187 | ||
| 4176 | (compl | 4188 | (compl |
| 4177 | ;; string completion | 4189 | ;; string completion |
| 4178 | (let ((completion-ignore-case t)) | 4190 | (setq completion-ignore-case t |
| 4179 | (setq choose-completion-string-functions | 4191 | choose-completion-string-functions |
| 4180 | `(lambda (choice buffer mini-p base-size) | 4192 | `(lambda (choice buffer mini-p base-size) |
| 4181 | (let ((choose-completion-string-functions nil)) | 4193 | (setq choose-completion-string-functions nil) |
| 4182 | (choose-completion-string choice buffer base-size)) | 4194 | (choose-completion-string choice buffer base-size) |
| 4183 | (bibtex-complete-string-cleanup choice ',compl) | 4195 | (bibtex-complete-string-cleanup choice ',compl) |
| 4184 | ;; return t (needed by choose-completion-string-functions) | 4196 | t)) ; needed by choose-completion-string-functions |
| 4185 | t)) | 4197 | (bibtex-complete-string-cleanup (bibtex-complete-internal compl) |
| 4186 | (bibtex-complete-string-cleanup (bibtex-complete-internal compl) | 4198 | compl)) |
| 4187 | compl))) | 4199 | |
| 4188 | 4200 | (t (setq choose-completion-string-functions nil | |
| 4189 | (t (error "Point outside key or BibTeX field"))))) | 4201 | completion-ignore-case nil) ; default |
| 4202 | (error "Point outside key or BibTeX field"))))) | ||
| 4190 | 4203 | ||
| 4191 | (defun bibtex-Article () | 4204 | (defun bibtex-Article () |
| 4192 | "Insert a new BibTeX @Article entry; see also `bibtex-entry'." | 4205 | "Insert a new BibTeX @Article entry; see also `bibtex-entry'." |