Skip to content

@railwaycat /Emacs_starter.pl
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Start Emacs.app from CLI
#!/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

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
@railwaycat
Owner

Thanks @ptb :)

@lmartins

Sorry to ask guys, how can I install this?

@InAbsentia

@lmartins Paste into a file named emacs (or whatever you want the command to be) in a directory in your path (ahead of the location of the existing emacs command). Then chmod +x /path/to/emacs.

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.