1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-03 08:30:09 +00:00

* 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.
This commit is contained in:
Stefan Monnier 2011-09-14 17:43:36 -04:00
parent 1b8b395447
commit 3fe48822c3
2 changed files with 23 additions and 30 deletions

View File

@ -1,5 +1,10 @@
2011-09-14 Stefan Monnier <monnier@iro.umontreal.ca>
* 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.
* newcomment.el (comment-add, comment-valid-prefix-p): Docfix.
* mpc.el (mpc-constraints-tag-lookup): New function.

View File

@ -3068,24 +3068,28 @@ When called interactively, FORCE is t, CURRENT is t if current buffer uses
(message "No BibTeX buffers defined")))
buffer-list))
(defun bibtex-complete-string-cleanup (str compl)
(defun bibtex-complete-string-cleanup (compl) (lambda (str status) ;Curried.
"Cleanup after inserting string STR.
Remove enclosing field delimiters for STR. Display message with
expansion of STR using expansion list COMPL."
;; point is at position inside field where completion was requested
(save-excursion
(let ((abbr (cdr (if (stringp str)
(assoc-string str compl t)))))
(if abbr (message "Abbreviation for `%s'" abbr))
(bibtex-remove-delimiters))))
(when (memq status '(exact finished sole))
(let ((abbr (cdr (assoc-string str compl t))))
(when abbr
(message "%s = abbreviation for `%s'" str abbr)))
(when (eq status 'finished)
(save-excursion (bibtex-remove-delimiters))))))
(defun bibtex-complete-crossref-cleanup (key)
(defun bibtex-complete-crossref-cleanup (buf) (lambda (key status) ;Curried.
"Display summary message on entry KEY after completion of a crossref key.
Use `bibtex-summary-function' to generate summary."
(save-excursion
(if (and (stringp key)
(bibtex-search-entry key t))
(message "Ref: %s" (funcall bibtex-summary-function)))))
(when (memq status '(exact sole finished))
(let ((summary
(with-current-buffer buf
(save-excursion
(if (bibtex-search-entry key t)
(funcall bibtex-summary-function))))))
(when summary
(message "%s %s" key summary))))))
(defun bibtex-copy-summary-as-kill (&optional arg)
"Push summery of current BibTeX entry to kill ring.
@ -4985,16 +4989,7 @@ entries from minibuffer."
(t (let ((completion-ignore-case nil))
(complete-with-action
a (bibtex-global-key-alist) s p)))))
:exit-function
(lambda (string status)
(when (memq status '(exact sole finished))
(let ((summary
(with-current-buffer buf
(save-excursion
(if (bibtex-search-entry string)
(funcall bibtex-summary-function))))))
(when summary
(message "%s %s" string summary))))))))
:exit-function (bibtex-complete-crossref-cleanup buf))))
((eq compl 'string)
;; String key completion: no cleanup needed.
@ -5011,14 +5006,7 @@ entries from minibuffer."
((eq a 'metadata) `(metadata (category . bibtex-string)))
(t (let ((completion-ignore-case t))
(complete-with-action a compl s p)))))
:exit-function
(lambda (string status)
(when (memq status '(exact finished sole))
(let ((abbr (cdr (assoc-string string compl t))))
(when abbr
(message "%s = abbreviation for `%s'" string abbr))))
(when (eq status 'finished)
(save-excursion (bibtex-remove-delimiters)))))))))
:exit-function (bibtex-complete-string-cleanup compl))))))
(defun bibtex-String (&optional key)
"Insert a new BibTeX @String entry with key KEY."