Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leap with Label #206

Open
BazookaMusic opened this issue Mar 16, 2018 · 2 comments
Open

leap with Label #206

BazookaMusic opened this issue Mar 16, 2018 · 2 comments
Labels
New Feature A new feature that is not currently implemented.

Comments

@BazookaMusic
Copy link
Contributor

BazookaMusic commented Mar 16, 2018

I am thinking about a feature to allow for quick jumping between points of interest in text or code. The principle would be to have a distinct symbols as beacons in the file so that they can be instantly reachable by an editor find. These symbols will consist of an extremely rare encapsulating string, a label and a number for grouping . It would look like <<. Label_Number .>> . This would work with 4 commands.

  1. The set label <text> [at index <number>] command with set the label to a string value similarly to the set format command. The number argument will by default be the starting index of the label to be printed. Its value will increment.

  2. The label [here] command will print the label at the current cursor position.

  3. The leap [<number>] command will jump to the currently set label which is indexed by number or to the next index, if a number is not given. The command will remember the last index it was called with. In case of a nonexistent index it will jump randomly to the first matching label. Alternatively, a history of the labels could be kept which will contain the available indexes and it could jump to the last index.

  4. A clear labels command which would delete all the labels in the text. (This could be messy)

Another enhancement would be a self modifying rule which would have a dictionary of labels for increased accuracy. This would allow for a consistent leap <Label_name> command which I am hesitant to include in the original idea because with the accuracy results I have observed, I don't think it would be very usable.

Uses of the Leap command

  1. User-defined Bookmarks
  2. Rule templates which could include labels at points of interest. For example, in place of a function name, argument lists, etc.
  3. Easy backtracking

Example usage

``` def <<.Function_0.>> ( <<.Function_1.>> , <<.Function_2.>> ): <<.Function_3.>> return <<.Function_4.>> ``` This could be the definition of a function inside the Python rules file. The user could say "set label function" and use the leap command to position the cursor at the function name, the arguments and finally the return statement.

I'd like to take this on after some feedback about how useful it sounds and the way it should work.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@BazookaMusic BazookaMusic changed the title leap with Label leap with Label #enhancement Mar 16, 2018
@BazookaMusic BazookaMusic changed the title leap with Label #enhancement leap with Label Mar 16, 2018
@LexiconCode
Copy link
Member

LexiconCode commented Mar 17, 2018

I love the utility of the idea. Importation would be very tricky when it comes to index number. Wouldn't the index number change any time text or function was edited? Could you expound on what you mean by that index number?

This would not be hard to create using Visual Studio Code #198 because it's IDE aware. VSC has a bookmark feature which we could pair label to line position.

Or If the text is highlighted it could be paired with the search function. And you could jump from each reference. For instance if there's 3 references you could jump to the 3rd.

I put some more thought into it and let me know what you think there's definitely a lot of options with an API.

I'm not clever enough to figure out IDE agnostic approach.

@BazookaMusic
Copy link
Contributor Author

BazookaMusic commented Mar 18, 2018

I like the idea of visual studio code and I think something similar would be possible with many other editors with support for bookmarks. I have not used the bookmarks personally however So I will have to take a look at them.

Now for my original idea. First about the index number: I was thinking that as you said updating the Index as function is edited would be very hard in an ide agnostic context, so perhaps the user Could make up for it.
My approach was that there would be two rules:

  1. Once a label is set, the index number is set to zero or any number given by the user.
  2. When jumping, Index is set to the destination, either a number spoken by the user or index+1 if "next" is spoken.
    This would work if the user only uses the same label multiple Times in cases Where she wants to Jump sequentially from one Spot to another or for blocks of code small enough that every Index is visible . It would be impossible to edit in random Order or to jump back without explicitly stating the indexes. I felt this wouldn't be a problem because the indexes would act as a visual aid for the user so that He doesn't have to count how many references She has to Skip to get to the the one she wants.
def <^(function)^>(<^(function)^>,<^(function)^>,<^(function)^>):
    <^(function)^>(<^(function)^>)
    return <^(function)^>

In the above code example without an Index ,it would be very annoying to have to count how many labels there are between the first and The Return statement to Jump directly to The Return statement. On the contrary, the Index would make it easy to say jump 6 and get there directly.

def <^(function_0)^>(<^(function_1)^>,<^(function_2)^>,<^(function_3)^>):
    <^(function_4)^>(<^(function_5)^>)
    return <^(function_6)^>

A problem comes up if you are somewhere else in the code and you want to Jump to a label without knowing its index and its index isn't 0. For this case I think you Could use the form of the label to partially search for the label. In the above case you could look for "(^function_" and try to read the index in a way similar to the jump in and fill commands.

(I'm sorry for the terrible text formatting, Google Voice doesn't help very much and I have rsi)

@LexiconCode LexiconCode added Enhancement Enhancement of an existing feature New Feature A new feature that is not currently implemented. and removed Enhancement Enhancement of an existing feature labels Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Feature A new feature that is not currently implemented.
Projects
None yet
Development

No branches or pull requests

2 participants