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

From: Jambunathan K <[email-masked]>
Date: Fri, 25 Jan 2013 20:27:29 +0530

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)

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