]> code.delx.au - gnu-emacs-elpa/commitdiff
extended gtags functionality #90
authorksjogo <jogo@kronberger-spiele.de>
Sun, 6 Apr 2014 21:57:35 +0000 (23:57 +0200)
committerksjogo <jogo@kronberger-spiele.de>
Tue, 3 Jun 2014 14:30:35 +0000 (16:30 +0200)
showing annotations and meta

company-gtags.el

index 0ae98d7d62e0d66a33327c27a816398b980056de..41a81726287a4ee0fd3c2aec18cf9938287ab2f9 100644 (file)
   (with-temp-buffer
     (let (tags)
       (when (= 0 (call-process company-gtags-executable nil
-                               (list (current-buffer) nil) nil "-c" prefix))
+                               (list (current-buffer) nil) nil "-xGq" (concat "^" prefix)))
         (goto-char (point-min))
-        (split-string (buffer-string) "\n" t)))))
-
-(defun company-gtags-location (tag)
-  (with-temp-buffer
-    (when (= 0 (call-process company-gtags-executable nil
-                             (list (current-buffer) nil) nil "-x" tag))
-        (goto-char (point-min))
-        (when (looking-at (concat (regexp-quote tag)
-                                  "[ \t]+\\([[:digit:]]+\\)"
-                                  "[ \t]+\\([^ \t]+\\)"))
-          (cons (expand-file-name (match-string 2))
-                (string-to-number (match-string 1)))))))
+        (cl-loop while
+                 (re-search-forward (concat
+                                     "^"
+                                     "\\([^ ]*\\)" ;; completion
+                                     "[ \t]+\\([[:digit:]]+\\)" ;; linum
+                                     "[ \t]+\\([^ \t]+\\)" ;; file
+                                     "[ \t]+\\(.*\\)" ;; definition 
+                                     "$"
+                                     ) nil t)
+                 collect
+                 (propertize (match-string 1)
+                             'meta (match-string 4)
+                             'location (cons (expand-file-name (match-string 3))
+                                             (string-to-number (match-string 2)))
+                             ))))))
 
 ;;;###autoload
 (defun company-gtags (command &optional arg &rest ignored)
                  (or (company-grab-symbol) 'stop)))
     (candidates (company-gtags-fetch-tags arg))
     (sorted t)
-    (location (company-gtags-location arg))))
+    (duplicates t)
+    (annotation (let (annotation)
+                  (when (string-match (concat arg "\\((.*)\\).*") (get-text-property 0 'meta arg))
+                    (match-string 1 (get-text-property 0 'meta arg)))))
+    (meta (get-text-property 0 'meta arg))
+    (location (get-text-property 0 'location arg))))
 
 (provide 'company-gtags)
 ;;; company-gtags.el ends here