2

ECB windows display their number: W-0, W-1, etc.

Is there a way to define bindings so that I can get to these windows using bindings such as C-c . w 0, C-c . w 1, rather than using C-c . g d to go to directories, C-c . g s to go to sources?

enter image description here

Alternatively, is there a way to display the key bindings for the windows in the frame modelines?

3

Here's what to do, and how to discover it :)

Navigating to one of these windows, we see that the local value of mode-line-format is:

((:eval
  (car
   (ecb-mode-line-make-modeline-str
    (format " W-%d"
            (1-
             (ecb-window-in-window-list-number
              (ecb-canonical-windows-list))))
   ecb-mode-line-win-nr-face)))
 (#(" " 0 1
    (face ecb-mode-line-prefix-face)))
 (#("/Volumes/Home/hodiquey/Projects/git/ecb" 0 39
    (help-echo "Mouse-2 toggles maximizing, mouse-3 displays a popup-menu" face ecb-mode-line-data-face))))

Therefore, ecb-window-in-window-list-number and ecb-canonical-windows-list are the key (and the actual numbers is 1 more than what's displayed)

You can then do something like

(defun my-jump-to-ecb-number (n)
  (interactive "p")
  (let ((winlist (ecb-canonical-windows-list)))
    (select-window
     (cdr
      (assoc (+ n 1)
             (mapcar (lambda (win)
                       (cons (ecb-window-in-window-list-number winlist win)
                             win))
                     winlist))))))

And use it with something like

(define-key ecb-mode-map (kbd "w 0") (lambda () (interactive) (my-jump-to-ecb-number 0)))
0

The generic solution would be:

  1. Use describe-key (C-h k) or describe-key-briefly(C-h c) to get the names of the commands invoked by the original bindings:

    • C-h c C-c . g d
    • C-h c C-c . g s
  2. Set up additional bindings for the commands:

    (define-key ecb-mode-map (kbd "w 0") 'goto-dirs)
    (define-key ecb-mode-map (kbd "w 1") 'goto-sources)
    

    ... where goto-dirs and goto-sources are the names of the commands you obtained in step 1.

  • that wouldn't work too well when switching layouts (which would potentially change the number associated with dirs/sources) – Sigma Oct 10 '14 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.