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

diff-options and the ability to bind keys to tig prompt commands #116

Closed
wants to merge 9 commits into from

Conversation

tsibley
Copy link
Contributor

@tsibley tsibley commented Feb 13, 2013

Adds support for the features described in GH #69.

This is useful for persistent arguments to the diff view instead of
setting TIG_DIFF_OPTS or always passing them on the command line
invocation.
parse_args() is only used by option_set_command() for the two "argv"
style options: blame-options and diff-options.  Allowing parse_args() to
overwrite the destination enables ":set diff-options = ..." to work more
than once from within the tig prompt (or at all if first set via tigrc).

This is safe since argv_copy() handles the necessary freeing, added as
part of 7dfa0b2.
Preparation for running prompt commands from keybindings.
This allows new diff-options to take effect.  The diff view is still
unrefreshable when reading data from STDIN.
Redrawing is not always enough but is still used as a fallback if the
view is unrefreshable.
A boolean return value limits the ability of open_run_request() to
handle more complex run requests in the future.  The "quit, refresh, or
do nothing" logic in view_driver(), based on the boolean return value,
is easily represented by returning REQ_QUIT, REQ_REFRESH, or REQ_NONE
from open_run_request() itself.  Returning a request also seems more in
line with workings of other functions which process requests.

The current view is passed to open_run_request(), which enables it to
return REQ_REFRESH as appropriate.  For the future, this also opens the
door for other queries and actions on the view.
"Internal" run requests now provide a way to add keybindings for tigrc
and tig prompt commands.  For example:

    bind diff F :set diff-options = --full-diff

Much of the change to open_run_request() is increased indentation;
viewing the diff with whitespace ignored (git show -w or pressing W in
tig) reveals the simplicity of the functional changes.
@jonas
Copy link
Owner

jonas commented Feb 18, 2013

Thanks, all applied except the modeline patch. I prefer if you could add it to your ~/.vimrc instead.

@jonas jonas closed this Feb 18, 2013
@tsibley
Copy link
Contributor Author

tsibley commented Feb 20, 2013

Thanks for merging!

I included the modeline patch because contributors may not have the same
personal whitespace styles, but they should still use the project's
preferred style. For example, my .vimrc specifies a tabstop of 4 and
uses spaces instead of hard tabs. This is my preferred personal style
and the style preferred by many projects I contribute to. I try to use
a tabstop of 8 and hard tabs when working on tig, however, because it's
the predominate style of the code. While I could special-case tig.c
with a ftplugin, it seems like a property of the file should be in the file.

@richo
Copy link
Contributor

richo commented Feb 20, 2013

The other option is .exrc which is per project but not file specific, unfortunately there's no option to prompt with it's content. I might build a plugin.

@tsibley
Copy link
Contributor Author

tsibley commented Feb 20, 2013

The whitespace preferences are really project-wide, not just tig.c, but
tig.c is probably the most touched file.

@jonas
Copy link
Owner

jonas commented Feb 21, 2013

For some of the projects I have contributed to I've simply added a line like this to ~/.vimrc:

autocmd BufRead */SFLPhone/*    set ts=4 sw=4

On the other hand, I want to keep the most active contributor to tig happy so I will add the mode lines. :)

@tsibley
Copy link
Contributor Author

tsibley commented Feb 21, 2013

:) tig is fantastic, and I enjoy contributing. I use it everyday for
digging into complex history and branch review.

On 02/20/2013 07:25 PM, Jonas Fonseca wrote:

For some of the projects I have contributed to I've simply added a
line like this to ~/.vimrc:

|autocmd BufRead /SFLPhone/ set ts=4 sw=4
|

On the other hand, I want to keep the most active contributor to tig
happy so I will add the mode lines. :)


Reply to this email directly or view it on GitHub
#116 (comment).

jonas added a commit that referenced this pull request Feb 22, 2013
This was originally suggested by Thomas Sibley to ease contributions.
Use the update mechanism to add Copyright notice for 2013.
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

Successfully merging this pull request may close these issues.

3 participants