emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] 09/18: Fix multiple calls of ggtags-show-definition


From: Leo Liu
Subject: [elpa] 09/18: Fix multiple calls of ggtags-show-definition
Date: Sat, 05 Apr 2014 01:25:16 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit c091f9971116f53c104c2b251d421e114b471c2d
Author: Leo Liu <address@hidden>
Date:   Wed Apr 2 11:10:10 2014 +0800

    Fix multiple calls of ggtags-show-definition
    
    and misuse of pcase equality in ggtags-eldoc-function.
    
    Fix ggtags-global-output to notice the problem of running multiple
    processes.
---
 ggtags.el |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/ggtags.el b/ggtags.el
index 39f0ff6..8c97c49 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -1647,6 +1647,12 @@ commands `next-error' and `previous-error'.
   "Asynchronously pipe the output of running CMDS to BUFFER.
 When finished invoke CALLBACK in BUFFER with process exit status."
   (or buffer (error "Output buffer required"))
+  (when (get-buffer-process (get-buffer buffer))
+    ;; Notice running multiple processes in the same buffer so that we
+    ;; can fix the caller. See for example `ggtags-eldoc-function'.
+    (message "Warning: detected %S already running in %S; interrupting..."
+             (get-buffer-process buffer) buffer)
+    (interrupt-process (get-buffer-process buffer)))
   (let* ((program (car cmds))
          (args (cdr cmds))
          (cutoff (and cutoff (+ cutoff (if (get-buffer buffer)
@@ -1910,17 +1916,17 @@ to nil disables displaying this information.")
 (declare-function eldoc-message "eldoc")
 (defun ggtags-eldoc-function ()
   "A function suitable for `eldoc-documentation-function' (which see)."
-  (pcase (cons (ggtags-tag-at-point) ggtags-eldoc-cache)
-    (`(nil . ,_) nil)
-    (`(,_x ,_x) nil)
-    (`(,_x ,_x ,def) def)
-    (`(,tag . ,_)
-     (let* ((ggtags-print-definition-function
-             (lambda (s)
-               (setq ggtags-eldoc-cache (list tag s))
-               (eldoc-message s))))
-       (ggtags-show-definition tag)
-       nil))))
+  (pcase (ggtags-tag-at-point)
+    (`nil nil)
+    (tag (if (equal tag (car ggtags-eldoc-cache))
+             (cadr ggtags-eldoc-cache)
+           (setq ggtags-eldoc-cache (list tag)) ;don't come back until done
+           (let* ((ggtags-print-definition-function
+                   (lambda (s)
+                     (setq ggtags-eldoc-cache (list tag s))
+                     (eldoc-message s))))
+             (ggtags-show-definition tag)
+             nil)))))
 
 ;;; imenu
 



reply via email to

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