GNU bug report logs - #13549
24.3.50; FR: Improve grep output (show function names, when possible)

Previous Next

Package: emacs;

Reported by: Jambunathan K <kjambunathan <at> gmail.com>

Date: Fri, 25 Jan 2013 14:59:02 UTC

Severity: wishlist

Found in version 24.3.50

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Jambunathan K <kjambunathan <at> gmail.com>
Subject: bug#13549: closed (Re: bug#13549: 24.3.50; FR: Improve grep
 output (show function names, when possible))
Date: Fri, 24 May 2013 20:58:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#13549: 24.3.50; FR: Improve grep output (show function names, when possible)

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 13549 <at> debbugs.gnu.org.

-- 
13549: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13549
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 13549-done <at> debbugs.gnu.org, Jambunathan K <kjambunathan <at> gmail.com>
Subject: Re: bug#13549: 24.3.50;
	FR: Improve grep output (show function names, when possible)
Date: Fri, 24 May 2013 23:55:15 +0300
>> -     ("^.+?-[0-9]+-.*\n" (0 grep-context-face)))
>> +     ("^.+?[-=][0-9]+[-=].*\n" (0 grep-context-face)))
>
> Sounds good, tho a little comment above that line would be welcome (it
> could talk about both the =..= and the -..- cases).

Done, with more comments.

As for the function names in the output of grep, let's hope that
the developers of GNU grep will apply the patch implemented in

http://lists.gnu.org/archive/html/bug-grep/2005-01/msg00027.html

that adds the command line option `-p' and `--show-function-line'
with formatting similar to the output of git-grep
that is now supported in Emacs.

[Message part 3 (message/rfc822, inline)]
From: Jambunathan K <kjambunathan <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; FR: Improve grep output (show function names, when possible)
Date: Fri, 25 Jan 2013 20:27:29 +0530
[Message part 4 (text/plain, inline)]
FR: Improve grep output (show function names, when possible)


Please see the attached screen shot.

Window on top displays cscope control buffer.

Window down below shows output from rgrep.  Note that the grep output
has been enhanced to *also* display the function name.

Compare cscope's typography with grep's.  (Hint: cscope's is much
better).  I have modified compilation faces as below for quick visual
comparison.

(custom-set-faces
 '(compilation-info ((t (:inherit cscope-file-face))))
 '(compilation-line-number ((t (:inherit cscope-line-number-face)))))

----------------------------------------------------------------

I used the following local modification to compile.el to sneak in the
function names.  

The modification is in `compilation-parse-errors' which seems to be a
font-lock handler.  I call `which-function' within this context.  Is it
justified?

(WARNING: Quick and Dirty work)
(Bzr version: revno: 111597)

[compile.el.diff (text/x-diff, inline)]
=== modified file 'lisp/progmodes/compile.el'
--- lisp/progmodes/compile.el	2013-01-14 01:09:38 +0000
+++ lisp/progmodes/compile.el	2013-01-25 14:25:11 +0000
@@ -1320,6 +1320,24 @@ to `compilation-error-regexp-alist' if R
                              file line end-line col end-col (or type 2) fmt))
 
             (when (integerp file)
+	      (when (integerp line)
+		(let* ((file-name (match-string file))
+		       (line-no (match-string line))
+		       (which-fn
+			(save-match-data
+			  (when line-no
+			    (with-current-buffer
+				(find-file-noselect file-name)
+			      (forward-line (1- line))
+			      (which-function))))))
+		  (overlay-put
+		   (make-overlay (match-end file) (match-end file)
+				 (current-buffer) t t)
+		   'after-string
+		   (format " <%s>"
+			   (propertize (or which-fn "global")
+				       'face 'cscope-function-face)))))
+
               (compilation--put-prop
                file 'font-lock-face
                (if (consp type)

[Message part 6 (text/plain, inline)]
----------------------------------------------------------------

In GNU Emacs 24.3.50.7 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2013-01-25 on debian-6.05
Bzr revision: 111597 michael.albinus <at> gmx.de-20130124095002-l3domdlb4dqep93i
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
System Description:	Debian GNU/Linux 6.0.5 (squeeze)

----------------------------------------------------------------

[grep-proof-of-concept-cf-cscope.png (image/png, attachment)]

This bug report was last modified 11 years and 360 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.