From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: unifying emacs "go to definition" functionality Date: Wed, 20 Feb 2013 08:54:05 +0400 Message-ID: <87txp7d1qq.fsf@yandex.ru> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1361336063 3740 80.91.229.3 (20 Feb 2013 04:54:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 20 Feb 2013 04:54:23 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: Brendan Miller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 20 05:54:45 2013 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 1U81ha-00007e-J0 for ged-emacs-devel@m.gmane.org; Wed, 20 Feb 2013 05:54:42 +0100 Original-Received: from localhost ([::1]:47082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U81hG-000070-AQ for ged-emacs-devel@m.gmane.org; Tue, 19 Feb 2013 23:54:22 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:56886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U81h7-00006i-TP for emacs-devel@gnu.org; Tue, 19 Feb 2013 23:54:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U81h1-0003Md-0A for emacs-devel@gnu.org; Tue, 19 Feb 2013 23:54:13 -0500 Original-Received: from mail-lb0-f180.google.com ([209.85.217.180]:62337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U81h0-0003LX-PF for emacs-devel@gnu.org; Tue, 19 Feb 2013 23:54:06 -0500 Original-Received: by mail-lb0-f180.google.com with SMTP id q12so5557777lbc.25 for ; Tue, 19 Feb 2013 20:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=igWa5uuDdzjHsANZppI4PJjcPLKSIRdcoTCHFgglQ3A=; b=lzCcR0IdZLhQ9zkhh2xR0Z4OtYqaVBY2SouRxnsuN6B2wATvMXiSh3j74541QqYf/T GaxXTKu+5VG27WpJ2yPN/llmziWXqVGlxfMwLZD/klK83jkcwvzqhPj3ojZo+AzlPw3j yB1ZiilXQucmr9R3+7TJjSDDQtTvVvK7gdu9lHyJGFdaf1vLjNGBMIjg6j2tiX3eyTnK Vks62062ugWJyGbRgIYYwXi9Oi9qwe9g9p78T35vCTvKD6StgyNubp6xPiCMZslzmK3e D2NJTHijuFL/iN1D9tKubOpUIouqsW430KGSGW2PQTK9hf9twKxVBRDqvYtCIfKC2gDu 1vMA== X-Received: by 10.152.47.97 with SMTP id c1mr16488481lan.6.1361336045475; Tue, 19 Feb 2013 20:54:05 -0800 (PST) Original-Received: from SOL ([178.252.98.87]) by mx.google.com with ESMTPS id tm10sm38255996lab.10.2013.02.19.20.54.03 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 19 Feb 2013 20:54:04 -0800 (PST) In-Reply-To: (Brendan Miller's message of "Tue, 19 Feb 2013 16:28:04 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.217.180 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:157187 Archived-At: Brendan Miller writes: > Right now emacs has several modules that offer "go to definition" > functionality, all of which have different implementations, and > different behavior. > > 1. Etags uses M-. and M-* to push and pop from a pair of tag stacks > (find-tag-marker-ring, and tags-location-ring). > > 2. elisp uses C-h f TAB RETURN to jump to definition. It has no tag > stack, so there's no way to jump back. It's actually C-x F for Elisp if your use which-func, or whatever binding you have for find-function (by default, none). > 3. CEDET uses C-c , J to jump to definition. It has no tag stack, > though it pushes to the global mark ring. > > 4. Jedi (jump to definition/autocompletion for python) uses C-. It has > no tag stack. > > 5. SLIME uses etags keybindings, but I don't think it uses etags stack. > > By far the etags interface (M-. to jump to definition and push the > location, M-* to pop back), is the easiest interface to use, though > the underlying tagging engine is less precise than the others. I agree than etags's push/pop interface is the easiest in this list, but it also has room for improvement. > My suggestion is that the etags key bindings and tag stack be made > generic, and that M-. trigger some kind of callback through a buffer > local variable, so that jump to definition can be handled in a mode > specific way. The "callback" part seems to be the easiest (you add a save-buffer-position-function variable and make sure all navigation functions call it), and also the most important, I think. This way, the user we can have a navigation system that is a drop-in replacement for mark and tag rings. I have a small package that does that through advice, but that means I need to hardcode every function that does navigation, by hand, and/or ask any potential user to do that, too. https://github.com/dgutov/point-stack > Note that in addition to reusing the same keybindings, reusing the > same tag stack gives that added benefits that it's possible to > navigate through a high level language into a lower level language, > and then pop back out with M-*. I have this mocked up (in kind of a > hacky way) with elisp and C, where I can jump from elisp into the C > definition of a native function, navigate around C with etags or > CEDET, and then pop back out back into elisp again. Using the same keybindings for the jump commands is, on one hand, something that each user can set up themselves (it's customary to expect users to set their own keybindings), on the other, I looks hard to do something about this and retain backward compatibility at the same time. Unless everybody agrees that M-. is the way to go, of course. If you'd like to standardize on M-* too, then everybody would also need to agree which storage facility to use (e.g. mark ring or tag ring, and we have two mark rings, so the two ways are not exactly equivalent).