summaryrefslogtreecommitdiff
path: root/lisp/cedet/semantic/symref/cscope.el
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2016-04-12 21:08:22 +0300
committerDmitry Gutov <dgutov@yandex.ru>2016-04-12 21:08:56 +0300
commitcc0b713210a4ae3e273571f8c829122db2b143cf (patch)
treee511f08acafd5d691a4943b2c90163213fa828c6 /lisp/cedet/semantic/symref/cscope.el
parent50455754b558d1689bbbb596e05631f2789b1350 (diff)
downloademacs-cc0b713210a4ae3e273571f8c829122db2b143cf.tar.gz
Perform xref searches without visiting unopened files
* lisp/progmodes/xref.el (xref-collect-references): Instead of calling `semantic-symref-find-references-by-name', use `semantic-symref-instantiate' and `semantic-symref-perform-search' directly. Ask for `line-and-text' results (bug#23223). (xref-collect-matches): Include the line text in the "hit" structure. (xref--convert-hits): New function, split off from `xref-collect-references' and `xref-collect-matches', to convert "hits" to xref instance list. Create a temporary buffer here, to use it for post-processing all hit lines. (xref--collect-matches): Use a different approach for non-visited files. Insert the line text into the temp buffer, apply the file's major mode the best we can without reading its whole contents, syntax-propertize, and search in the result. (xref--collect-matches-1): Extract, to handle the common logic between two cases. (xref--find-buffer-visiting): New function, a wrapper around `find-buffer-visiting' to amortize its cost. * lisp/cedet/semantic/symref/idutils.el (semantic-symref-idutils--line-re): New constant. (semantic-symref-parse-tool-output-one-line): Support result type `line-and-text'. * lisp/cedet/semantic/symref/grep.el (semantic-symref-grep--line-re) (semantic-symref-parse-tool-output-one-line): Same. * lisp/cedet/semantic/symref/cscope.el (semantic-symref-cscope--line-re) (semantic-symref-parse-tool-output-one-line): Same. * lisp/cedet/semantic/symref/global.el (semantic-symref-global--line-re) (semantic-symref-parse-tool-output-one-line): Same.
Diffstat (limited to 'lisp/cedet/semantic/symref/cscope.el')
-rw-r--r--lisp/cedet/semantic/symref/cscope.el12
1 files changed, 10 insertions, 2 deletions
diff --git a/lisp/cedet/semantic/symref/cscope.el b/lisp/cedet/semantic/symref/cscope.el
index 4890b5b5755..3abd8b3f51c 100644
--- a/lisp/cedet/semantic/symref/cscope.el
+++ b/lisp/cedet/semantic/symref/cscope.el
@@ -60,6 +60,9 @@ See the function `cedet-cscope-search' for more details.")
(semantic-symref-parse-tool-output tool b)
))
+(defconst semantic-symref-cscope--line-re
+ "^\\([^ ]+\\) [^ ]+ \\([0-9]+\\) ")
+
(cl-defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-cscope))
"Parse one line of grep output, and return it as a match list.
Moves cursor to end of the match."
@@ -78,8 +81,13 @@ Moves cursor to end of the match."
;; We have to return something at this point.
subtxt)))
)
- (t
- (when (re-search-forward "^\\([^ ]+\\) [^ ]+ \\([0-9]+\\) " nil t)
+ ((eq (oref tool :resulttype) 'line-and-text)
+ (when (re-search-forward semantic-symref-cscope--line-re nil t)
+ (list (string-to-number (match-string 2))
+ (expand-file-name (match-string 1))
+ (buffer-substring-no-properties (point) (line-end-position)))))
+ (t ; :resulttype is 'line
+ (when (re-search-forward semantic-symref-cscope--line-re nil t)
(cons (string-to-number (match-string 2))
(expand-file-name (match-string 1)))
))))