emacs-devel
[Top][All Lists]
Advanced

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

Re: address@hidden: Re: find-grep makes raw terminal ANSI]


From: Juri Linkov
Subject: Re: address@hidden: Re: find-grep makes raw terminal ANSI]
Date: Sat, 17 Nov 2007 17:32:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

>> Currently grep.el adds " --color=always" to the environment variable
>> GREP_OPTIONS instead of putting this argument into the grep command.
>
> How 'bout using --color=auto (and then setup TERM appropriately and run
> the grep(&find) process in a tty rather than a pipe)?

Do you mean a patch like below?  It works because grep produces escape
sequences when stdout is a tty that is not dumb.  Here is relevant part
of grep source code for --color=auto:

          if(isatty(STDOUT_FILENO) && getenv("TERM") &&
             strcmp(getenv("TERM"), "dumb"))
                  color_option = 1;
          else
            color_option = 0;

and `process-connection-type' is t by default.

Index: lisp/progmodes/grep.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/grep.el,v
retrieving revision 1.79
diff -c -r1.79 grep.el
*** lisp/progmodes/grep.el      30 Aug 2007 09:36:59 -0000      1.79
--- lisp/progmodes/grep.el      17 Nov 2007 15:32:27 -0000
***************
*** 366,372 ****
      (grep-compute-defaults))
    (when (eq grep-highlight-matches t)
      ;; Modify `process-environment' locally bound in `compilation-start'
!     (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always"))
      ;; for GNU grep 2.5.1
      (setenv "GREP_COLOR" "01;31")
      ;; for GNU grep 2.5.1-cvs
--- 366,373 ----
      (grep-compute-defaults))
    (when (eq grep-highlight-matches t)
      ;; Modify `process-environment' locally bound in `compilation-start'
!     (setenv "TERM" "emacs")
!     (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=auto"))
      ;; for GNU grep 2.5.1
      (setenv "GREP_COLOR" "01;31")
      ;; for GNU grep 2.5.1-cvs

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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