From: Juri Linkov <juri@jurta.org>
To: Jambunathan K <kjambunathan@gmail.com>
Cc: 13549@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 [thread overview]
Message-ID: <871u8ylp7b.fsf@mail.jurta.org> (raw)
In-Reply-To: <87a9rxux7q.fsf@gmail.com> (Jambunathan K.'s message of "Fri, 25 Jan 2013 20:27:29 +0530")
> 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
next prev parent reply other threads:[~2013-05-22 20:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 14:57 bug#13549: 24.3.50; FR: Improve grep output (show function names, when possible) Jambunathan K
2013-01-25 15:05 ` Jambunathan K
2013-01-25 17:32 ` Glenn Morris
2013-01-25 18:55 ` Stefan Monnier
2013-02-03 13:49 ` Jambunathan K
2013-05-22 20:44 ` Juri Linkov [this message]
2013-05-22 22:03 ` Stefan Monnier
2013-05-24 20:55 ` Juri Linkov
2013-05-25 13:08 ` Jambunathan K
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871u8ylp7b.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=13549@debbugs.gnu.org \
--cc=kjambunathan@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).