Module: CmdTools::Commands::EmacsLaunch
- Extended by:
- RubyPatch::AutoLoad
- Defined in:
- lib/cmd_tools/commands/emacs_launch.rb
Class Method Summary collapse
-
.run(mode, *files) ⇒ Object
Open
filesbymode(:gui/:cui) mode. -
.stop ⇒ Object
Stop emacs daemon.
Class Method Details
.run(mode, *files) ⇒ Object
Open files by mode (:gui/:cui) mode. Launch emacs daemon if necessary. Create new frame if necessary. You can edit ~/.config/cmd_tools/config.yaml to specify an emacs executable. For example, if you are a Mac user who uses MacPorts, following modification will be useful.
- :emacs: emacs
+ :emacs: /Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cmd_tools/commands/emacs_launch.rb', line 12 def self.run(mode, *files) Process.waitpid(spawn "#{::CmdTools::Config.emacs} --daemon") unless daemon_running? files_str = files.flatten.join(' ') case mode when :gui if is_gui_running? emacsclient_open(files_str) else spawn "emacsclient -c -n #{files_str}" end when :cui Process.waitpid(emacsclient_open(files_str)) # To retain a file even if a terminal, which the file was opened, have closed. exec "emacsclient -t #{files_str}" else raise ArgumentError, "Expected :gui or :cui, but got #{mode}." end end |
.stop ⇒ Object
Stop emacs daemon.
32 33 34 |
# File 'lib/cmd_tools/commands/emacs_launch.rb', line 32 def self.stop exec "emacsclient -e '(kill-emacs)'" if daemon_running? end |