Syntax-Highlight-WithEmacs
view release on metacpan or search on metacpan
lib/Syntax/Highlight/WithEmacs.pm view on Meta::CPAN
'ansify_css', 'ansify_ccss', 'ansify_opts', '_ansify_italic'
);
$self->start_server if $self->_start_server && $self->use_client;
}
method start_server {
return if $self->{made_server};
my ($cout, $cin, $cerr);
my @cmd = ($self->emacs_cmd, @{$self->emacs_args},
'--daemon' . ($self->server_name ? '='.$self->server_name : ''));
local $ENV{HOME} = (getpwuid $<)[7] unless $ENV{HOME};
local $ENV{TERM} = $self->term_spec;
run \@cmd, \$cin, \$cout, \$cerr;
$self->{made_server} = 1;
}
method _client_cmd_args {
($self->client_cmd, -a => '', ($self->server_name ? (-s => $self->server_name) : ()))
}
method run_htmlize($in, $out) {
lib/Syntax/Highlight/WithEmacs.pm view on Meta::CPAN
$_ = qq{"$_"};
}
my $kill_command = $self->use_client ? '(delete-frame (selected-frame) t)' : '(kill-emacs)';
my @cmd = $self->use_client ? $self->_client_cmd_args : $self->emacs_cmd;
my @cmd_args = @{$self->emacs_args};
@cmd_args = grep { !/^-q$/i } @cmd_args if $self->use_client;
my $hyper = $self->htmlize_generate_hyperlinks ? 't' : 'nil';
my @args = (@cmd, '-nw', @cmd_args,
-eval => qq((ignore-errors (require 'htmlize) (setq htmlize-generate-hyperlinks $hyper) (setq htmlize-output-type "$mode") (htmlize-file $in $out))),
-eval => $kill_command);
local $ENV{HOME} = (getpwuid $<)[7] unless $ENV{HOME};
local $ENV{TERM} = $self->term_spec;
my ($tin, $tout, $err);
run \@args, '<pty<', \$tin, '>pty>', \$tout, '2>', \$err;
$self->{made_server} = $self->use_client;
}
=head2 htmlize_file
run htmlize on a given filename. The major-mode emacs uses to highlight
it will be chosen by your own emacs configuration file, which is
lib/Syntax/Highlight/WithEmacs.pm view on Meta::CPAN
=head2 kill_server
manually send the kill command to the emacs server.
=cut
method kill_server {
my @cmd = ($self->_client_cmd_args,
-eval => '(kill-emacs)');
my ($cout, $cin, $cerr);
local $ENV{HOME} = (getpwuid $<)[7] unless $ENV{HOME};
local $ENV{TERM} = $self->term_spec;
run \@cmd, \$cin, \$cout, \$cerr;
$self->{made_server} = 0;
}
method DEMOLISH {
$self->kill_server if $self->_kill_server && $self->{made_server}
}
};
( run in 0.324 second using v1.01-cache-2.11-cpan-8d75d55dd25 )