diff options
| author | Stefan Monnier | 2011-09-14 17:43:36 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2011-09-14 17:43:36 -0400 |
| commit | 3fe48822c39477d6e1b5fe566c00ccbb631cdb8e (patch) | |
| tree | 11a53b97bbfca9ca8a43e9841b64b25de6014078 | |
| parent | 1b8b395447e2c4d417e98ec1656e357b15ecadeb (diff) | |
| download | emacs-3fe48822c39477d6e1b5fe566c00ccbb631cdb8e.tar.gz emacs-3fe48822c39477d6e1b5fe566c00ccbb631cdb8e.zip | |
* textmodes/bibtex.el (bibtex-complete-string-cleanup)
(bibtex-complete-crossref-cleanup): Adjust to accommodate needs of
bibtex-completion-at-point-function.
(bibtex-completion-at-point-function): Use them.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/textmodes/bibtex.el | 50 |
2 files changed, 24 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 975cd34ba60..a8c50789a84 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2011-09-14 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2011-09-14 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * textmodes/bibtex.el (bibtex-complete-string-cleanup) | ||
| 4 | (bibtex-complete-crossref-cleanup): Adjust to accommodate needs of | ||
| 5 | bibtex-completion-at-point-function. | ||
| 6 | (bibtex-completion-at-point-function): Use them. | ||
| 7 | |||
| 3 | * newcomment.el (comment-add, comment-valid-prefix-p): Docfix. | 8 | * newcomment.el (comment-add, comment-valid-prefix-p): Docfix. |
| 4 | 9 | ||
| 5 | * mpc.el (mpc-constraints-tag-lookup): New function. | 10 | * mpc.el (mpc-constraints-tag-lookup): New function. |
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index 3efb2f158c0..741b6cd904c 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el | |||
| @@ -3068,24 +3068,28 @@ When called interactively, FORCE is t, CURRENT is t if current buffer uses | |||
| 3068 | (message "No BibTeX buffers defined"))) | 3068 | (message "No BibTeX buffers defined"))) |
| 3069 | buffer-list)) | 3069 | buffer-list)) |
| 3070 | 3070 | ||
| 3071 | (defun bibtex-complete-string-cleanup (str compl) | 3071 | (defun bibtex-complete-string-cleanup (compl) (lambda (str status) ;Curried. |
| 3072 | "Cleanup after inserting string STR. | 3072 | "Cleanup after inserting string STR. |
| 3073 | Remove enclosing field delimiters for STR. Display message with | 3073 | Remove enclosing field delimiters for STR. Display message with |
| 3074 | expansion of STR using expansion list COMPL." | 3074 | expansion of STR using expansion list COMPL." |
| 3075 | ;; point is at position inside field where completion was requested | 3075 | (when (memq status '(exact finished sole)) |
| 3076 | (save-excursion | 3076 | (let ((abbr (cdr (assoc-string str compl t)))) |
| 3077 | (let ((abbr (cdr (if (stringp str) | 3077 | (when abbr |
| 3078 | (assoc-string str compl t))))) | 3078 | (message "%s = abbreviation for `%s'" str abbr))) |
| 3079 | (if abbr (message "Abbreviation for `%s'" abbr)) | 3079 | (when (eq status 'finished) |
| 3080 | (bibtex-remove-delimiters)))) | 3080 | (save-excursion (bibtex-remove-delimiters)))))) |
| 3081 | 3081 | ||
| 3082 | (defun bibtex-complete-crossref-cleanup (key) | 3082 | (defun bibtex-complete-crossref-cleanup (buf) (lambda (key status) ;Curried. |
| 3083 | "Display summary message on entry KEY after completion of a crossref key. | 3083 | "Display summary message on entry KEY after completion of a crossref key. |
| 3084 | Use `bibtex-summary-function' to generate summary." | 3084 | Use `bibtex-summary-function' to generate summary." |
| 3085 | (save-excursion | 3085 | (when (memq status '(exact sole finished)) |
| 3086 | (if (and (stringp key) | 3086 | (let ((summary |
| 3087 | (bibtex-search-entry key t)) | 3087 | (with-current-buffer buf |
| 3088 | (message "Ref: %s" (funcall bibtex-summary-function))))) | 3088 | (save-excursion |
| 3089 | (if (bibtex-search-entry key t) | ||
| 3090 | (funcall bibtex-summary-function)))))) | ||
| 3091 | (when summary | ||
| 3092 | (message "%s %s" key summary)))))) | ||
| 3089 | 3093 | ||
| 3090 | (defun bibtex-copy-summary-as-kill (&optional arg) | 3094 | (defun bibtex-copy-summary-as-kill (&optional arg) |
| 3091 | "Push summery of current BibTeX entry to kill ring. | 3095 | "Push summery of current BibTeX entry to kill ring. |
| @@ -4985,16 +4989,7 @@ entries from minibuffer." | |||
| 4985 | (t (let ((completion-ignore-case nil)) | 4989 | (t (let ((completion-ignore-case nil)) |
| 4986 | (complete-with-action | 4990 | (complete-with-action |
| 4987 | a (bibtex-global-key-alist) s p))))) | 4991 | a (bibtex-global-key-alist) s p))))) |
| 4988 | :exit-function | 4992 | :exit-function (bibtex-complete-crossref-cleanup buf)))) |
| 4989 | (lambda (string status) | ||
| 4990 | (when (memq status '(exact sole finished)) | ||
| 4991 | (let ((summary | ||
| 4992 | (with-current-buffer buf | ||
| 4993 | (save-excursion | ||
| 4994 | (if (bibtex-search-entry string) | ||
| 4995 | (funcall bibtex-summary-function)))))) | ||
| 4996 | (when summary | ||
| 4997 | (message "%s %s" string summary)))))))) | ||
| 4998 | 4993 | ||
| 4999 | ((eq compl 'string) | 4994 | ((eq compl 'string) |
| 5000 | ;; String key completion: no cleanup needed. | 4995 | ;; String key completion: no cleanup needed. |
| @@ -5011,14 +5006,7 @@ entries from minibuffer." | |||
| 5011 | ((eq a 'metadata) `(metadata (category . bibtex-string))) | 5006 | ((eq a 'metadata) `(metadata (category . bibtex-string))) |
| 5012 | (t (let ((completion-ignore-case t)) | 5007 | (t (let ((completion-ignore-case t)) |
| 5013 | (complete-with-action a compl s p))))) | 5008 | (complete-with-action a compl s p))))) |
| 5014 | :exit-function | 5009 | :exit-function (bibtex-complete-string-cleanup compl)))))) |
| 5015 | (lambda (string status) | ||
| 5016 | (when (memq status '(exact finished sole)) | ||
| 5017 | (let ((abbr (cdr (assoc-string string compl t)))) | ||
| 5018 | (when abbr | ||
| 5019 | (message "%s = abbreviation for `%s'" string abbr)))) | ||
| 5020 | (when (eq status 'finished) | ||
| 5021 | (save-excursion (bibtex-remove-delimiters))))))))) | ||
| 5022 | 5010 | ||
| 5023 | (defun bibtex-String (&optional key) | 5011 | (defun bibtex-String (&optional key) |
| 5024 | "Insert a new BibTeX @String entry with key KEY." | 5012 | "Insert a new BibTeX @String entry with key KEY." |