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

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 24 May 2013 20:58:02 +0000

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 [email-masked].

-- 
13549: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13549
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#13549: 24.3.50; FR: Improve grep output (show function names, when possible)
From: Juri Linkov <[email-masked]>
To: Stefan Monnier <[email-masked]>
Cc: [email-masked], Jambunathan K <[email-masked]>
Date: Fri, 24 May 2013 23:55:15 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

>> -     ("^.+?-[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.

Subject: 24.3.50; FR: Improve grep output (show function names, when possible)
From: Jambunathan K <[email-masked]>
To: [email-masked]
Date: Fri, 25 Jan 2013 20:27:29 +0530
List-Id: <debbugs-submit.debbugs.gnu.org>

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)

=== 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)

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

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 [email-masked]
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
System Description:	Debian GNU/Linux 6.0.5 (squeeze)

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