Use Emacs With Home Row

After writing about switching buffers in emacs last year. I keep looking for the way to switch buffer quicker and more comfortably. I mentioned the package awesome-tab in that post and I'm still using it.

The package shows buffers as tabs in emacs header line, and provides functions to switch to next/prev, first/last tab. It also groups buffers depends on project and major-mode.

I write a patch for the package to add function to jump to specifc tab recently. So that user can jump to specific tabs with different shortcuts.

I also write a patch for company-mode to customize the company candidate numbers when company-show-numbers is set to t.

Now I can use the home row the way I want in emacs. Check the screenshot below.

use emacs with home row image
use emacs with home row

As you can see in the picture, instead of numbers, there're "asdf" for both tabs and completion candidates. Next step is to switch/select tabs/candidates with home row shortcuts.

    {:des "Emacs m/v select company candidates"
 :rules [:emacs-m-mode
         [:a [:!Tx :!T6 :1]]
         [:s [:!Tx :!T6 :2]]
         [:d [:!Tx :!T6 :3]]
         [:f [:!Tx :!T6 :4]]
         [:g [:!Tx :!T6 :5]]
         [:h [:!Tx :!T6 :6]]
         [:j [:!Tx :!T6 :7]]
         [:k [:!Tx :!T6 :8]]
         [:l [:!Tx :!T6 :9]]
         [:semicolon [:!Tx :!T6 :0]]]}    

Above code uses goku and karabiner to map m+asdfg and v+hjkl; to C-x C-6 1234567890. That's 'm' key down then click 'a' to C-x C-6 1 in emacs. Then I map C-x C-6 + numbers to functions that switch/select tabs/candidates in emacs.

    ;; jump to specific in emacs
(define-key awesome-tab-mode-map (kbd "C-x C-6 1") (lambda () (interactive) (awesome-tab-jump ?a)))
(define-key awesome-tab-mode-map (kbd "C-x C-6 2") (lambda () (interactive) (awesome-tab-jump ?s)))
(define-key awesome-tab-mode-map (kbd "C-x C-6 3") (lambda () (interactive) (awesome-tab-jump ?d)))

;; select specific candidates in company-active-map
(define-key company-active-map (kbd "C-x C-6 1") (kbd "M-1"))
(define-key company-active-map (kbd "C-x C-6 2") (kbd "M-2"))
(define-key company-active-map (kbd "C-x C-6 3") (kbd "M-3"))    

We can use magic now!

'ma' switch to first tab. 'mg' select 5th candidates when completing stuff.

You can find above code in my goku config and .emacs.d.

Comment via email or via Disqus comments below: