diff -r 24fc5a406138 -r c576e88fef13 genorg.pl --- a/genorg.pl Sun Dec 15 22:45:46 2024 +1000 +++ b/genorg.pl Sun Dec 15 23:46:24 2024 +1000 @@ -63,21 +63,21 @@ END my $req_config = <<"END"; -(with-eval-after-load 'org - (org-link-set-parameters "genorg" +(require 'org) +(require 'ob) +(org-link-set-parameters "genorg" :follow nil :export #'(lambda (link desc _ _) - (format "" desc link)) - :store nil)) + (format "%s" desc link)) + :store nil) END -my $custom_code = "(require 'ob-dot) (setq org-confirm-babel-evaluate nil)"; +my $custom_code = "(list 1)"; my $elisp_code = <<"END" =~ s/\n\s+//gr; (let ((ls '(LIST))) (require 'org) - $custom_code (mapc (lambda (b) (with-current-buffer b @@ -85,7 +85,8 @@ (eq major-mode 'org-mode)) (org-export-to-file 'html (pop ls))))) (buffer-list)) - (kill-emacs)) + (kill-emacs) +) END @@ -168,10 +169,16 @@ no_name_dir => \$no_name_dir ); + sub read_config ($path) { open my $fh, '<', $path or die "Couldn't open config file\n"; while (<$fh>) { next if /^\s+$/; + if (/^>>---+/) { + local $/; + $custom_code = <$fh>; + return; + } chomp; my ($directive, $rest) = split /\s+/, $_, 2; if (exists($config_vars{$directive})) { @@ -245,7 +252,7 @@ } %changed_files // exit; $elisp_code =~ s/LIST/join '', map "\"$_\" ", values %changed_files /e; - open my $fh, '-|', ($emacs, '--batch', '~/.emacs.d/init.el', keys %changed_files, "--eval" , "$elisp_code"); + open my $fh, '-|', ($emacs, '-Q','--eval', "(progn $custom_code)", keys %changed_files, "--eval" , "$elisp_code"); close $fh; \%changed_files } @@ -254,6 +261,7 @@ $ARGV[0] // die "No arguments provided\n"; while ($_ = shift @ARGV) { + /^-c$/ && do { print "$req_config\n"; exit }; /^(-h|--?help)$/ && help_and_bye; /^-t$/ && do { template shift @ARGV ; exit }; /^-c$/ && do { $config_file = shift @ARGV; next }; @@ -588,3 +596,4 @@ } } +