From f37d86ed0bd0857cfb5c606e9d5b5611d02783aa Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sun, 10 May 2015 17:27:16 +0300 Subject: [PATCH] semantic/symref/grep: Support regexp search * lisp/cedet/semantic/symref.el (semantic-symref-hit-to-tag-via-buffer): Don't regexp-quote when the search type is regexp. * lisp/cedet/semantic/symref/grep.el (semantic-symref-perform-search): Support the regexp search type. Pass -E to Grep when it's used. --- lisp/cedet/semantic/symref.el | 8 ++++++-- lisp/cedet/semantic/symref/grep.el | 16 +++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lisp/cedet/semantic/symref.el b/lisp/cedet/semantic/symref.el index 10293d9496c..2c5e3ba1805 100644 --- a/lisp/cedet/semantic/symref.el +++ b/lisp/cedet/semantic/symref.el @@ -472,8 +472,12 @@ buffers that were opened." (goto-char (point-min)) (forward-line (1- line)) - ;; Search forward for the matching text - (when (re-search-forward (regexp-quote searchtxt) + ;; Search forward for the matching text. + ;; FIXME: This still fails if the regexp uses something specific + ;; to the extended syntax, like grouping. + (when (re-search-forward (if (memq searchtype '(regexp tagregexp)) + searchtxt + (regexp-quote searchtxt)) (point-at-eol) t) (goto-char (match-beginning 0)) diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el index 3fa1c5ff7d8..3cf841e4f2c 100644 --- a/lisp/cedet/semantic/symref/grep.el +++ b/lisp/cedet/semantic/symref/grep.el @@ -141,7 +141,7 @@ This shell should support pipe redirect syntax." "Perform a search with Grep." ;; Grep doesn't support some types of searches. (let ((st (oref tool :searchtype))) - (when (not (eq st 'symbol)) + (when (not (memq st '(symbol regexp))) (error "Symref impl GREP does not support searchtype of %s" st)) ) ;; Find the root of the project, and do a find-grep... @@ -150,12 +150,14 @@ This shell should support pipe redirect syntax." (filepattern (semantic-symref-derive-find-filepatterns)) ;; Grep based flags. (grepflags (cond ((eq (oref tool :resulttype) 'file) - "-l ") - (t "-n "))) - (greppat (cond ((eq (oref tool :searchtype) 'regexp) - (oref tool searchfor)) - (t - (shell-quote-argument + "-l ") + ((eq (oref tool :searchtype) 'regexp) + "-nE ") + (t "-n "))) + (greppat (shell-quote-argument + (cond ((eq (oref tool :searchtype) 'regexp) + (oref tool searchfor)) + (t (concat "\\<" (oref tool searchfor) "\\>"))))) ;; Misc (b (get-buffer-create "*Semantic SymRef*")) -- 2.11.4.GIT