Created
July 25, 2013 20:23
-
-
Save jqtruong/6083390 to your computer and use it in GitHub Desktop.
Another example of a temporary overlay map in emacs...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro repeater-map-more (keymaps &optional msg) | |
"For complex maps in which multiple repeatable keys are attached to | |
functions." | |
`(set-temporary-overlay-map | |
(let ((map (make-sparse-keymap))) | |
(loop | |
for (repeat-key fun) in ,keymaps | |
do (define-key map (vector repeat-key) | |
`(lambda () (interactive) | |
(if ,msg | |
(message ,msg)) | |
(if (listp ',fun) | |
(apply (car ,fun) (cdr ,fun)) | |
(,fun))))) | |
map) t)) | |
(defun jqt/continue-more (keymaps &optional msg) | |
"Helper method for not much at the moment..." | |
(if msg | |
(message msg)) | |
(repeater-map-more keymaps msg)) | |
(defun jqt/window-control () | |
"Creates a temporary overlay map for: | |
- `f' switch to next window | |
- `b' switch to previous window | |
- `p' switch to previous buffer | |
- `n' switch to next buffer | |
- `j' switch to top jabber buffer | |
- `s' switch to buffer from the minibuffer | |
- `d' delete current window | |
- `c' split window to compare last two buffers | |
- `C' like `c' but split horizontally | |
- `1' delete other windows | |
- `2' split frame with one-third and two-third ratios | |
- `3' split frame into equal thirds" | |
(interactive) | |
(jqt/continue-more | |
'(;; switch windows | |
(?f '(other-window 1)) | |
(?b '(other-window -1)) | |
;; switch buffers | |
(?p previous-buffer) | |
(?n next-buffer) | |
(?j jqt/switch-to-jabber-chat-buffer) | |
(?s ido-switch-buffer) | |
;; resize windows | |
(?d delete-window) | |
(?c jqt/split-to-compare) | |
(?C '(jqt/split-to-compare 1)) | |
(?1 delete-other-windows) | |
(?2 jqt/two-third-it-up) | |
(?3 jqt/split-window-into-three)) | |
"window-control map active...")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment