global.el 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ;;; semantic/symref/global.el --- Use GNU Global for symbol references
  2. ;; Copyright (C) 2008-2012 Free Software Foundation, Inc.
  3. ;; Author: Eric M. Ludlam <eric@siege-engine.com>
  4. ;; This file is part of GNU Emacs.
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;;
  17. ;; GNU Global use with the semantic-symref system.
  18. (require 'cedet-global)
  19. (require 'semantic/symref)
  20. ;;; Code:
  21. ;;;###autoload
  22. (defclass semantic-symref-tool-global (semantic-symref-tool-baseclass)
  23. (
  24. )
  25. "A symref tool implementation using GNU Global.
  26. The GNU Global command can be used to generate lists of tags in a way
  27. similar to that of `grep'. This tool will parse the output to generate
  28. the hit list.
  29. See the function `cedet-gnu-global-search' for more details.")
  30. (defmethod semantic-symref-perform-search ((tool semantic-symref-tool-global))
  31. "Perform a search with GNU Global."
  32. (let ((b (cedet-gnu-global-search (oref tool :searchfor)
  33. (oref tool :searchtype)
  34. (oref tool :resulttype)
  35. (oref tool :searchscope)
  36. ))
  37. )
  38. (semantic-symref-parse-tool-output tool b)
  39. ))
  40. (defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-global))
  41. "Parse one line of grep output, and return it as a match list.
  42. Moves cursor to end of the match."
  43. (cond ((or (eq (oref tool :resulttype) 'file)
  44. (eq (oref tool :searchtype) 'tagcompletions))
  45. ;; Search for files
  46. (when (re-search-forward "^\\([^\n]+\\)$" nil t)
  47. (match-string 1)))
  48. (t
  49. (when (re-search-forward "^\\([^ ]+\\) +\\([0-9]+\\) \\([^ ]+\\) " nil t)
  50. (cons (string-to-number (match-string 2))
  51. (match-string 3))
  52. ))))
  53. (provide 'semantic/symref/global)
  54. ;; Local variables:
  55. ;; generated-autoload-file: "../loaddefs.el"
  56. ;; generated-autoload-load-name: "semantic/symref/global"
  57. ;; End:
  58. ;;; semantic/symref/global.el ends here