changeset 6:5370428e673e

experimenting with a perlscript for weaving
author Robert McIntyre <rlm@mit.edu>
date Mon, 24 Oct 2011 09:29:17 -0700
parents 4824087ce1f2
children ce96610fe058
files auto-weave.pl old-weave.sh weave.sh
diffstat 3 files changed, 92 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/auto-weave.pl	Mon Oct 24 09:29:17 2011 -0700
     1.3 @@ -0,0 +1,43 @@
     1.4 +#!/usr/bin/perl
     1.5 +
     1.6 +use Linux::Inotify2;
     1.7 +use AnyEvent;
     1.8 +
     1.9 +
    1.10 +my $inotify = new Linux::Inotify2
    1.11 +  or die "unable to create new inotify object: $!";
    1.12 +
    1.13 +
    1.14 +@org_files =  glob("./org/*.org");
    1.15 +
    1.16 +$" = "\n";
    1.17 +print "@org_files";
    1.18 +
    1.19 +
    1.20 +foreach(@org_files){
    1.21 +# add watchers
    1.22 +$inotify->watch ($_, IN_MODIFY, sub 
    1.23 +{
    1.24 +  my $e = shift;
    1.25 +  my $name = $e->fullname;
    1.26 +  print "$name was modified\n" if $e->IN_MODIFY;
    1.27 +  `
    1.28 +
    1.29 +});
    1.30 +
    1.31 +
    1.32 +
    1.33 +
    1.34 +}
    1.35 +
    1.36 +
    1.37 +
    1.38 +
    1.39 +# integration into AnyEvent (works with EV, Glib, Tk, POE...)
    1.40 +my $inotify_w = AnyEvent->io 
    1.41 +  (
    1.42 +   fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll }
    1.43 +  );
    1.44 +
    1.45 + # manual event loop
    1.46 +1 while $inotify->poll;
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/old-weave.sh	Mon Oct 24 09:29:17 2011 -0700
     2.3 @@ -0,0 +1,34 @@
     2.4 +#!/bin/sh
     2.5 +
     2.6 +# assumes ./org directory with org files to publish to 
     2.7 +# ./html
     2.8 +
     2.9 +#target=$(readlink -f $1)
    2.10 +
    2.11 +dir=`pwd`
    2.12 +
    2.13 +emacs  \
    2.14 +-l /home/r/config/emacs/clojure-init.el \
    2.15 +-l /home/r/config/emacs/org-init.el \
    2.16 +-l /home/r/config/emacs/web-color.el \
    2.17 +--batch \
    2.18 +--eval "
    2.19 +(progn
    2.20 +(setq org-publish-project-alist
    2.21 +      '(
    2.22 +	(\"project\"
    2.23 +	 :base-directory \"$dir/org\"
    2.24 +	 :base-extension \"org\"
    2.25 +	 :publishing-directory \"$dir/html\"
    2.26 +	 :recursive t
    2.27 +	 :publishing-function org-publish-org-to-html
    2.28 +	 :auto-preamble t)
    2.29 +	))
    2.30 +
    2.31 +(org-publish-project \"project\"))" \
    2.32 +\
    2.33 +2>&1 #| pcregrep 'Wrote'
    2.34 +
    2.35 +
    2.36 +
    2.37 +
     3.1 --- a/weave.sh	Mon Oct 24 08:31:37 2011 -0700
     3.2 +++ b/weave.sh	Mon Oct 24 09:29:17 2011 -0700
     3.3 @@ -3,34 +3,11 @@
     3.4  # assumes ./org directory with org files to publish to 
     3.5  # ./html
     3.6  
     3.7 -#target=$(readlink -f $1)
     3.8 +target=$(readlink -f $1)
     3.9  
    3.10  dir=`pwd`
    3.11  
    3.12 -# emacs  \
    3.13 -# -l /home/r/config/emacs/clojure-init.el \
    3.14 -# -l /home/r/config/emacs/org-init.el \
    3.15 -# -l /home/r/config/emacs/web-color.el \
    3.16 -# --batch \
    3.17 -# --eval "
    3.18 -# (progn
    3.19 -# (setq org-publish-project-alist
    3.20 -#       '(
    3.21 -# 	(\"project\"
    3.22 -# 	 :base-directory \"$dir/org\"
    3.23 -# 	 :base-extension \"org\"
    3.24 -# 	 :publishing-directory \"$dir/html\"
    3.25 -# 	 :recursive t
    3.26 -# 	 :publishing-function org-publish-org-to-html
    3.27 -# 	 :auto-preamble t)
    3.28 -# 	))
    3.29 -
    3.30 -# (org-publish-project \"project\"))" \
    3.31 -# \
    3.32 -# 2>&1 #| pcregrep 'Wrote'
    3.33 -
    3.34 -
    3.35 -emacsclient  \
    3.36 +emacsclient \
    3.37  --eval "
    3.38  (progn
    3.39  (setq org-publish-project-alist
    3.40 @@ -44,8 +21,20 @@
    3.41  	 :auto-preamble t)
    3.42  	))
    3.43  
    3.44 -(org-publish-project \"project\"))" \
    3.45 +(org-publish-file \"$target\" '(\"project\"
    3.46 +	 :base-directory \"$dir/org\"
    3.47 +	 :base-extension \"org\"
    3.48 +	 :publishing-directory \"$dir/html\"
    3.49 +	 :recursive t
    3.50 +	 :publishing-function org-publish-org-to-html
    3.51 +	 :auto-preamble t)
    3.52 +	))" \
    3.53 +\
    3.54 +2>&1 #| pcregrep 'Wrote'
    3.55  
    3.56  
    3.57  
    3.58  
    3.59 +
    3.60 +
    3.61 +