From 031b897078d354f1c0a7cafdcd5dea478c5000c6 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sun, 4 Jan 2009 17:11:00 -0800 Subject: [PATCH] Ikiwiki plugin: Make location of emacs configurable. --- contrib/ikiwiki/IkiWiki/Plugin/muse.pm | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/contrib/ikiwiki/IkiWiki/Plugin/muse.pm b/contrib/ikiwiki/IkiWiki/Plugin/muse.pm index 4567377..1d5257f 100644 --- a/contrib/ikiwiki/IkiWiki/Plugin/muse.pm +++ b/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; -- 2.11.4.GIT