File: emacsclient-plus

package info (click to toggle)
emacs21 21.4a%2B1-5.6
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 59,052 kB
  • ctags: 58,903
  • sloc: lisp: 493,229; ansic: 237,171; xml: 4,262; sh: 4,108; makefile: 2,418; perl: 1,069; cs: 776; asm: 254; csh: 9; sed: 4
file content (31 lines) | stat: -rw-r--r-- 846 bytes parent folder | download | duplicates (10)
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
#!/usr/bin/perl

# If there is an Emacs server, runs emacsclient.
# Otherwise, launches Emacs.
# Only for systems with Berkeley sockets (like Debian GNU/Linux).

$real_emacsclient = "/usr/bin/emacsclient";
$socket_prefix = "esrv";
$id = `id --user`;
chomp $id;
$socket_dir = "/tmp/";
$hostname = `hostname`;
chomp $hostname;

if (-S "$socket_dir$socket_prefix$id-$hostname") {
    exec ("$real_emacsclient " . join (" ", @ARGV));            
    die "Cannot run $real_emacsclient: $!";
}
else {
    if ($ENV{'DISPLAY'}) {
        system "emacs &";
        # Wait the server (Emacs is slow)
        sleep 2;
        exec ("$real_emacsclient " . join (" ", @ARGV));                
        die "Cannot run $real_emacsclient: $!";
    }
    else {
        exec ("emacs " . join (" ", @ARGV));            
        die "Cannot run emacs: $!";
    }
}