Class: Editserver::Emacs

Inherits:
Editor
  • Object
show all
Defined in:
lib/editserver/terminal/emacs.rb

Instance Method Summary collapse

Methods inherited from Editor

define_editor, terminal, #terminal, terminal=

Instance Method Details

#edit(file) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/editserver/terminal/emacs.rb', line 13

def edit file
  if terminal.nil?
    File.open(file, 'w') { |f| f.write 'No terminal defined!' }
  else
    super
  end
rescue EditError
  start_server
  super
end

#start_serverObject



7
8
9
10
11
# File 'lib/editserver/terminal/emacs.rb', line 7

def start_server
  pid = fork { exec *(terminal + %w[-e emacs --eval (server-start)]) }
  sleep 2 # HACK!
  Process.detach pid
end