【发布时间】:2011-01-15 00:31:36
【问题描述】:
我想在 emacs 中设置一个键来对缓冲区中的文件执行 shell 命令,并在不提示的情况下恢复缓冲区。 shell命令为:p4 edit 'currentfilename.ext'
(global-set-key [\C-E] (funcall 'revert-buffer 1 1 1))
;; my attempt above to call revert-buffer with a non-nil
;; argument (ignoring the shell command for now) -- get an init error:
;; Error in init file: error: "Buffer does not seem to be associated with any file"
对 elisp 来说是全新的。来自emacs manual,这里是revert-buffer的定义:
Command: revert-buffer &optional ignore-auto noconfirm preserve-modes
谢谢!
【问题讨论】:
-
你想恢复缓冲区是因为它已经被编辑过,还是因为 shell 命令破坏了缓冲区的内容?
-
因为它将缓冲区更改为写入而不是只读,并将其添加到版本控制中。