如何在Emacs 25中将C-x SPC本地绑定到gud模式

如何在Emacs 25中将C-x SPC本地绑定到gud模式,emacs,key-bindings,gud,Emacs,Key Bindings,Gud,类似于,但我希望将CTRL+x后跟空格绑定为gud break 我所做的工作(好吧,这是一个黑客;继续阅读)是: 但是ctl-x-map是一个类似于全局map的全局变量。事实上,如果切换到另一个C++缓冲区,并且C-H-C-C-X SPC类型得到: C-x SPC runs the command gud-break (found in global-map), which is an interactive compiled Lisp function. It is bound to C-x

类似于,但我希望将CTRL+x后跟空格绑定为
gud break

我所做的工作(好吧,这是一个黑客;继续阅读)是:

但是
ctl-x-map
是一个类似于全局map的全局变量。事实上,如果切换到另一个C++缓冲区,并且C-H-C-C-X SPC类型得到:

C-x SPC runs the command gud-break (found in global-map), which is an interactive compiled Lisp function.

It is bound to C-x SPC, C-x C-a C-b.

(gud-break ARG)

Set breakpoint at current line.
这意味着所有缓冲区的全局定义都已更改,这在AFAIK中是不正确的

有一种方法“插入”或某种程度地影响C-X的局部键映射,我相信这是“代码> GUD模式映射< /COD>”,因为我希望所有C++缓冲区的绑定不是全局的。例如,CTRL+x后跟空格的全局绑定是

矩形标记模式

是的,我知道标准绑定是
C-xc-acc-b
用于
gud break
,但这要求RSI

更新#1 由于我需要用于
gud模式映射的本地键映射
,因此仅当我运行调试器时,此键映射才需要处于活动状态。在我的例子中,这是在C++模式缓冲区中,但是我的理解是,代码> GUD模式映射< /COD>只在调试会话期间在那些C++模式缓冲器中激活,并且在GUD模式结束时从键绑定中移除。 更新#2 这不起作用:

(define-key gud-mode-map [(control x ?\ )] 'gud-break) ;; <-- gave "Two bases given in one event" error too.
(define-key gud-mode-map (kbd "C-x SPC") 'gud-break) ;; <-- this does not work either.

但是,当我切换到C++缓冲区时,也应该临时插入相同的绑定(而GUD模式是活动的),然后做同样的事情,我得到这个:

C-x SPC runs the command rectangle-mark-mode (found in global-map),
which is an interactive autoloaded compiled Lisp function in
'rect.el'.

It is bound to C-x SPC.

(rectangle-mark-mode &optional ARG)

Toggle the region as rectangular.
Activates the region if needed.  Only lasts until the region is deactivated.
切换回gud缓冲区,并键入
C-h m
显示:

Debugger mode defined in 'gud.el':
Major mode for interacting with an inferior debugger process.

   You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx,
M-x perldb, M-x xdb, or M-x jdb.  Each entry point finishes by executing a
hook; 'gdb-mode-hook', 'sdb-mode-hook', 'dbx-mode-hook',
'perldb-mode-hook', 'xdb-mode-hook', or 'jdb-mode-hook' respectively.

After startup, the following commands are available in both the GUD
interaction buffer and any source buffer GUD visits due to a breakpoint stop
or step operation:

C-x SPC sets a breakpoint at the current file and line.  In the
GUD buffer, the current file and line are those of the last breakpoint or
step.  In a source buffer, they are the buffer's file and current line.

...

注意上面提到的
C-x SPC
。这就好像他们打算绑定C-x SPC,但它不起作用,或者当进入gud模式时,有什么东西阻止它在缓冲区中正确绑定。

我不太清楚您想要什么。但是,如果您只想在
gud模式映射处于活动状态时重新定义键
C-x SPC
,请告诉
define key
您想使用该映射:
(define key-gud mode-map…
我选择完全放弃。在缓冲区中使用
C-x SPC
无论如何都是有问题的。我注意到,即使在GUD完成之后,在GuD绑定中使用的 C-X-C-A//COD>前缀也被留在C++缓冲区中,因此GUD模式无论如何都不会自行清理。p> 你说你希望绑定是本地的,但你没有说本地什么。那么,您希望
C-x SPC
在哪个缓冲区调用
gud break
?@Stefan我刚刚更新了问题的结尾以澄清。谢谢,您的思路是正确的,但这对我来说不起作用。有关我的尝试,请参见我描述中的更新#2。也许我的
(kbd…
需要调整?@bgoodr在完成
(定义键gud模式映射(kbd“C-x SPC”)“gud中断)
并处于
gud模式下时,
C-h C-x SPC RET
显示了什么?
C-h C-x SPC
不是我认为你的意思,因为这样做会导致
C-h C-x SPC
未定义。我怀疑您的意思是
C-hk C-x SPC
使用
C-hk
(对于
描述键
),然后键入
C-x SPC
。所以我这样做了,并得到了
C-xspc运行命令矩形标记模式
。我在GUD模式下从C++缓冲区中做了这件事,但是这很奇怪。
描述模式
是否应该显示gud模式以某种方式处于“活动”状态?在结果的帮助缓冲区中,我没有看到任何包含“gud”的引用。在主要描述中添加了更新#3,希望它能帮助解决这个难题。我仍然感到困惑。
C-x SPC runs the command rectangle-mark-mode (found in global-map),
which is an interactive autoloaded compiled Lisp function in
'rect.el'.

It is bound to C-x SPC.

(rectangle-mark-mode &optional ARG)

Toggle the region as rectangular.
Activates the region if needed.  Only lasts until the region is deactivated.
Debugger mode defined in 'gud.el':
Major mode for interacting with an inferior debugger process.

   You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx,
M-x perldb, M-x xdb, or M-x jdb.  Each entry point finishes by executing a
hook; 'gdb-mode-hook', 'sdb-mode-hook', 'dbx-mode-hook',
'perldb-mode-hook', 'xdb-mode-hook', or 'jdb-mode-hook' respectively.

After startup, the following commands are available in both the GUD
interaction buffer and any source buffer GUD visits due to a breakpoint stop
or step operation:

C-x SPC sets a breakpoint at the current file and line.  In the
GUD buffer, the current file and line are those of the last breakpoint or
step.  In a source buffer, they are the buffer's file and current line.

...