From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jorgen Schaefer Newsgroups: gmane.emacs.devel Subject: Generalizing find-definition Date: Sun, 2 Nov 2014 15:15:24 +0100 Message-ID: <20141102151524.0d9c665c@forcix> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1414937771 9407 80.91.229.3 (2 Nov 2014 14:16:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Nov 2014 14:16:11 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 02 15:16:04 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 1Xkvwo-0002U1-N2 for ged-emacs-devel@m.gmane.org; Sun, 02 Nov 2014 15:16:02 +0100 Original-Received: from localhost ([::1]:57418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xkvwo-0005YX-83 for ged-emacs-devel@m.gmane.org; Sun, 02 Nov 2014 09:16:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkvwP-0005R1-2I for emacs-devel@gnu.org; Sun, 02 Nov 2014 09:15:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XkvwH-0006Kc-Fw for emacs-devel@gnu.org; Sun, 02 Nov 2014 09:15:36 -0500 Original-Received: from loki.jorgenschaefer.de ([87.230.15.51]:33594) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkvwH-0006KU-8U for emacs-devel@gnu.org; Sun, 02 Nov 2014 09:15:29 -0500 Original-Received: by loki.jorgenschaefer.de (Postfix, from userid 998) id 0715320458D; Sun, 2 Nov 2014 15:15:27 +0100 (CET) Original-Received: from forcix (port-35731.pppoe.wtnet.de [46.59.190.112]) by loki.jorgenschaefer.de (Postfix) with ESMTPSA id 6DA96200601 for ; Sun, 2 Nov 2014 15:15:26 +0100 (CET) X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.25; i586-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 87.230.15.51 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:176235 Archived-At: Hello! Emacs by default uses etags.el to find definitions. This is great for C and similar more static languages, but many more dynamic languages have other ways of finding definitions. This has lead to major/minor modes redefining M-. to a specialized "go to definition" function (e.g. SLIME for CL, slime-nav for Emacs Lisp, Geiser, Cider, Elpy etc.). I think it would be good if Emacs provided a generalized functionality for M-. and related commands instead of having all these modes re-implementing it. If I get positive feedback on the following ideas, I'm happy to do the necessary coding (once the git transition is done). M-. is bound to a new command `find-definition', which primarily calls the value of a new variable `find-definition-function' (by default a wrapper around `find-tag' to keep the current functionality intact). `find-definition' also keeps track of the tag ring, so this would move `find-tag-marker-ring' and related functionality out of etags.el, too. M-* is the standard opposite command for this, so that would be extracted as well. SLIME and a few other modes re-define M-, to be the opposite for M-. instead for easier navigation. How do you feel about swapping the definition of M-, and M-* in etags.el? C-M-. is currently bound to find-tag-regexp. There is currently no standard functionality in Emacs to find the callers of a symbol at point, which might be nice to put on C-M-. if it is defined at some point for symmetry reasons. If so, find-tag-regexp needs a new key binding. I'm unsure how useful find-tag-regexp is to begin with as I do not use tags tables, so I kept it out of the proposal below, even though it is certainly related. Other commands affected by this would be C-x 4 . and C-x 5 . So the new module find-definition.el would define: Variable `find-definition-function' A function to be called to find definitions for the symbol at point. It is called with no arguments, and should return a marker for the location of the definition. M-. find-definition Call `find-definition-function' and go to the marker returned, if any. Store the old location in `find-definition-marker-ring'. M-, or M-* find-definition-pop-mark Go to the last location in `find-definition-marker-ring' C-x 4 . and C-x 5 . Same as `find-definition', except the marker returned by `find-definition-function' is displayed in another window or frame instead. Changes to etags.el: Remove the aforementioned key bindings. Provide a new function, `etags-find-definition', which calls `find-tag-noselect'. This will also check for the current prefix argument to mimic the old behavior for NEXT-P. Changes to elisp-mode.el: Provide a value for `find-definition-function' which finds the definition of the symbol at point. Comments? Regards, Jorgen