我正在做 Rails 开发,发现我需要生成一个shell,重命名缓冲区(例如 webrick),然后启动命令(rails s),如果每次启动 emacs 时我想要一个 Rails 控制台或 Rails dbconsole、rspec、spork 等,则重新执行整个操作。
我希望有这样的事情:
(defun spawn-shell ()
"Invoke shell test"
(with-temp-buffer
(shell (current-buffer))
(process-send-string nil "echo 'test1'")
(process-send-string nil "echo 'test2'")))
我不希望 shell 在退出时消失,因为 shell 缓冲区中的输出很重要,有时我需要杀死它并重新启动它,但我不想丢失该历史记录。
本质上,我想采用手动过程并使其可调用。
任何帮助深表感谢
Tom
也许这个版本spawn-shell
会做你想做的事:
(defun spawn-shell (name)
"Invoke shell test"
(interactive "MName of shell buffer to create: ")
(pop-to-buffer (get-buffer-create (generate-new-buffer-name name)))
(shell (current-buffer))
(process-send-string nil "echo 'test1'\n")
(process-send-string nil "echo 'test2'\n"))
It prompts for a name to use when you run it interactively (M-x spawn-shell). It creates a new buffer based on the input name using generate-new-buffer-name http://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer-Names.html, and you were missing the newlines on the end of the strings you were sending to the process.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)