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

Persistent readline history #620

Merged
merged 1 commit into from
Jun 28, 2017

Conversation

rolandwalker
Copy link
Contributor

Persist readline history to ~/.tig_history or $XDG_DATA_HOME/tig/history.

Arguably the $XDG_DATA_HOME part doesn't belong in prompt.c but this does keep #ifdef HAVE_READLINE tucked into a single file.

It might be preferable to persist only the "search" part of the history as less does. Certainly that's the part of the feature I intend to use. However, all readline inputs are currently merged in the volatile history, and I wanted to avoid changing existing UI.

Another desirable refinement would be to take HISTORY_SIZE from a ~/.tigrc option, and support disabling persistent history when set to zero.

It doesn't seem practical to provide test coverage as there isn't a reliable way to inspect the binary for its compile-time readline configuration.

@jonas
Copy link
Owner

jonas commented Jun 27, 2017

Yeees, looking forward to using this. \o/
Will take a look tomorrow.

@@ -46,6 +46,8 @@ struct input {
enum input_status prompt_default_handler(struct input *input, struct key *key);
char *read_prompt_incremental(const char *prompt, bool edit_mode, bool allow_empty, input_handler handler, void *data);
char *read_prompt(const char *prompt);
const char *prompt_histfile(void);
void prompt_teardown(void);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor nit, these don't have to be exported.

src/prompt.c Outdated
@@ -466,10 +467,44 @@ read_prompt(const char *prompt)
return line;
}

const char *
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and both can be declared static.

@jonas
Copy link
Owner

jonas commented Jun 28, 2017

Very nice.

@rolandwalker rolandwalker force-pushed the readline-persistent-history-file branch from b180466 to c29f5da Compare June 28, 2017 02:16
src/prompt.c Outdated
prompt_teardown(void)
{
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to mention that these can be removed. But I can do that after merge.

or $XDG_DATA_HOME/tig/history
@rolandwalker rolandwalker force-pushed the readline-persistent-history-file branch from c29f5da to 54ce4e4 Compare June 28, 2017 02:35
@jonas jonas merged commit 25b62a1 into jonas:master Jun 28, 2017
@rolandwalker rolandwalker deleted the readline-persistent-history-file branch June 28, 2017 02:52
@jonas jonas modified the milestone: tig-2.3 Jul 8, 2017
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.

2 participants