]> code.delx.au - gnu-emacs-elpa/blobdiff - company-gtags.el
Bumped version to 0.2.1.
[gnu-emacs-elpa] / company-gtags.el
index a7667677a5c717f105cddd9e193974295898ad53..d3b429a3a40914325fd015e8953068a576d3321f 100644 (file)
@@ -2,7 +2,7 @@
 ;;
 ;; Copyright (C) 2009 Nikolaj Schumacher
 ;;
-;; This file is part of company.
+;; This file is part of company 0.2.1.
 ;;
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License
           (forward-line)))
       (nreverse tags))))
 
+(defun company-gtags-location (tag)
+  (with-temp-buffer
+    (when (= 0 (call-process "global" 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)))))))
+
 (defun company-gtags (command &optional arg &rest ignored)
   "A `company-mode' completion back-end for GNU Global."
   (case command
@@ -65,7 +76,8 @@
                   (company-gtags-available)
                (or (company-grab company-gtags-symbol-regexp) "")))
     ('candidates (company-gtags-fetch-tags arg))
-    ('sorted t)))
+    ('sorted t)
+    ('location (company-gtags-location arg))))
 
 (provide 'company-gtags)
 ;;; company-gtags.el ends here