Comments (11)
@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 causegit-link
to only use line numbers if there's more than 1 line in the selected region
from git-link.
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.
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.
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.
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.
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.
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.
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.
"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.
"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.
Added to v0.8.0.
from git-link.
Related Issues (20)
- Feature request: support for Gitiles HOT 5
- Support not stripping ".git" from directory name
- Feature request: Add custom macro or function to define a custom git forge. HOT 4
- Fails to resolve insteadOf directives when looking up remote URLs HOT 1
- Feature Request: Choose from multiple remotes HOT 2
- support for http HOT 2
- support 'Gitea' 's (and its fokr : Forgejo ?) server ? HOT 3
- How to call git-link from another interactive function? HOT 1
- Git link from buffer created by `log-view-find-revision` goes to page not found on Github
- Control over whether to link to a file in a branch or a file in a commit HOT 2
- Add support for Savannah HOT 1
- Proper sourcehut link HOT 2
- Move CI to GitHub Actions or CircleCI HOT 1
- Support custom HTTP scheme HOT 3
- Support for Linking to `git blame` Page & Linking to Documentation Files like Org and Markdown Files on Bitbucket HOT 2
- not working for files in an auxiliary worktree (using git-worktree) HOT 4
- mapconcat: Wrong type argument: arrayp, (47 97 98 99 100 101 102 103 104 105 ...) HOT 10
- Regression - incorrect directory passed to function in "git-link-remote-alist" HOT 2
- replaces / in branch name with %2F but github URL retains the / HOT 2
- Trailing slash quirk
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git-link.