Audio-Nama

 view release on metacpan or  search on metacpan

lib/Audio/Nama/Custom.pm  view on Meta::CPAN

# ---------------- User Customization ---------------

package Audio::Nama;
use Modern::Perl '2020';

sub setup_user_customization {
	my $filename = $file->user_customization();

	# effect aliases from .namarc
	for( keys %{$config->{alias}->{effect}} )
	{ my $longform = $config->{alias}->{effect}->{$_};
		 if(effect_index($longform))
			{
				$fx_cache->{partial_label_to_full}->{$_} =
				$fx_cache->{partial_label_to_full}->{$longform}
			}
		 else 
			{ throw("$longform: effect not found, cannot create shortcut") 
			}
 	} 
	return unless -r $filename;
	say("reading user customization file $filename");
	my %custom;
	unless (%custom = do $filename) {
		throw("couldn't parse $filename: $@\n") if $@;
		return;
	}
	logpkg(__FILE__,__LINE__,'debug','customization :', sub{Dumper \%custom });
	my $prompt;
	{ no warnings 'redefine';
		*prompt = $custom{prompt} if $custom{prompt};
	}
	my @commands = keys %{ $custom{commands} };
	for my $cmd(@commands){
		#my $coderef = gen_coderef($cmd,$custom{commands}{$cmd}) or next;
		$text->{user_command}->{$cmd} = $custom{commands}{$cmd};
	}
	$config->{alias}   = $custom{aliases};
}

sub gen_coderef {
	my ($cmd,$code) = @_;
	my $coderef = eval "sub{ use feature ':5.10'; no warnings 'uninitialized'; $code }";
	throw("couldn't parse command $cmd: $@"), return if $@;
	$coderef
}
1;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.404 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )