Personal tree-keybindings - ECB - the Emacs Code Browser
Description: ECB - the Emacs Code Browser

Next: Using popup-menus, Previous: Incremental search, Up: Using the keyboard

#### 6.2.3 Adding personal keybindings for the tree-buffers

There are five hooks which can be used for adding personal keybindings to the ECB tree-buffers:

- `ecb-common-tree-buffer-after-create-hook`
- `ecb-directories-buffer-after-create-hook`
- `ecb-sources-buffer-after-create-hook`
- `ecb-methods-buffer-after-create-hook`
- `ecb-history-buffer-after-create-hook`

These hooks are called directly after tree-buffer creation so they can be used to add personal local keybindings1 either to all tree-buffers (`ecb-common-tree-buffer-after-create-hook`) or just to a certain tree-buffer. Here is a list which keys MUST NOT be rebound:

- `RET` and all combinations with `Shift` and `Ctrl`: Used for selecting nodes in all tree-buffers.
- `TAB`: Used for expanding/collapsing nodes in all tree-buffers.
- `C-t`: Used for toggling “do not leave window after selection” in all tree-buffers, see command `ecb-toggle-do-not-leave-window-after-select`.
- All self-inserting characters: Used for easy and fast navigation in all tree-buffers, See Incremental search.
- `F2`, `F3`, `F4`: Used for customizing ECB, adding source-path in the directories buffer.

The following example binds `C-a` to some useful code in ALL tree-buffers and `C-d` to even more useful code ONLY in the directories buffer:

       (add-hook 'ecb-common-tree-buffer-after-create-hook
                 (lambda ()
                    (local-set-key (kbd "C-a")
                                   (lambda ()
                                      (interactive)
                                      (message "ECB is great!")))))

       (add-hook 'ecb-directories-buffer-after-create-hook
                 (lambda ()
                    (local-set-key (kbd "C-d")
                                   (lambda ()
                                      (interactive)
                                      (message "ECB is wonderful!")))))

#### Footnotes

[1] To be more general: They can be used to run any arbitrary lisp code after a tree-buffer creation!