--- Begin Message ---
Subject: |
24.3.50; FR: Improve grep output (show function names, when possible) |
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 address@hidden
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
Description: PNG image
--- End Message ---
--- Begin Message ---
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) |
>> - ("^.+?-[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.
--- End Message ---