-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaquamacs
More file actions
executable file
·45 lines (32 loc) · 1.1 KB
/
aquamacs
File metadata and controls
executable file
·45 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl
# Aquamacs Emacs starter
# (C) 2007 Aquamacs Project
# Revisions
# 1.0 - first version to be included with Aquamacs [2007-03-17 David Reitter]
# 1.1 - delayed deletion of new files [2008-11-12 David Reitter]
$app_name='Aquamacs';
$app_path = "/Applications/$app_name.app";
#$app_path = '<AQUAMACS-PATH>';
# $pid = qx"ps auxc | awk '/^$ENV{'USER'} .* Aquamacs Emacs\$/ {print \$2}'";
my $args = "";
my $tmpfiles = "";
for my $f (@ARGV) {
$args .= '"'.$f.'" ';
$tmpfiles .= '"'.$f.'" ' if (! -e $f);
}
system("touch $args") if ($tmpfiles);
# there is still an issue:
# if the sudo emacs is still open, it will
# call 'open' and open the files in the wrong
# emacs process.
if ($ENV{'USER'} ne "root") # hack: not sudo
{
# we can only call "open" with existing files.
# that's why we create them just for the "open" call.
system("open -a $app_path $args");
} else {
system("'$app_path/Contents/MacOS/$app_name' $args 2>/dev/null &");
}
# delay deletion because Emacs can't open non-existing documents
system("(sleep 5; rm $tmpfiles) &") if ($tmpfiles);
exit;