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

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

Projects
None yet
3 participants
Contributor

tsibley commented Feb 13, 2013

Adds support for the features described in GH #69.

tsibley added some commits Feb 9, 2013

@tsibley tsibley Add a diff-options config, similar to blame-options
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.
56a7cf2
@tsibley tsibley Add a vim modeline to tig.c to codify the file's whitespace preferences 9f1e397
@tsibley tsibley Allow overwriting of a previously set "argv" option
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.
bced6fd
@tsibley tsibley Support refreshing the diff view by reloading the data
This allows new diff-options to take effect.  The diff view is still
unrefreshable when reading data from STDIN.
b8d0ddf
@tsibley tsibley Refactor the prompt command handling into a separate function
Preparation for running prompt commands from keybindings.
efd18b8
@tsibley tsibley Return a request from open_run_request()
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.
df12ae9
@tsibley tsibley After setting an option, refresh the view if possible
Redrawing is not always enough but is still used as a fallback if the
view is unrefreshable.
8230f0d
@tsibley tsibley Key bindings which execute tig prompt commands
"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.
92f9711
@tsibley tsibley Document the ability to bind internal commands 63848af
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

Contributor

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.

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.

Contributor

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.

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. :)

Contributor

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 jonas added a commit that referenced this pull request Feb 22, 2013

@jonas jonas [#116] Add vim mode lines and machinery for updating C file headers
This was originally suggested by Thomas Sibley to ease contributions.
Use the update mechanism to add Copyright notice for 2013.
0609a8c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment