如何绑定<打印屏幕>到 emacs 中的宏?

发布于 2024-09-07 02:57:58 字数 507 浏览 1 评论 0原文

我希望能够在 emacs 中点击 并触发 git 存储库中的提交。我的 lisp 很生锈,知道它坏了,但不知道在哪里:

( 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 )

目前它绑定到 ^1 因为我不知道如何表示 按钮。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你是年少的欢喜 2024-09-14 02:57:58

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

  • 点击 Mx global-set-key RET; RET <函数名称>

然后,点击Cx ESC ESC(即repeat-complex-command)。在迷你缓冲区中,您应该看到一个全局设置键函数调用,您可以将其复制到 .emacs 文件中。

A general trick that works for binding keystrokes you don't know the Emacs names for:

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

Then, hit C-x ESC ESC (which is repeat-complex-command). In the minibufer, you should see a global-set-key function invocation that you can copy into your .emacs file.

无远思近则忧 2024-09-14 02:57:58

您可以使用以下命令获取打印屏幕密钥

(kbd "<print>")

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

(vc-git-checkin "." nil "checkpoint")

You can get the print-screen key with

(kbd "<print>")

As for the actual committing, it's probably much easier to use the version control functions emacs provides:

(vc-git-checkin "." nil "checkpoint")
夜雨飘雪 2024-09-14 02:57:58

您需要先运行此命令:

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

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

(global-set-key [snapshot] 'tip-local-write ) 

You need to run this first:

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

After which, you can do this:

(global-set-key [snapshot] 'tip-local-write ) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文