From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: highlight regular expression in grep window Date: Sat, 8 Feb 2014 14:19:21 -0800 (PST) Message-ID: References: <84ab5187-0def-45b6-bdb2-87693a1d77e5@googlegroups.com> <2d2fe767-9f72-422c-beb9-5dbed1ec89f8@googlegroups.com> <0cd4f26f-2ba8-48b0-a839-6e3e169ee56f@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1391897986 16707 80.91.229.3 (8 Feb 2014 22:19:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 8 Feb 2014 22:19:46 +0000 (UTC) To: Rami A , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 08 23:19:53 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WCGFd-0001AG-Af for geh-help-gnu-emacs@m.gmane.org; Sat, 08 Feb 2014 23:19:53 +0100 Original-Received: from localhost ([::1]:48170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCGFc-00008R-PH for geh-help-gnu-emacs@m.gmane.org; Sat, 08 Feb 2014 17:19:52 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCGFL-00005O-4C for help-gnu-emacs@gnu.org; Sat, 08 Feb 2014 17:19:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCGFD-0007xA-IJ for help-gnu-emacs@gnu.org; Sat, 08 Feb 2014 17:19:35 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:41466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCGFD-0007x3-Bn for help-gnu-emacs@gnu.org; Sat, 08 Feb 2014 17:19:27 -0500 Original-Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s18MJNFo008902 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 8 Feb 2014 22:19:24 GMT Original-Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s18MJM5P016401 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 8 Feb 2014 22:19:23 GMT Original-Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s18MJMrk023730; Sat, 8 Feb 2014 22:19:22 GMT In-Reply-To: <0cd4f26f-2ba8-48b0-a839-6e3e169ee56f@googlegroups.com> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6680.5000 (x86)] X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95992 Archived-At: Wow, a reply to a thread from 6 months ago! > I went back and tried using your grep+.el library. > I have a couple of questions: > > 1. Is it possible to tweak it so it would remove/toggle comments in > the grep window for a C language based file or assembly? By "grep window" I guess you mean the window showing buffer *grep*. Yes. If you use a prefix arg with `grepp-remove-comments' then you are prompted for the regexp that is used to match commented lines. Really, it is not necessarily about comments. This is just a regexp that is passed to command `flush-lines' after making the buffer writable etc. For example, `C-u ;' then enter, say, ":[0-9]+: */\*" (without the quotes) at the prompt, to match lines containing `/*'. Or whatever. You can alternatively customize `grepp-default-comment-line-regexp' so it matches the comment syntax you want (or whatever other syntax pattern you want to match, for removal). You can also define your own command that binds that option value to whatever regexp you want: (defun remove-C-comment-starts () "Remove lines with C comment starts: `/*'." (interactive) (let ((grepp-default-comment-line-regexp ":[0-9]+: */\\*")) (grepp-remove-comments))) Obviously, for C code things are a bit complicated for multi-line comments. With a simple thing like this (which is essentially just `flush-lines') you can remove only individual lines that match a pattern. The code has no real understanding of C commenting. But you could write a similar command that binds a regexp for /* and calls `grepp-remove-comments', then binds a regexp for */ and calls it again, then binds a regexp for // and calls it again. That won't catch comment lines between a /* line and a */ line, but it will at least cut down on much of the noise. > 2. Is there an option to highlight the match in the grep window? > "this is different than my question asked in this thread." I am > really looking to highlight each match in a busy grep window. IIUC, that happens already. If you do, say, `M-x grep' and enter this command: `grep -nH -e the.*r alloc.c' then matches for the regexp `the.*r' are highlighted in buffer *grep*. ---- There are other things you can use, instead of using grep and then flushing comments this way. You can, for instance, use command `hide/show-comments' from library `hide-comnt.el' to hide comments. And then use search to navigate among the uncommented code (e.g., Isearch or Icicles search across multiple buffers or files). (I don't think that `occur' and `moccur' ignore the hidden comments.) `hide/show-comments' does take care of lines between /* and */, for instance. And it does not hide code that is on the same line as a comment. It is not line-oriented; it is comment-oriented. http://www.emacswiki.org/emacs/HideOrIgnoreComments (description) http://www.emacswiki.org/emacs-en/download/hide-comnt.el (code)