From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: Re: Generalizing find-definition Date: Sat, 06 Dec 2014 12:19:18 -0600 Message-ID: <85bnngiqu1.fsf@stephe-leake.org> References: <20141102151524.0d9c665c@forcix> <20141117211039.37f03409@forcix> <877fymghgb.fsf@bredband.net> <85ppc0qf9a.fsf@stephe-leake.org> <85zjb3o09d.fsf@stephe-leake.org> <85tx1amnyg.fsf@stephe-leake.org> <85egsem1u2.fsf@stephe-leake.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1417890001 12315 80.91.229.3 (6 Dec 2014 18:20:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Dec 2014 18:20:01 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 06 19:19:54 2014 Return-path: Envelope-to: ged-emacs-devel@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 1XxJxR-0001oA-Rm for ged-emacs-devel@m.gmane.org; Sat, 06 Dec 2014 19:19:53 +0100 Original-Received: from localhost ([::1]:55184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XxJxR-0000Q5-6N for ged-emacs-devel@m.gmane.org; Sat, 06 Dec 2014 13:19:53 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XxJx6-0000Ps-Ai for emacs-devel@gnu.org; Sat, 06 Dec 2014 13:19:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XxJwy-0002NM-Qa for emacs-devel@gnu.org; Sat, 06 Dec 2014 13:19:32 -0500 Original-Received: from dnvrco-outbound-snat.email.rr.com ([107.14.73.226]:6033 helo=dnvrco-oedge-vip.email.rr.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XxJwy-0002MN-Lq for emacs-devel@gnu.org; Sat, 06 Dec 2014 13:19:24 -0500 Original-Received: from [70.94.38.149] ([70.94.38.149:52738] helo=TAKVER) by dnvrco-oedge02 (envelope-from ) (ecelerity 3.5.0.35861 r(Momo-dev:tip)) with ESMTP id FE/1E-05421-8A843845; Sat, 06 Dec 2014 18:19:20 +0000 In-Reply-To: (Helmut Eller's message of "Sat, 06 Dec 2014 09:55:13 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.94 (windows-nt) X-RR-Connecting-IP: 107.14.64.130:25 X-Authority-Analysis: v=2.1 cv=NtdfcqtJ c=1 sm=1 tr=0 a=AppmJ/7ZOOFWL/q6u6u93g==:117 a=AppmJ/7ZOOFWL/q6u6u93g==:17 a=ayC55rCoAAAA:8 a=fNEgcOh0sVsA:10 a=9i_RQKNPAAAA:8 a=pGLkceISAAAA:8 a=UdDPmWSrQkXxL4NteiIA:9 X-Cloudmark-Score: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 107.14.73.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:179199 Archived-At: Helmut Eller writes: > On Fri, Dec 05 2014, Stephen Leake wrote: > > [...] >> I have a function that combines 1 and 2 and similar links; it calls >> ffap-string-at-point, compares that to an alist of (regexp . command), >> and then defaults to find-file. The alist has: > [...] >> Perhaps a similar function could be included in xref? > > Just thinking aloud: > > I guess such filenames or URLs (URIs?) typically occur in comments, > string literals, or perhaps in things like #include or > (require 'some-library). M-x ffap seems cover this partially, but then > there's also M-x find-library. Certainly a lot of things to find! I just added this for (require 'foo): (set (make-local-variable 'ff-search-directories) 'load-path) (set (make-local-variable 'ff-special-constructs) nil) (add-to-list 'ff-special-constructs (cons "^(require '\\(.*\\))" (lambda () (file-name-nondirectory (locate-library (match-string 1)))))) That's used by ff-find-other-file. > A problem seems to be that xref-identifier-at-point would need a > possibly complicated heuristic to determine if we are at such a filename > or a "normal" identifier. Yes, I think that requires input from the user. Currently, I use C-F11 (bound to 'ff-find-other-file') when the thing at point is something related to a filename ('require' in elisp, '#include' in C++, 'with' in Ada), and C-c C-d (now bound to 'xref-find-definitions') when the thing at point is a symbol. We could just search for both, and present a list, but I think that would be more cumbersome than it's worth. > Maybe it's easier to have a separate xref-file-name-at-point which > would by default do what ffap-guess-file-name-at-point does. For ELisp > it should additionally recognize (require 'foo) and somehow reuse > find-library. find-file.el and files.el provide similarly customizable 'find a file' functions. It would be nice to unify them, but that's a lot of work. I'm most familiar with find-file, but it could easily be that files is a better structure. > There's also the problem which keybinding to use. We will probably > steal the global bindings for M-. and M-, from etags but beyond that > we don't have keys for our commands. At least one additional prefix key > for a xref keymap would be nice. ada-mode uses C-c C-o for a wrapper around ff-find-other-file. I don't see a similar binding in c-mode. We would probably need to keep xref-minor-mode for now, and provide a binding in there. Then if it becomes popular, it can be promoted to a global binding. -- -- Stephe