cmd_tools 2.0.5 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,8 @@ module ::CmdTools::Command::EmacsLaunch
2
2
  require 'ruby_patch'
3
3
  extend ::RubyPatch::AutoLoad
4
4
 
5
+ EMACSCLIENT_OPEN = lambda{|files| spawn "emacsclient -n #{files}"}
6
+
5
7
  # Open +files+ by +mode+ (:gui/:cui) mode.
6
8
  # Launch emacs daemon if necessary.
7
9
  # Create new frame if necessary.
@@ -10,17 +12,18 @@ module ::CmdTools::Command::EmacsLaunch
10
12
  # - :emacs: emacs
11
13
  # + :emacs: /Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs
12
14
  def self.run(mode, *files)
13
- system "#{::CmdTools::Config.emacs} --daemon" unless daemon_running?
15
+ Process.waitpid(spawn "#{::CmdTools::Config.emacs} --daemon") unless daemon_running?
14
16
 
15
17
  files = files.flatten.join(' ')
16
18
  case mode
17
19
  when :gui
18
20
  if number_of_frames() <= 1 # emacs daemon has one (invisible) frame.
19
- exec "emacsclient -c -n #{files}"
21
+ spawn "emacsclient -c -n #{files}"
20
22
  else
21
- exec "emacsclient -n #{files}"
23
+ EMACSCLIENT_OPEN[files]
22
24
  end
23
25
  when :cui
26
+ Process.waitpid(EMACSCLIENT_OPEN[files])
24
27
  exec "emacsclient -t #{files}"
25
28
  else
26
29
  raise ArgumentError, "Expected :gui or :cui, but got #{mode}."
@@ -29,13 +32,13 @@ module ::CmdTools::Command::EmacsLaunch
29
32
 
30
33
  # Stop emacs daemon.
31
34
  def self.stop
32
- exec "emacsclient -e '(kill-emacs)'"
35
+ exec "emacsclient -e '(kill-emacs)'" if daemon_running?
33
36
  end
34
37
 
35
38
  private
36
39
 
37
40
  def self.daemon_running?
38
- system "emacsclient -e '()' > /dev/null 2>&1"
41
+ system "emacsclient -e '()' > #{File::NULL} 2>&1"
39
42
  end
40
43
 
41
44
  def self.number_of_frames
@@ -17,9 +17,9 @@ module ::CmdTools::Config
17
17
  else
18
18
  FileUtils.mkdir_p(CONFIG_DIR)
19
19
  open(CONFIG_FILE, 'w'){|io|
20
- io.write(CONFIG_DEFAULT.to_yaml)
21
- io.flush
22
- }
20
+ io.write(CONFIG_DEFAULT.to_yaml)
21
+ io.flush
22
+ }
23
23
  CONFIG_DEFAULT
24
24
  end
25
25
 
@@ -1,3 +1,3 @@
1
1
  module CmdTools
2
- VERSION = '2.0.5'
2
+ VERSION = '2.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmd_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-12 00:00:00.000000000 Z
12
+ date: 2012-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_patch
16
- requirement: &2156566300 !ruby/object:Gem::Requirement
16
+ requirement: &73308010 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0.3'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2156566300
24
+ version_requirements: *73308010
25
25
  description: ! 'Command line tools. Please type
26
26
 
27
27
 
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 1.8.15
86
+ rubygems_version: 1.8.11
87
87
  signing_key:
88
88
  specification_version: 3
89
89
  summary: Command line tools.