From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: [jidanni@jidanni.org: Re: find-grep makes raw terminal ANSI]
Date: Sat, 17 Nov 2007 17:32:48 +0200 [thread overview]
Message-ID: <87fxz4j3a6.fsf@jurta.org> (raw)
In-Reply-To: <jwvr6ipcxfl.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 16 Nov 2007 23:24:24 -0500")
>> 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/
next prev parent reply other threads:[~2007-11-17 15:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-16 4:29 [jidanni@jidanni.org: Re: find-grep makes raw terminal ANSI] Richard Stallman
2007-11-16 21:54 ` Juri Linkov
2007-11-17 4:24 ` Stefan Monnier
2007-11-17 15:32 ` Juri Linkov [this message]
2007-11-17 17:28 ` Drew Adams
2007-11-17 22:50 ` Eli Zaretskii
2007-11-17 23:04 ` Drew Adams
2007-11-18 0:29 ` David Kastrup
2007-11-18 4:14 ` Eli Zaretskii
2007-11-17 22:54 ` Juri Linkov
2007-11-18 3:18 ` Stefan Monnier
2007-11-18 10:45 ` Andreas Schwab
2007-11-18 12:05 ` Juri Linkov
2007-11-19 16:00 ` Stefan Monnier
2007-11-18 22:45 ` Richard Stallman
2007-11-17 23:30 ` Richard Stallman
2007-11-17 23:59 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fxz4j3a6.fsf@jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).