Giter VIP home page Giter VIP logo

Comments (11)

sshaw avatar sshaw commented on July 17, 2024 1

@husainaloos, @talwrii take a look at f176318.

  • C-u - git-link will not use line numbers
  • (setq git-link-use-single-line-number nil) will cause git-link to only use line numbers if there's more than 1 line in the selected region

from git-link.

sshaw avatar sshaw commented on July 17, 2024

One issue I came across was that the package does not support opening the file in the browser.

One can open the file in the browser by setting git-link-open-in-browser but I assume you mean without a line number?

If I want to point a given file (no single region selected) to a collaborator, I won't be able to do that without losing (1).

Yes, linking out a line is something that would be nice to have, but what's the API for this?

I think using a prefix argument to git-link, git-link-commit, etc... is the best approach but currently the default prefix arg prompts for a remote. This is something I think should probably change in 1.0 but that aside what to do now? Maybe an additional prefix arg?

There is also the case to use a prefix are when one wants to enter a branch name.

from git-link.

husainaloos avatar husainaloos commented on July 17, 2024

That is correct. I meant the file without a line number.

Here is a suggestion. Though it might affect the behavior of handlers people use in git-link-remote-alist, it will not cause an error:

Currently any handler will have to handler the following arguments: (hostname dirname filename branch commit start end). We can have it where there are three cases for start/end values:

  • start=nil and end=nil, this means that the browser should open the file (without a line number). This is an example.
  • start!=nil and end=nil, this means that the browser should open the file pointing to a line. This is an example
  • finally, start!=nil and end!=nil, this means that the browser should open the file pointing to a region. This is an example

I believe this is the behavior of GBrowse in fugitive in the vim world.

from git-link.

sshaw avatar sshaw commented on July 17, 2024

Hi,

We can have it where there are three cases for start/end values:
...

Yes, agreed. But how to tell the interactive git-link command to not generate the line number? Currently if it's used in cases like magit-status buffer there's no line number so it's not an issue but in a regular buffer with a point, how do say: don't use the line number?

from git-link.

talwrii avatar talwrii commented on July 17, 2024

But how to tell the interactive git-link command to not generate the line number?

The "emacsy" way of doing this would be to use a prefix argument (e.g. press C-u a number of times before the command).

An alternative approach would be to use a dynamically bound environment variable and let people define their own keybindings if they want a file without a line (this is what I end up using myself most of the time).

(lamba () (intteractive) (let ((git-link-include-line nil)) (git-link))

Although actually, I think the best approach is to omit the line if you are line 1 (this is pretty intuitive and easy to remember).

from git-link.

sshaw avatar sshaw commented on July 17, 2024

The "emacsy" way of doing this would be to use a prefix argument (e.g. press C-u a number of times before the command).

Indeed.

An alternative approach would be...

Yes, this is what I wanted to hear about, alternative approaches. But unless @husainaloos has any other ideas, I think the best option is to use a prefix arg of C-u - git-link. - is a good mnemonic for "without line number".

Although actually, I think the best approach is to omit the line if you are line 1 (this is pretty intuitive and easy to remember).

I sorta like this but linking to line 1 is a valid use case. As an innocent use I'd consider it a bug instead of a feature.

from git-link.

husainaloos avatar husainaloos commented on July 17, 2024

Hi,

We can have it where there are three cases for start/end values:
...

Yes, agreed. But how to tell the interactive git-link command to not generate the line number? Currently if it's used in cases like magit-status buffer there's no line number so it's not an issue but in a regular buffer with a point, how do say: don't use the line number?

@sshaw I am no emacs power user and I am not familiar with elisp enough to wrote lisp. So take what follows with a grain of salt.

I don't think I understand the difficulty. Maybe it is technical? Emacs has a function that determines if there is a selected region in the buffer or not. If there is no selected region, then the link generated only contains the file and no start/end line. If there is a region selected, then we calculated the start and end of that line, and generate a link based on that:

if (use-region-p) {
    start = line-number-at-pos(region-beginning)
    end = line-number-at-pos(region-end)
} else {
    start = end = nil
}
call hook_function(start, end)

Would that not work?

from git-link.

sshaw avatar sshaw commented on July 17, 2024

Currently if there's no region we link to the line number. Can't stop doing that. I think the best bet is to check for a prefix argument of -. So assuming git-link is bound to C-c g l you'd type: C-u - C-c g l. = "minus the line number" 💲💲💲

Maybe there's a setting too git-link-no-region-no-line-number...

from git-link.

husainaloos avatar husainaloos commented on July 17, 2024

"Currently if there's no region we link to the line number. Can't stop doing that." Is the reason to maintain compatibility? Because to me, and I know this is subjective, opening a file when no region is selected is the more intuitive approach.

from git-link.

sshaw avatar sshaw commented on July 17, 2024

"Currently if there's no region we link to the line number. Can't stop doing that." Is the reason to maintain compatibility?

Linking to a single line is a valid use case. I do it all the time. I don't think having to select a 1 line region just to link to that line is a good UI.

This repo is 6 years old and there has been a ton of requests. This is the first to not want line number at point.

from git-link.

sshaw avatar sshaw commented on July 17, 2024

Added to v0.8.0.

from git-link.

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.