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

Provide a %(fileline) state variable #304

Closed
bkudria opened this issue Jun 16, 2014 · 6 comments
Closed

Provide a %(fileline) state variable #304

bkudria opened this issue Jun 16, 2014 · 6 comments
Milestone

Comments

@bkudria
Copy link

bkudria commented Jun 16, 2014

Some editors support jumping to a particular line. It'd be great if the current line was exposed as %(fileline) or something similar, so an editor keybinding could instruct the editor to jump right to that line.

@jonas
Copy link
Owner

jonas commented Jun 17, 2014

The built-in editor already supports jumping to a specific line number, but
this new variable will allow to create custom editor bindings. The only
thing is how to handle missing line numbers since for example Vim requires
that the parameter is passed as +lineno. I guess 1 is a sane default.
On Jun 16, 2014 4:01 PM, "Benjamin Kudria" notifications@github.com wrote:

Some editors support jumping to a particular line. It'd be great if the
current line was exposed as %(fileline) or something similar, so an
editor keybinding could instruct the editor to jump right to that line.


Reply to this email directly or view it on GitHub
#304.

@vivien
Copy link
Contributor

vivien commented Jun 17, 2014

Since 1 is a valid line number, I would suggest defaulting to 0 for missing line number.
And common editors fallback gracefully to the first line (tested with vim, nano and emacs).

Also, given the terminology for patches, I would suggest %(diffline) or %(chunkline).
(%(diffline) looks more appropriate)

@bkudria
Copy link
Author

bkudria commented Jun 17, 2014

@jonas the built-in editor binding doesn't work for me, since my git.editor is set to 'mvim --remote-wait-silent'. I get this error:

Argument missing after: "--remote-wait-silent"
More info with: "vim -h"
*** Your editor reported an error while opening the file.
*** This is probably because it doesn't support the line
*** number argument added automatically. The line number
*** has been disabled for now. You can permanently disable
*** it by adding the following line to ~/.tigrc
*** set editor-line-number = no

Vim is expecting a filename after --remote-wait-silent, but a line number before the option. Hence the need for a custom binding, and a linenumber placeholder. (I'd like to connect to my existing Vim instance to avoid swap file issues.)

@vivien %(diffline) wouldn't make sense in the blame view, for example. But 0 is a good default.

@jonas
Copy link
Owner

jonas commented Jun 18, 2014

OK, let's make 0 the default. Since the state variables are "context sensible" I'd prefer to have only one %(lineno) or %(fileline) variable. Else you would have to have different editor bindings for the diff and blob/blame views.

@jonas jonas added this to the tig-2.1 milestone Nov 9, 2014
@jonas jonas closed this as completed in 30b3804 Nov 10, 2014
@jonas
Copy link
Owner

jonas commented Nov 10, 2014

@bkudria I finally got around to implementing this. I hope this fixes your problem. Feel free to provide feedback if you have the time to test. Note that by default the variable defaults to 0, but Vim doesn't care about that.

@bkudria
Copy link
Author

bkudria commented Nov 10, 2014

@jonas this works beautifully, thanks!

dcfranca pushed a commit to jerojasro-booking/tig that referenced this issue Nov 27, 2014
This exposes the current file line number as the variable `%(lineno)`.
The blame, blob, diff, grep and stage views updates the variable.

Fixes jonas#304
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants