From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#13549: 24.3.50; FR: Improve grep output (show function names, when possible) Date: Wed, 22 May 2013 23:44:24 +0300 Organization: JURTA Message-ID: <871u8ylp7b.fsf@mail.jurta.org> References: <87a9rxux7q.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1369256784 6846 80.91.229.3 (22 May 2013 21:06:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 22 May 2013 21:06:24 +0000 (UTC) Cc: 13549@debbugs.gnu.org To: Jambunathan K Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 22 23:06:24 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UfGEp-0006ax-0x for geb-bug-gnu-emacs@m.gmane.org; Wed, 22 May 2013 23:06:23 +0200 Original-Received: from localhost ([::1]:44945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfGEo-00008s-GW for geb-bug-gnu-emacs@m.gmane.org; Wed, 22 May 2013 17:06:22 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfGEj-00007M-D6 for bug-gnu-emacs@gnu.org; Wed, 22 May 2013 17:06:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfGEi-00084w-DK for bug-gnu-emacs@gnu.org; Wed, 22 May 2013 17:06:17 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfGEi-00084m-AA for bug-gnu-emacs@gnu.org; Wed, 22 May 2013 17:06:16 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UfGFS-0002oM-1z for bug-gnu-emacs@gnu.org; Wed, 22 May 2013 17:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 22 May 2013 21:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13549 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13549-submit@debbugs.gnu.org id=B13549.136925677410736 (code B ref 13549); Wed, 22 May 2013 21:07:02 +0000 Original-Received: (at 13549) by debbugs.gnu.org; 22 May 2013 21:06:14 +0000 Original-Received: from localhost ([127.0.0.1]:56788 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfGEg-0002n6-CT for submit@debbugs.gnu.org; Wed, 22 May 2013 17:06:14 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:35315 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfGEc-0002mm-Mg for 13549@debbugs.gnu.org; Wed, 22 May 2013 17:06:12 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id C4DCC258B9E91C; Wed, 22 May 2013 14:05:22 -0700 (PDT) In-Reply-To: <87a9rxux7q.fsf@gmail.com> (Jambunathan K.'s message of "Fri, 25 Jan 2013 20:27:29 +0530") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:74462 Archived-At: > 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