idutils.el 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ;;; semantic/symref/idutils.el --- Symref implementation for idutils
  2. ;;; Copyright (C) 2009-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. ;; Support IDUtils use in the Semantic Symref tool.
  18. (require 'cedet-idutils)
  19. (require 'semantic/symref)
  20. ;;; Code:
  21. ;;;###autoload
  22. (defclass semantic-symref-tool-idutils (semantic-symref-tool-baseclass)
  23. (
  24. )
  25. "A symref tool implementation using ID Utils.
  26. The udutils command set 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-idutils-search' for more details.")
  30. (defmethod semantic-symref-perform-search ((tool semantic-symref-tool-idutils))
  31. "Perform a search with IDUtils."
  32. (let ((b (cedet-idutils-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-idutils))
  41. "Parse one line of grep output, and return it as a match list.
  42. Moves cursor to end of the match."
  43. (cond ((eq (oref tool :resulttype) 'file)
  44. ;; Search for files
  45. (when (re-search-forward "^\\([^\n]+\\)$" nil t)
  46. (match-string 1)))
  47. ((eq (oref tool :searchtype) 'tagcompletions)
  48. (when (re-search-forward "^\\([^ ]+\\) " nil t)
  49. (match-string 1)))
  50. (t
  51. (when (re-search-forward "^\\([^ :]+\\):+\\([0-9]+\\):" nil t)
  52. (cons (string-to-number (match-string 2))
  53. (expand-file-name (match-string 1) default-directory))
  54. ))))
  55. (provide 'semantic/symref/idutils)
  56. ;; Local variables:
  57. ;; generated-autoload-file: "../loaddefs.el"
  58. ;; generated-autoload-load-name: "semantic/symref/idutils"
  59. ;; End:
  60. ;;; semantic/symref/idutils.el ends here