[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#19468: 25.0.50; UI inconveniences with M-.

From: Eli Zaretskii
Subject: bug#19468: 25.0.50; UI inconveniences with M-.
Date: Sat, 02 May 2015 14:45:00 +0300

> Date: Sat, 02 May 2015 14:16:22 +0300
> From: Eli Zaretskii <address@hidden>
> Cc: address@hidden
> And the saga is not yet over, but now I need help.  The method
> semantic-symref-parse-tool-output-one-line returns nil, but I cannot
> seem to figure out why.  The buffer which contains Grep hits look fine
> to me (except that it includes SGR escape sequences, due to
> "--color=always" switch to Grep -- why is that a good idea?), but
> where's the code of this method?  I couldn't step into it with Edebug,
> for some reason.

Found it: that --color=always _is_ the problem, since the SGR escapes
interfere with the search.  How does this work on Posix platforms?
Should we filter out that switch unconditionally?

The patch below incorporates the additional fix for this problem, and
now, finally, I have my references using Grep as well:

diff --git a/lisp/cedet/semantic/symref/grep.el 
index 981dab8..da1803f 100644
--- a/lisp/cedet/semantic/symref/grep.el
+++ b/lisp/cedet/semantic/symref/grep.el
@@ -105,7 +105,11 @@ (defun semantic-symref-grep-use-template (rootdir 
filepattern grepflags greppatt
   ;; We have grep-compute-defaults.  Let's use it.
   (let* ((grep-expand-keywords semantic-symref-grep-expand-keywords)
-        (cmd (grep-expand-template grep-find-template
+        (cmd (grep-expand-template (if (memq system-type '(windows-nt ms-dos))
+                                        (replace-regexp-in-string
+                                         "--color=always" "--color=auto"
+                                         grep-find-template t t)
+                                      grep-find-template)
@@ -115,7 +119,7 @@ (defun semantic-symref-grep-use-template (rootdir 
filepattern grepflags greppatt
     ;;(message "New command: %s" cmd)
-(defcustom semantic-symref-grep-shell "sh"
+(defcustom semantic-symref-grep-shell shell-file-name
   "The shell command to use for executing find/grep.
 This shell should support pipe redirect syntax."
   :group 'semantic
@@ -140,7 +144,8 @@ (cl-defmethod semantic-symref-perform-search ((tool 
         (greppat (cond ((eq (oref tool :searchtype) 'regexp)
                         (oref tool searchfor))
-                        (concat "'\\<" (oref tool searchfor) "\\>'"))))
+                        (shell-quote-argument
+                          (concat "\\<" (oref tool searchfor) "\\>")))))
         ;; Misc
         (b (get-buffer-create "*Semantic SymRef*"))
         (ans nil)
@@ -158,10 +163,12 @@ (cl-defmethod semantic-symref-perform-search ((tool 
          (let ((cmd (concat "find " default-directory " -type f " filepattern 
" -print0 "
                             "| xargs -0 grep -H " grepflags "-e " greppat)))
            ;;(message "Old command: %s" cmd)
-           (call-process semantic-symref-grep-shell nil b nil "-c" cmd)
+           (call-process semantic-symref-grep-shell nil b nil
+                          shell-command-switch cmd)
        (let ((cmd (semantic-symref-grep-use-template rootdir filepattern 
grepflags greppat)))
-         (call-process semantic-symref-grep-shell nil b nil "-c" cmd))
+         (call-process semantic-symref-grep-shell nil b nil
+                        shell-command-switch cmd))
     (setq ans (semantic-symref-parse-tool-output tool b))
     ;; Return the answer

reply via email to

[Prev in Thread] Current Thread [Next in Thread]