我想设置一个按键绑定,以将日期插入缓冲区。在我的.emacs
文件中编写了以下Lisp代码,以date
为例:
;;put the date
(global-set-key
(kbd "C-c C-d")
(shell-command "date" (current-buffer))
)
当我使用其他命令(例如'next-line
)时,键绑定运行良好,但是在读取.emacs文件时,shell-command
会将其放入*scratch*
缓冲区,并保持在那里。
也许我需要使用shell-command-on-region
。
(current-buffer)
在你的.emacs
运行时被评估。你想使用(shell-command "date" t)
将其插入到调用命令时的当前缓冲区中,或者将其封装在defun
中,以便在执行函数时进行评估。 - tripleee