diff options
| author | Stefan Monnier | 2016-01-02 13:03:42 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2016-01-02 13:03:42 -0500 |
| commit | 8637f3d0fa8d2f7325313abd66edb072b1a69db7 (patch) | |
| tree | ac3c44c31a0d291167742c61713532c588f0e5ea | |
| parent | 0a7ad071efdd6fe9cc2f5f18bb5648f0062ec60b (diff) | |
| download | emacs-8637f3d0fa8d2f7325313abd66edb072b1a69db7.tar.gz emacs-8637f3d0fa8d2f7325313abd66edb072b1a69db7.zip | |
(semantic-symref-derive-find-filepatterns): Return a list
* lisp/cedet/semantic/symref/grep.el
(semantic-symref-derive-find-filepatterns): Return a list.
(semantic-symref-perform-search): Quote the result here once and for all.
| -rw-r--r-- | lisp/cedet/semantic/symref/grep.el | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el index 54b538345ab..3b544d9f912 100644 --- a/lisp/cedet/semantic/symref/grep.el +++ b/lisp/cedet/semantic/symref/grep.el | |||
| @@ -53,6 +53,8 @@ and those hits returned.") | |||
| 53 | See find -name man page for format.") | 53 | See find -name man page for format.") |
| 54 | 54 | ||
| 55 | (defun semantic-symref-derive-find-filepatterns (&optional mode) | 55 | (defun semantic-symref-derive-find-filepatterns (&optional mode) |
| 56 | ;; FIXME: This should be moved to grep.el, where it could be used | ||
| 57 | ;; for "C-u M-x grep" as well. | ||
| 56 | "Derive a list of file patterns for the current buffer. | 58 | "Derive a list of file patterns for the current buffer. |
| 57 | Looks first in `semantic-symref-filepattern-alist'. If it is not | 59 | Looks first in `semantic-symref-filepattern-alist'. If it is not |
| 58 | there, it then looks in `auto-mode-alist', and attempts to derive something | 60 | there, it then looks in `auto-mode-alist', and attempts to derive something |
| @@ -64,28 +66,20 @@ Optional argument MODE specifies the `major-mode' to test." | |||
| 64 | (when (not pat) | 66 | (when (not pat) |
| 65 | ;; No hit, try auto-mode-alist. | 67 | ;; No hit, try auto-mode-alist. |
| 66 | (dolist (X auto-mode-alist) | 68 | (dolist (X auto-mode-alist) |
| 67 | (when (eq (cdr X) mode) | 69 | (when (and (eq (cdr X) mode) |
| 68 | ;; Only take in simple patterns, so try to convert this one. | 70 | ;; Only take in simple patterns, so try to convert this one. |
| 69 | (let ((Xp | 71 | (string-match "\\\\\\.\\([^\\'>]+\\)\\\\'" (car X))) |
| 70 | (cond ((string-match "\\\\\\.\\([^\\'>]+\\)\\\\'" (car X)) | 72 | (push (concat "*." (match-string 1 (car X))) pat)))) |
| 71 | (concat "*." (match-string 1 (car X)))) | ||
| 72 | (t nil)))) | ||
| 73 | (when Xp | ||
| 74 | (setq pat (cons Xp pat)))) | ||
| 75 | ))) | ||
| 76 | ;; Convert the list into some find-flags. | 73 | ;; Convert the list into some find-flags. |
| 77 | (cond ((= (length pat) 1) | 74 | (if (null pat) |
| 78 | (concat "-name " (shell-quote-argument (car pat)))) | 75 | (error "Customize `semantic-symref-filepattern-alist' for %S" |
| 79 | ((consp pat) | 76 | major-mode) |
| 80 | (concat (shell-quote-argument "(") " " | 77 | (let ((args `("-name" ,(car pat)))) |
| 81 | (mapconcat (lambda (s) | 78 | (if (null (cdr args)) |
| 82 | (concat "-name " (shell-quote-argument s))) | 79 | args |
| 83 | pat | 80 | `("(" ,@args |
| 84 | " -o ") | 81 | ,@(apply #'nconc (mapcar (lambda (s) `("-o" "-name" ,s)) pat)) |
| 85 | " " (shell-quote-argument ")"))) | 82 | ")")))))) |
| 86 | (t | ||
| 87 | (error "Customize `semantic-symref-filepattern-alist' for %s" major-mode)) | ||
| 88 | ))) | ||
| 89 | 83 | ||
| 90 | (defvar grepflags) | 84 | (defvar grepflags) |
| 91 | (defvar greppattern) | 85 | (defvar greppattern) |
| @@ -147,7 +141,8 @@ This shell should support pipe redirect syntax." | |||
| 147 | ;; Find the root of the project, and do a find-grep... | 141 | ;; Find the root of the project, and do a find-grep... |
| 148 | (let* (;; Find the file patterns to use. | 142 | (let* (;; Find the file patterns to use. |
| 149 | (rootdir (semantic-symref-calculate-rootdir)) | 143 | (rootdir (semantic-symref-calculate-rootdir)) |
| 150 | (filepattern (semantic-symref-derive-find-filepatterns)) | 144 | (filepatterns (semantic-symref-derive-find-filepatterns)) |
| 145 | (filepattern (mapconcat #'shell-quote-argument filepatterns " ")) | ||
| 151 | ;; Grep based flags. | 146 | ;; Grep based flags. |
| 152 | (grepflags (cond ((eq (oref tool :resulttype) 'file) | 147 | (grepflags (cond ((eq (oref tool :resulttype) 'file) |
| 153 | "-l ") | 148 | "-l ") |