use warnings; use strict; =head1 NAME BarnOwl::Module::RunCurrentLine =head1 DESCRIPTION In the middle of editing text, cut the current line and run it as a BarnOwl command =cut package BarnOwl::Module::RunCurrentLine; use POSIX; use BarnOwl::Editwin qw(move_to_line_start move_to_line_end replace_region delete_prev_char set_mark get_region); our $VERSION = 0.1; sub run_current_line { move_to_line_start(); set_mark(); move_to_line_end(); my $text = get_region(); replace_region(''); delete_prev_char(); BarnOwl::command($text); } BarnOwl::new_command('run-current-line' => \&run_current_line, { summary => "In the middle of editing text, cut the current line and run it as a BarnOwl command", usage => "run-current-line", description => "In the middle of editing text, cut the current line and run it as a BarnOwl command Currently doesn't quite successfully cut the current line if it's the first line of the window WARNING: If you try to run something that eventually starts a different text editing or command window, like zwrite, BarnOwl will probably segfault! It might segfault even if you don't do that!", }); 1;