emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bad moves with xref-find-definitions


From: Dmitry Gutov
Subject: Re: Bad moves with xref-find-definitions
Date: Sat, 25 Apr 2015 22:01:47 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Thunderbird/36.0

Hi there,

On 04/23/2015 06:07 PM, Vitalie Spinu wrote:

There has been a breaking change in UI with respect to find definition
functionality. I am all for generic interface but IMO there is no reason
to break standard Emacs interaction mechanism in favor for some not that
well thought UI borrowed from SLIME.

SLIME has plenty of users who find the approach convenient. You should notice that in both CIDER discussions you've referenced that opinion has also been expressed.

When discussing the options for the new UI to replace `find-tag', both initial proposals also opted not to prompt by default [1][2]. And this is the first complaint we've received about that aspect, in the four months since xref had been introduced.

  1) `find-tag` (previously bound to M-.) was prompting for a symbol
      before jumping to the definition. The symbol at point was the
      default. On the expense of one additional RET this was very
      convenient because it leaves the possibility to jump to a different
      symbol and also saves you from useless navigation to a symbol when
      symbol is not directly under the cursor. The desired symbol might
      not be visible, or even present in current buffer.

Since you're usually intent on typing out the symbol name, pressing `C-u' before that shouldn't make a lot of difference. On the other hand, when "jump to the symbol at point" is a frequent operation, it makes sense to optimize it.

      Now, "xref-find-definitions" encourages you to navigate to a symbol
      by disrupting the flow twice. Once, when you navigate to a symbol,
      and often for the second time when you need to go back to the
      editing after you saw the definition. This just fosters a bad habit
      of tracking what you read with a cursor. It just cannot be right.

I don't know if it's a bad habit. Apparently, it's a common one.

      Needless to say that most other functionality in Emacs does ask for
      completion before performing an action (documentation, find-file
      etc).

In my view, "jump to the thing at point" is a different kind of operation (and it can work with symbols, file paths, etc).

It also has correspondence in other editors: Ctrl-] in Vim, or Ctrl+Click in IDEs.

      Having an option to *not* navigate to symbol is very useful and
      Emacs was recognizing this need all this time. Why would you change
      this now?

The question could as well be, why wasn't it changed sooner. Anyway, this behavior can be customizable, like suggested by Michael Griffiths in the second CIDER discussion.

But while you're only person requesting it, you can modify the current behavior trivially with `advice-add'.

      Etags is still very useful even with dynamic languages. For example
      the language tool might not load all the files in current
      project/directory, or you might intentionally keep some code in
      non-project directories. You might also define your tags for a
      bunch of other related projects which you want to access from the
      current project.

`completion-at-point-functions' defaults to `'(tags-completion-at-point-function)'. Are you also worried about a major mode overriding it? That's the whole point of adding this kind of variable.

And if by any chance the major mode does a poor job, you can use xxx-mode-hook to override it back. In this case, there already exists `xref-etags-mode', because of a prior request.

      Now, when "M-." is gone, if the language re-defines
      `xref-find-function` how do I access tags? Do I need to bind a new
      global key for `find-tag` command?

You can also add a separate binding for it. And if/when `find-tag' goes away, you can use that binding for a new command wrapping `xref-find-definitions'.

By the way, it seems I've forgot to declare `find-tag' obsolete.

There has been a lengthy discussion on Cider issue tracker to change the
behavior borrowed from SLIME into standard emacs UI [1][2]. Once that
was changed, emacs itself seems to move into wrong ways.

Maybe the fact that Emacs currently behaves in a certain some way is not always a bullet-proof argument in its favor.

[1] http://lists.gnu.org/archive/html/emacs-devel/2014-11/msg01302.html
[2] http://lists.gnu.org/archive/html/emacs-devel/2014-11/msg01684.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]