GithubHelp home page GithubHelp logo

Comments (4)

ubolonton avatar ubolonton commented on April 26, 2024

I think we should keep the versions that use tree-sitter types, so that user code can avoid the back-n-forth conversion when necessary. However, I agree that adding versions that use Emacs types would make it more convenient for other use cases.

To clarify, the types are:

  1. tree-sitter byte
  2. tree-sitter point, or [row column]
  3. Emacs byte
  4. Emacs position
  5. Emacs (current-column)
  6. Emacs (line-number-at-pos)

The only conversions that are simple 1+/1- are 1 <-> 3, and 2 <-> 6 (for row).
The rest are more involved, since Emacs counts characters, while tree-sitter counts bytes.

There are already functions to convert 1/2 <-> 4, which is probably the most commonly used type in Emacs.

from elisp-tree-sitter.

ubolonton avatar ubolonton commented on April 26, 2024

The most commonly needed conversions are fairly involved, which is why I prefer keeping the lower-level functions that take/return tree-sitter types directly.

from elisp-tree-sitter.

ubolonton avatar ubolonton commented on April 26, 2024

I think I'll add variants that return Emacs's positions to functions that return ts-byte and ts-point. It's a bit unfortunate that both Emacs and tree-sitter use both "point" and "position" to call things. Naming is going to get "interesting".

from elisp-tree-sitter.

ubolonton avatar ubolonton commented on April 26, 2024

I added position variants to some functions. They should be preferred over the byte variants.

from elisp-tree-sitter.

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.