From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.bugs Subject: bug#895: slow processing of process output Date: Wed, 6 Jul 2011 10:58:35 -0700 Message-ID: <6D56BDCE22F94C77B10AB679E92860C6@us.oracle.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1309982613 1530 80.91.229.12 (6 Jul 2011 20:03:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 6 Jul 2011 20:03:33 +0000 (UTC) Cc: 895@debbugs.gnu.org To: "'Lars Magne Ingebrigtsen'" , "'Stefan Monnier'" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 06 22:03:26 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QeYJi-0004Db-8V for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Jul 2011 22:03:26 +0200 Original-Received: from localhost ([::1]:41654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeYJg-000361-UZ for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Jul 2011 16:03:25 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:42183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeWNN-0002Bz-Ox for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2011 13:59:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QeWNL-0008PD-Od for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2011 13:59:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeWNL-0008Od-Fr for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2011 13:59:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QeWNK-0007k6-6S; Wed, 06 Jul 2011 13:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Drew Adams" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Jul 2011 17:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 895 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 895-submit@debbugs.gnu.org id=B895.130997513629751 (code B ref 895); Wed, 06 Jul 2011 17:59:02 +0000 Original-Received: (at 895) by debbugs.gnu.org; 6 Jul 2011 17:58:56 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QeWND-0007jo-Dz for submit@debbugs.gnu.org; Wed, 06 Jul 2011 13:58:55 -0400 Original-Received: from acsinet15.oracle.com ([141.146.126.227]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QeWNB-0007jW-8n for 895@debbugs.gnu.org; Wed, 06 Jul 2011 13:58:54 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by acsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p66Hwj2J026791 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 6 Jul 2011 17:58:47 GMT Original-Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p66HwhD5013963 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 6 Jul 2011 17:58:44 GMT Original-Received: from abhmt110.oracle.com (abhmt110.oracle.com [141.146.116.62]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p66HwbGg032697; Wed, 6 Jul 2011 12:58:38 -0500 Original-Received: from dradamslap1 (/10.159.55.239) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Jul 2011 10:58:37 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 Thread-Index: Acw7+Dck5Q7YfjFtQh2hedHjZSK3NQAAsV8A X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A020208.4E14A257.00DD:SCFMA922111,ss=1,re=-4.000,fgs=0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 06 Jul 2011 13:59:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:48117 Archived-At: > That is, if we instead prompted for the regexp we wanted to match > explicitly, then we could highlight it ourselves instead of relying on > grep to do it. I did that (without prompting), for Emacs 20 & 21. See: http://www.emacswiki.org/emacs/download/compile%2b20.el It was I who proposed that vanilla Emacs itself highlight the matches. That idea was adopted, but Emacs Dev decided to do the highlighting using escape chars provided by (some) external `grep' commands. (So I adjusted my code too to use that approach: http://www.emacswiki.org/emacs/download/grep%2b.el) > However, `M-x grep' as it is is pretty neat, because you can > fiddle with all the options and do > grep ... | grep -v | etc Absolutely. But there is no reason to conflate "[having] the `M-x grep' command be less...shell-script-ey" with doing the highlighting in Lisp. Why do you want less shell-script-ey? My code did the highlighting in Lisp, but it should not in any way interfere with piping etc. (However, for unrelated reasons piping with Emacs `grep' is not available until Emacs 22, and it was Emacs 22 that introduced external-`grep' highlighting.) > So providing something that is as flexible as `M-x grep' is today, but > allow Emacs greater control of the output sounds difficult. Not at all (IIUYC). > Ok, here's one other possibility off the top of my head: What about if > Emacs parsed the command line? :-) That is, if you're typing > grep -nH -e foo.*bar *.el > then the grep syntax isn't that impossible to parse. I mean, finding > the regexp, and highlighting the matching bits. That is what I did, IIUYC. The relevant bit of the compile+20.el code: ;; Remember `grep-pattern' for highlighting, if highlighting is possible. (cond (;; Quoted pattern (either "..." or '...') (string-match (concat grep-program "[ \t]*\\(-[a-zA-Z]+\\s-+\\)*[ \t]*\\('[^']+'\\|\"[^\"]+\"\\)") ;" command-args) (setq grep-pattern (substring command-args (1+ (match-beginning 2)) (1- (match-end 2))))) (;; Unquoted pattern. (string-match (concat grep-program "[ \t]*\\(-[a-zA-Z]+\\s-+\\)*[ \t]*\\([^ \n\t'\"]+\\)") ; " command-args) (setq grep-pattern (substring command-args (match-beginning 2) (match-end 2)))) (t;; Bad pattern. (setq grep-pattern nil))) ;; Account for a case-insensitivity option. (when (and (not (string= "" grep-case-insensitive-option)) (string-match grep-case-insensitive-option command-args)) (setq grep-pattern (mapconcat (lambda (char) (if (or (and (>= char ?a) (<= char ?z)) (and (>= char ?A) (<= char ?Z))) (concat "[" (char-to-string (downcase char)) (char-to-string (upcase char)) "]") (char-to-string char))) grep-pattern ""))) This is a quick hack that works well in general (for Emacs 20/21). But note that the `grep-pattern' highlighting is not anchored after the file name and line number, so if the file name itself matches the `grep-pattern' then it doesn't highlight the latter. Someone could work out the code to anchor the pattern match properly. I didn't bother to try, since it is good enough as is, for my use. > It isn't difficult to imagine more complex command lines that Emacs > wouldn't be able to parse, though. And you'd lose highlighting of the > matches there... Yes. FWIW, I think the Emacs Dev approach of using external `grep' highlighting is generally not bad (but there have been a few bugs that needed to be fixed along the way).