From 6cffdff2e5dfc81a6b6b2155cbb8d895930fba5e Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Tue, 22 Jan 2019 15:19:27 +0100 Subject: [PATCH] Update ggtags. Signed-off-by: Andreas Gerler --- bba.org | 2 +- elpa/ggtags-20181031.1803/ggtags-pkg.el | 2 - .../ggtags-autoloads.el | 0 elpa/ggtags-20181221.238/ggtags-pkg.el | 2 + .../ggtags.el | 95 ++++++++++++++++++- 5 files changed, 97 insertions(+), 4 deletions(-) delete mode 100644 elpa/ggtags-20181031.1803/ggtags-pkg.el rename elpa/{ggtags-20181031.1803 => ggtags-20181221.238}/ggtags-autoloads.el (100%) create mode 100644 elpa/ggtags-20181221.238/ggtags-pkg.el rename elpa/{ggtags-20181031.1803 => ggtags-20181221.238}/ggtags.el (96%) diff --git a/bba.org b/bba.org index dabea7ab..cffa3cd0 100644 --- a/bba.org +++ b/bba.org @@ -3298,7 +3298,7 @@ If you are new to tags check [[http://tuhdo.github.io/c-ide.html][this]]. #+BEGIN_SRC emacs-lisp :tangle yes (if (>= emacs-major-version 24) (progn - (add-to-list 'load-path "~/.emacs.d/elpa/ggtags-20181031.1803" t) + (add-to-list 'load-path "~/.emacs.d/elpa/ggtags-20181221.238" t) (require 'ggtags) (add-to-list 'load-path "~/.emacs.d/elpa/helm-gtags-20170116.529" t) (require 'helm-gtags) diff --git a/elpa/ggtags-20181031.1803/ggtags-pkg.el b/elpa/ggtags-20181031.1803/ggtags-pkg.el deleted file mode 100644 index fbe30297..00000000 --- a/elpa/ggtags-20181031.1803/ggtags-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "ggtags" "20181031.1803" "emacs frontend to GNU Global source code tagging system" '((emacs "25")) :commit "669676461c74ffd30b81dce60cf4f081270f2858" :keywords '("tools" "convenience") :authors '(("Leo Liu" . "sdl.web@gmail.com")) :maintainer '("Leo Liu" . "sdl.web@gmail.com") :url "https://github.com/leoliu/ggtags") diff --git a/elpa/ggtags-20181031.1803/ggtags-autoloads.el b/elpa/ggtags-20181221.238/ggtags-autoloads.el similarity index 100% rename from elpa/ggtags-20181031.1803/ggtags-autoloads.el rename to elpa/ggtags-20181221.238/ggtags-autoloads.el diff --git a/elpa/ggtags-20181221.238/ggtags-pkg.el b/elpa/ggtags-20181221.238/ggtags-pkg.el new file mode 100644 index 00000000..53d560b1 --- /dev/null +++ b/elpa/ggtags-20181221.238/ggtags-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "ggtags" "20181221.238" "emacs frontend to GNU Global source code tagging system" '((emacs "25")) :commit "2f538aa15c60ad8365b7240579f67a90f600c1d1" :keywords '("tools" "convenience") :authors '(("Leo Liu" . "sdl.web@gmail.com")) :maintainer '("Leo Liu" . "sdl.web@gmail.com") :url "https://github.com/leoliu/ggtags") diff --git a/elpa/ggtags-20181031.1803/ggtags.el b/elpa/ggtags-20181221.238/ggtags.el similarity index 96% rename from elpa/ggtags-20181031.1803/ggtags.el rename to elpa/ggtags-20181221.238/ggtags.el index 221d14d0..c170c492 100644 --- a/elpa/ggtags-20181031.1803/ggtags.el +++ b/elpa/ggtags-20181221.238/ggtags.el @@ -4,7 +4,7 @@ ;; Author: Leo Liu ;; Version: 0.9.0 -;; Package-Version: 20181031.1803 +;; Package-Version: 20181221.238 ;; Keywords: tools, convenience ;; Created: 2013-01-29 ;; URL: https://github.com/leoliu/ggtags @@ -2202,6 +2202,7 @@ to nil disables displaying this information.") (if ggtags-mode (progn (add-hook 'after-save-hook 'ggtags-after-save-function nil t) + (add-hook 'xref-backend-functions 'ggtags--xref-backend nil t) ;; Append to serve as a fallback method. (add-hook 'completion-at-point-functions #'ggtags-completion-at-point t t) @@ -2217,6 +2218,7 @@ to nil disables displaying this information.") (append mode-line-buffer-identification '(ggtags-mode-line-project-name))))) (remove-hook 'after-save-hook 'ggtags-after-save-function t) + (remove-hook 'xref-backend-functions 'ggtags--xref-backend t) (remove-hook 'completion-at-point-functions #'ggtags-completion-at-point t) (remove-function (local 'eldoc-documentation-function) 'ggtags-eldoc-function) (setq mode-line-buffer-identification @@ -2359,6 +2361,97 @@ Function `ggtags-eldoc-function' disabled for eldoc in current buffer: %S" err)) (setq he-expand-list (cdr he-expand-list)) t)) +;;; Xref + +(defconst ggtags--xref-limit 1000) + +(defclass ggtags-xref-location (xref-file-location) + ((project-root :type string :initarg :project-root))) + +(cl-defmethod xref-location-group ((l ggtags-xref-location)) + (with-slots (file project-root) l + (file-relative-name file project-root))) + +(defun ggtags--xref-backend () + (and (ggtags-find-project) + (let ((tag (ggtags-tag-at-point))) + ;; Try to use this backend if there is no tag at + ;; point, since we may still want to when asking + ;; the user for a tag. + (or (null tag) + (test-completion tag ggtags-completion-table))) + 'ggtags)) + +(cl-defmethod xref-backend-identifier-at-point ((_backend (eql ggtags))) + (ggtags-tag-at-point)) + +(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql ggtags))) + ggtags-completion-table) + +(defun ggtags--xref-collect-tags (tag root colored) + "Collect xrefs for TAG from Global output in the `current-buffer'. +Return the list of xrefs for TAG. Global output is assumed to +have grep format. + +ROOT is the project root directory to associate with the xrefs. + +If COLORED is non-nil, convert ANSI color codes to font lock text +properties in the summary text of each xref." + (cl-loop + with re = (cadr (assq 'grep ggtags-global-error-regexp-alist-alist)) + while (re-search-forward re nil t) + for summary = (buffer-substring (1+ (match-end 2)) (line-end-position)) + for file = (expand-file-name (match-string 1)) + for line = (string-to-number (match-string 2)) + for column = (string-match-p tag summary) + if colored do (setq summary (ansi-color-apply summary)) end + ;; Sometimes there are false positives, depending on the + ;; parser used so only collect lines that actually + ;; contain TAG. + and when column + collect (xref-make + summary + (make-instance + 'ggtags-xref-location + :file file + :line line + :column column + :project-root root)))) + +(defun ggtags--xref-find-tags (tag cmd) + "Find xrefs of TAG using Global CMD. +CMD has the same meaning as in `ggtags-global-build-command'. +Return the list of xrefs for TAG." + (let* ((ggtags-global-output-format 'grep) + (project (ggtags-find-project)) + (xrefs nil) + (collect + (lambda (_status) + (goto-char (point-min)) + (setq xrefs (ggtags--xref-collect-tags + tag + (ggtags-project-root project) + (and ggtags-global-use-color + (ggtags-project-has-color project)))) + (kill-buffer (current-buffer))))) + (ggtags-with-current-project + (ggtags-global-output + (get-buffer-create " *ggtags-xref*") + (append + (split-string (ggtags-global-build-command cmd)) + (list "--" (shell-quote-argument tag))) + collect ggtags--xref-limit 'sync) + xrefs))) + +(cl-defmethod xref-backend-definitions ((_backend (eql ggtags)) tag) + (ggtags--xref-find-tags tag 'definition)) + +(cl-defmethod xref-backend-references ((_backend (eql ggtags)) tag) + (ggtags--xref-find-tags tag 'reference)) + +(cl-defmethod xref-backend-apropos ((_backend (eql ggtags)) tag) + (ggtags--xref-find-tags tag 'grep)) + (defun ggtags-reload (&optional force) (interactive "P") (unload-feature 'ggtags force) -- 2.47.3