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: Juri Linkov <juri <at> jurta.org>
To: Jambunathan K <kjambunathan <at> gmail.com>
Cc: 13549 <at> debbugs.gnu.org
Subject: bug#13549: 24.3.50; FR: Improve grep output (show function names, when possible)
Date: Wed, 22 May 2013 23:44:24 +0300
> FR: Improve grep output (show function names, when possible)

I think external commands (like `cscope' etc.) should output function names
much more efficiently than using `find-file-noselect' and `which-function'
to post-process their output.

There was a suggestion to implement this in `grep' with the
`-p --show-c-function' command line argument as mentioned in:

http://stackoverflow.com/questions/6133989/what-grep-command-will-include-the-current-function-name-in-its-output

There are other grep-like commands that already can output function names,
e.g. `git-grep'.  If you add to ~./.gitconfig the following lines:

[diff "el"]
        xfuncname = "^(\\(.*)$"

and to a project-specific file .gitattributes:

*.el   diff=el

then the following command will output function names:

git grep -inH -p -e "org-element-map"
lisp/org/org.el=20969=(defun org-fill-paragraph (&optional justify)
lisp/org/org.el:21047:		      (org-element-map

Since line numbers of function names are enclosed with `=' in its output,
they could be highlighted like `-' separators with this patch:

=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el	2013-05-18 16:32:43 +0000
+++ lisp/progmodes/grep.el	2013-05-22 20:36:00 +0000
@@ -410,7 +410,7 @@ (defvar grep-mode-font-lock-keywords
       (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
       (1 grep-error-face)
       (2 grep-error-face nil t))
-     ("^.+?-[0-9]+-.*\n" (0 grep-context-face)))
+     ("^.+?[-=][0-9]+[-=].*\n" (0 grep-context-face)))
    "Additional things to highlight in grep output.
 This gets tacked on the end of the generated expressions.")
 

=== modified file 'etc/grep.txt'
--- etc/grep.txt	2013-01-03 00:36:36 +0000
+++ etc/grep.txt	2013-05-22 20:36:33 +0000
@@ -72,6 +72,14 @@
 agrep -n "INFO tree" ../info/*
 ../info/dir: 6: File: dir	Node: Top	This is the top of the INFO tree
 
+* git-grep
+  with `[diff "el"] xfuncname = "^(\\(.*)$"' in .gitconfig
+  and `*.el diff=el' in .gitattributes
+
+git grep -inH -p -e "org-element-map"
+lisp/org/org.el=20969=(defun org-fill-paragraph (&optional justify)
+lisp/org/org.el:21047:		      (org-element-map
+
 * unknown greps
 





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.