2

I would like to be able to hit <Print Screen> in emacs and trigger a commit in a git repository. My lisp is pretty rusty and know this is broken, but don't know where:

( defun tip-local-write nil "Write to store" ( interactive )
     ( save-buffer )
     ( change-directory "~/tip" )
     ( shell-command "git commit -m checkpoint ." )
     ( shell-command "git submodule foreach git commit -m checkpoint . \\\|\\\| true" ) ) )
( global-set-key [?\M-1] 'tip-local-write )

Currently it is binding to ^1 because I don't know how to represent the <Print Screen> button.

4

3 回答 3

2

适用于绑定您不知道 Emacs 名称的击键的一般技巧:

  • M-x global-set-key RET <your keystroke> RET <name of function>

然后,点击C-x ESC ESC(即repeat-complex-command)。在 minibufer 中,您应该会看到一个 global-set-key 函数调用,您可以将其复制到 .emacs 文件中。

于 2010-06-23T17:11:22.923 回答
2

您可以使用

(kbd "<print>")

至于实际提交,使用 emacs 提供的版本控制功能可能要容易得多:

(vc-git-checkin "." nil "checkpoint")
于 2010-06-23T17:11:43.810 回答
0

你需要先运行这个:

(w32-register-hot-key [snapshot])

之后,您可以执行以下操作:

(global-set-key [snapshot] 'tip-local-write ) 
于 2010-06-23T17:08:27.893 回答