GithubHelp home page GithubHelp logo

When using "who-calls" and selecting an item, one should go to where the function is called, not to the first definition of the calling function about edts HOT 4 CLOSED

sebastiw avatar sebastiw commented on July 24, 2024
When using "who-calls" and selecting an item, one should go to where the function is called, not to the first definition of the calling function

from edts.

Comments (4)

SpaceOgre avatar SpaceOgre commented on July 24, 2024

This has bugged me a bit to and I have done a fast fix that looks like this:

(defun edts-find-callers (module function arity)
  "Jump to any all functions calling `module':`function'/`arity' in the
current buffer's project."
  (edts-log-info "Finding callers of %s:%s/%s" module function arity)
  (let* ((callers (edts-get-who-calls module function arity))
         (caller-items (mapcar #'edts-function-popup-item callers)))
    (edts-do-find-callers caller-items)
    (edts-find-first-apperence-in-fun module function)))

(defun edts-find-first-apperence-in-fun (module function)
  (let ((cur-module (ferl-get-module))
        (mark  (copy-marker (point-marker)))
        (re (if (string-equal module cur-module)
                function
              (concat module ":" function))))
    (if (re-search-forward re nil t)
        (progn
          (beginning-of-line)
          (ring-insert-at-beginning (edts-window-history-ring) mark))
      (null (goto-char mark)))))

I'm far from a lisp expert so there is probably a better a more accurate way to do it but it's a start.

  • edts-find-first-apperence-in-fun is a new function
  • edts-find-callers is modified to call edts-find-first-apperence-in-fun
    It just searches for the first appearance of module:function after the point of the calling function head. Regexp needs to better so not comments etc are chosen.

from edts.

tjarvstrand avatar tjarvstrand commented on July 24, 2024

Actually having looked at it, it's pretty straight forward to get this information straight out of xref. I just need to update the api a little. I'll try to get to it since I'm currently rewiring all of the xref code anyway.

from edts.

tjarvstrand avatar tjarvstrand commented on July 24, 2024

Sometimes things are really easy. The fix is in master now.

from edts.

SpaceOgre avatar SpaceOgre commented on July 24, 2024

Nice! I started to look at the server code but since I have never used xref before I hit a wall with that, but it felt like that was to place to really change and not my fast hack.

Keep up the good work, I use edts every day for work and it just keeps getting better 👍

from edts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.