Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Start Emacs.app from CLI

View Emacs_starter.pl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/usr/bin/perl
 
# Emacs starter for Emacs mac port
 
# Thanks to Aquamacs Project and David Reitter
 
my $args = "";
my $tmpfiles = "";
 
for my $f (@ARGV) {
$args .= '"'.$f.'" ';
$tmpfiles .= '"'.$f.'" ' if (! -e $f);
}
 
system("touch $args") if ($tmpfiles);
system("open -a /Applications/Emacs.app $args");
 
# delay deletion because AE drag&drop doesn't work with non-existing documents
system("(sleep 3; rm $tmpfiles) &") if ($tmpfiles);
exit;
 
ptb commented

I rewrote this as a shell script and added the capability to accommodate filenames with spaces:

#!/bin/sh

t=()

while IFS= read -r file; do
  [ ! -f "$file" ] && t+=("$file") && /usr/bin/touch "$file"
done <<<"$(printf '%s\n' "$@")"

$(/usr/bin/open -a /Applications/Emacs.app "$@") &

if [ ! -z "$t" ]; then
  $(/bin/sleep 10; for file in "${t[@]}"; do /bin/rm "$file"; done) &
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.