Module: CmdTools::Command::EmacsLaunch
- Extended by:
- RubyPatch::AutoLoad
- Defined in:
- lib/cmd_tools/command/emacs_launch.rb
Class Method Summary collapse
-
.run(mode, *files) ⇒ Object
This method is created to provide ‘open -a Emacs.app’ command of Mac to Linux.
-
.stop ⇒ Object
Stop emacs daemon.
Class Method Details
.run(mode, *files) ⇒ Object
This method is created to provide ‘open -a Emacs.app’ command of Mac to Linux. Unfortunately, This method is not work satisfactory on Mac (but you have ‘open -a Emacs.app’). This method will
-
open
files
bymode
(:gui/:cui) mode -
launch emacs daemon if necessary
-
create new frame if necessary
You can edit ~/.config/cmd_tools/config.yaml to specify a path to an emacs executable.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cmd_tools/command/emacs_launch.rb', line 14 def self.run(mode, *files) Process.waitpid(spawn "#{::CmdTools::Config.emacs} --daemon") unless daemon_running? files_str = files.flatten.shelljoin case mode when :gui if 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.
34 35 36 |
# File 'lib/cmd_tools/command/emacs_launch.rb', line 34 def self.stop exec "emacsclient -e '(kill-emacs)'" if daemon_running? end |