[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#13549: 24.3.50; FR: Improve grep output (show function names, when p
From: |
Juri Linkov |
Subject: |
bug#13549: 24.3.50; FR: Improve grep output (show function names, when possible) |
Date: |
Wed, 22 May 2013 23:44:24 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) |
> 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
- bug#13549: 24.3.50; FR: Improve grep output (show function names, when possible),
Juri Linkov <=