From: Dmitry Gutov Date: Sun, 20 Aug 2017 21:39:22 +0000 (+0300) Subject: Fix byte-compilation warnings in semantic/symref/grep X-Git-Tag: emacs-26.0.90~390 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9da8d600b8453925d92b31ba98548480ad1e5c73;p=emacs.git Fix byte-compilation warnings in semantic/symref/grep * lisp/cedet/semantic/symref/grep.el (greppattern): Remove. (grepflags): Rename to semantic-symref-grep-flags. (semantic-symref-grep-expand-keywords): Update accordingly. (semantic-symref-grep-use-template): Remove the last two arguments to make sure they don't shadow the (not renamed) global variables. (semantic-symref-perform-search) (semantic-symref-parse-tool-output-one-line): Use slot names instead of keywords, like the byte-compiler wants us to. --- diff --git a/lisp/cedet/semantic/symref/grep.el b/lisp/cedet/semantic/symref/grep.el index f7c72bfb0be..f8b29290706 100644 --- a/lisp/cedet/semantic/symref/grep.el +++ b/lisp/cedet/semantic/symref/grep.el @@ -84,17 +84,14 @@ Optional argument MODE specifies the `major-mode' to test." ,@(mapcan (lambda (s) `("-o" "-name" ,s)) pat) ")")))))) -(defvar grepflags) -(defvar greppattern) +(defvar semantic-symref-grep-flags) (defvar semantic-symref-grep-expand-keywords (condition-case nil (let* ((kw (copy-alist grep-expand-keywords)) - (C (assoc "" kw)) - (R (assoc "" kw))) - (setcdr C 'grepflags) - (setcdr R 'greppattern) - kw) + (C (assoc "" kw))) + (setcdr C 'semantic-symref-grep-flags) + kw) (error nil)) "Grep expand keywords used when expanding templates for symref.") @@ -102,15 +99,15 @@ Optional argument MODE specifies the `major-mode' to test." "Use the grep template expand feature to create a grep command. ROOTDIR is the root location to run the `find' from. FILEPATTERN is a string representing find flags for searching file patterns. -GREPFLAGS are flags passed to grep, such as -n or -l. -GREPPATTERN is the pattern used by grep." +FLAGS are flags passed to Grep, such as -n or -l. +PATTERN is the pattern used by Grep." ;; We have grep-compute-defaults. Let's use it. (grep-compute-defaults) - (let* ((grepflags flags) - (greppattern pattern) + (let* ((semantic-symref-grep-flags flags) (grep-expand-keywords semantic-symref-grep-expand-keywords) (cmd (grep-expand-template (if (memq system-type '(windows-nt ms-dos)) + ;; FIXME: Is this still needed? ;; grep-find uses '--color=always' on MS-Windows ;; because it wants the colorized output, to show ;; it to the user. By contrast, here we don't show @@ -119,7 +116,7 @@ GREPPATTERN is the pattern used by grep." (replace-regexp-in-string "--color=always" "" grep-find-template t t) grep-find-template) - greppattern + pattern filepattern rootdir))) ;; http://debbugs.gnu.org/20719 @@ -137,7 +134,7 @@ This shell should support pipe redirect syntax." (cl-defmethod semantic-symref-perform-search ((tool semantic-symref-tool-grep)) "Perform a search with Grep." ;; Grep doesn't support some types of searches. - (let ((st (oref tool :searchtype))) + (let ((st (oref tool searchtype))) (when (not (memq st '(symbol regexp))) (error "Symref impl GREP does not support searchtype of %s" st)) ) @@ -147,20 +144,19 @@ This shell should support pipe redirect syntax." (filepatterns (semantic-symref-derive-find-filepatterns)) (filepattern (mapconcat #'shell-quote-argument filepatterns " ")) ;; Grep based flags. - (grepflags (cond ((eq (oref tool :resulttype) 'file) + (grepflags (cond ((eq (oref tool resulttype) 'file) "-l ") - ((eq (oref tool :searchtype) 'regexp) + ((eq (oref tool searchtype) 'regexp) "-nE ") (t "-n "))) - (greppat (shell-quote-argument - (cond ((eq (oref tool :searchtype) 'regexp) - (oref tool searchfor)) - (t - ;; Can't use the word boundaries: Grep - ;; doesn't always agrees with the language - ;; syntax on those. - (format "\\(^\\|\\W\\)%s\\(\\W\\|$\\)" - (oref tool searchfor)))))) + (greppat (cond ((eq (oref tool searchtype) 'regexp) + (oref tool searchfor)) + (t + ;; Can't use the word boundaries: Grep + ;; doesn't always agrees with the language + ;; syntax on those. + (format "\\(^\\|\\W\\)%s\\(\\W\\|$\\)" + (oref tool searchfor))))) ;; Misc (b (get-buffer-create "*Semantic SymRef*")) (ans nil) @@ -194,11 +190,11 @@ This shell should support pipe redirect syntax." Moves cursor to end of the match." (pcase-let ((`(,grep-re ,file-group ,line-group . ,_) (car grep-regexp-alist))) - (cond ((eq (oref tool :resulttype) 'file) + (cond ((eq (oref tool resulttype) 'file) ;; Search for files (when (re-search-forward "^\\([^\n]+\\)$" nil t) (match-string 1))) - ((eq (oref tool :resulttype) 'line-and-text) + ((eq (oref tool resulttype) 'line-and-text) (when (re-search-forward grep-re nil t) (list (string-to-number (match-string line-group)) (match-string file-group)