如何在Emacs 25

时间:2018-06-13 17:19:11

标签: emacs key-bindings gud

How to change GUD breakpoint keybinding to the old one类似,但我想将 CTRL + x ,然后 SPACE 绑定为gud-break

我的工作(好吧是黑客;继续阅读)是:

  (define-key ctl-x-map " " 'gud-break)

但是ctl-x-map是一个类似于全局地图的全局变量。事实上,如果我切换到另一个C ++缓冲区并键入C-h k 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-mode-map,因为我希望该绑定对于所有C ++缓冲区都不是全局的。例如, CTRL + x 的全局绑定,后跟 SPACE rectangle-mark-mode

是的,我发现C-x C-a C-b的标准绑定是gud-break,但这就是要求RSI。

更新#1

由于我需要gud-mode-map的本地密钥映射,因此只有在我运行调试器时才需要激活它。在我的例子中,这是在C ++模式缓冲区中,但我的理解是gud-mode-map仅在调试会话期间在那些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.

更新#3

作为一个实验,我在我的钩子中注释了我的define-key绑定,我添加到gud-gdb-mode-hook,重新gdb,然后切换到gud缓冲区(不是C ++源文件)并键入{{1我明白了:

C-h k C-x SPC

但是当我切换到C ++缓冲区时,应该暂时插入相同的绑定(当gud模式处于活动状态时),然后做同样的事情我得到了这个:

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

It is bound to <menu-bar> <debug> <break>, C-x SPC, C-c C-b, C-x C-a
C-b.

(gud-break ARG)

Set breakpoint at current line.

切换回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. 显示:

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但是它不起作用,或者在输入gud模式时阻止它在该缓冲区中正确绑定。

2 个答案:

答案 0 :(得分:0)

但是,如果您只想在C-x SPC处于有效状态时重新定义键gud-mode-map,请告诉define-key您要使用该地图:(define-key gud-mode-map ...)

答案 1 :(得分:0)

我选择完全放弃这一点。无论如何,在缓冲区中使用C-x SPC是有问题的。我注意到,即使在gud完成之后,用于gud绑定的C-x C-a前缀仍留在C ++缓冲区中,因此gud模式无论如何都不会自行清除。