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

allow access to global command history when using a specifc history #762

Merged
merged 4 commits into from Nov 25, 2017

Conversation

Projects
None yet
2 participants
@ailin-nemui
Contributor

ailin-nemui commented Oct 5, 2017

also add history loading method

@ailin-nemui

This comment has been minimized.

Contributor

ailin-nemui commented Oct 5, 2017

usage: ctrl+up/down

this can come in handy if you use /window history named or /set window_history on, but want to recall something from one of the other windows' histories

@ailin-nemui

This comment has been minimized.

Contributor

ailin-nemui commented Oct 5, 2017

sample script for your autorun:

use strict;
use warnings;
use YAML::Tiny;

my $histfile = Irssi::get_irssi_dir()."/history";

my ($hist) = eval { YAML::Tiny::LoadFile($histfile) };
if ($hist) {
    Irssi::UI::Window::load_history_entries(undef, @$hist);
}

Irssi::signal_add 'gui exit' => sub {
    if (Irssi::settings_get_bool('settings_autosave')) {
	YAML::Tiny::DumpFile($histfile, [ Irssi::UI::Window::get_history_entries(undef) ] )
    }
}
#define history_list_last command_history_list_last
#define history_list_first command_history_list_first
#define history_list_prev command_history_list_prev
#define history_list_next command_history_list_next

This comment has been minimized.

@dequis

dequis Oct 6, 2017

Member

Huh. Why?

This comment has been minimized.

@ailin-nemui

ailin-nemui Oct 6, 2017

Contributor

fixed

@dequis

This comment has been minimized.

Member

dequis commented Oct 6, 2017

Good stuff.

The commit log / PR title could use some more love. I mean, global window history is the default behavior, but being able to use global history while window history is enabled is a very good feature.

Not sure I fully understand what g_history is supposed to hold.

Leaving the job of persisting history to a perl script is a weird choice (not wrong, but not one i'd choose) but I guess you like perl, and more APIs don't hurt. It's a good example of adding more perl stuff, I guess.

@ailin-nemui ailin-nemui changed the title from add global window history to irssi to allow access to global command history when using a specifc history Oct 6, 2017

ailin-nemui added some commits Oct 6, 2017

refactor history to use history_entries list
this allows access to the global history even when a using /window history
named or /set window_history on, and you want to recall something from one
of the other windows' histories.

usage (default): ctrl+up/down
add two XSFuncs to manipulate command history entries
it is possible to use Irssi::UI::Window::get_history_entries to save the
history entries, load_history_entries to load entries into the command
history and delete_history_entries to remove history entries (for example
to remove history selectively)
add a key binding to erase history entries
it is possible to delete the current history entry using the
erase_history_entry key binding
@ailin-nemui

This comment has been minimized.

Contributor

ailin-nemui commented Oct 6, 2017

I renamed g_history to history_entries

@ailin-nemui ailin-nemui merged commit 3792bc9 into irssi:master Nov 25, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@ailin-nemui ailin-nemui deleted the ailin-nemui:global-history branch Nov 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment