Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ikiwiki plugin: Make location of emacs configurable.

  • Loading branch information...
commit 031b897078d354f1c0a7cafdcd5dea478c5000c6 1 parent daa9515
@mwolson mwolson authored
Showing with 27 additions and 5 deletions.
  1. +27 −5 contrib/ikiwiki/IkiWiki/Plugin/muse.pm
View
32 contrib/ikiwiki/IkiWiki/Plugin/muse.pm
@@ -31,6 +31,13 @@ sub getsetup () {
safe => 1,
rebuild => 1, # format plugin
},
+ muse_emacs => {
+ type => "string",
+ example => "/usr/bin/emacs",
+ description => "the location of Emacs",
+ safe => 1,
+ rebuild => 1,
+ },
muse_init => {
type => "string",
example => "~/ikiwiki/muse-init.el",
@@ -95,6 +102,22 @@ sub scan (@) {
}
}
+# Determine the emacs binary to use
+sub locate_emacs {
+ my $err = sub {
+ die "Unable to find your emacs binary.\n",
+ " Set muse_emacs config to the right value.\n";
+ };
+ if ( $config{muse_emacs} ) {
+ ( -x $config{muse_emacs} ) ? return $config{muse_emacs} : $err->();
+ }
+ else {
+ my $emacs = `which emacs`;
+ chomp $emacs;
+ ( $emacs ) ? return $emacs : $err->();
+ }
+}
+
# Pass the content of the page to Muse for publishing
sub filter (@) {
my %params=@_;
@@ -118,13 +141,12 @@ sub filter (@) {
my $qfile = $filename;
$qfile =~ s/"/\\"/g;
eval {
- system qw( emacs -q --no-site-file -batch -l ),
- $config{muse_init}, '--eval',
- qq{(muse-ikiwiki-publish-file "$qfile" "$qname")};
+ system locate_emacs(),
+ qw( -q --no-site-file -batch -l ), $config{muse_init},
+ '--eval', qq{(muse-ikiwiki-publish-file "$qfile" "$qname")};
{
open my $ifh, '<', $filename;
- local $/;
- $content = <$ifh>;
+ local $/; $content = <$ifh>;
close $ifh;
}
unlink $filename;
Please sign in to comment.
Something went wrong with that request. Please try again.