emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r105771: * textmodes/bibtex.el (bibte


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105771: * textmodes/bibtex.el (bibtex-complete-string-cleanup)
Date: Wed, 14 Sep 2011 17:43:36 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105771
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2011-09-14 17:43:36 -0400
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/textmodes/bibtex.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-09-14 21:21:59 +0000
+++ b/lisp/ChangeLog    2011-09-14 21:43:36 +0000
@@ -1,5 +1,10 @@
 2011-09-14  Stefan Monnier  <address@hidden>
 
+       * 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.

=== modified file 'lisp/textmodes/bibtex.el'
--- a/lisp/textmodes/bibtex.el  2011-09-10 21:15:28 +0000
+++ b/lisp/textmodes/bibtex.el  2011-09-14 21:43:36 +0000
@@ -3068,24 +3068,28 @@
           (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 @@
                       (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 @@
                     ((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."


reply via email to

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