smartrep
is a sequential command interface library. It enables the omittance of typing prefix keys. (e.g., C-c C-n C-n C-n … instead of C-c C-n C-c C-n C-c C-n …)
smartrep
offers only one function smartrep-define-key
.
The key is bound with smartrep-define-key
like:
(smartrep-define-key
global-map "M-g"
'(("n" . next-line)
("p" . previous-line)))
Then after typing M-g
, n
exetutes next-line
and p
executes previous-line
.
If any other key is typed, the special key binding is canceled. That is, if n
is typed, “n” is inserted as a character.
Scroll another buffer. The current buffer is not changed.
If you want to scroll by two lines in the other buffer, just type C-q n n
.
(smartrep-define-key
global-map "C-q" '(("n" . (scroll-other-window 1))
("p" . (scroll-other-window -1))
("N" . 'scroll-other-window)
("P" . (scroll-other-window '-))
("a" . (beginning-of-buffer-other-window 0))
("e" . (end-of-buffer-other-window 0))))
Changing Window size tends to execute the same command continuously. It is boring work.
So eval this example and type C-x { { {
.
(smartrep-define-key
global-map "C-x"
'(("{" . shrink-window-horizontally)
("}" . enlarge-window-horizontally)))
Org-mode has complicated prefix keys. It is so frustrating.
This idea simplifies it. If you want to move from heading to heading, then type C-c
and then C-n
or C-p
.
(smartrep-define-key
org-mode-map "C-c" '(("C-n" . (outline-next-visible-heading 1))
("C-p" . (outline-previous-visible-heading 1))))
You may control Firefox via Emacs.
This example enables the manipulation of Firefox to scroll up, down and more.
It requires moz.el
(autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)
(moz-minor-mode t)
(defun moz-send-message (moz-command)
(comint-send-string
(inferior-moz-process)
(concat moz-repl-name ".pushenv('printPrompt', 'inputMode'); "
moz-repl-name ".setenv('inputMode', 'line'); "
moz-repl-name ".setenv('printPrompt', false); undefined; "))
(comint-send-string
(inferior-moz-process)
(concat moz-command
moz-repl-name ".popenv('inputMode', 'printPrompt'); undefined;\n")))
(defun moz-scrolldown-1 ()
(interactive)
(moz-send-message "goDoCommand('cmd_scrollLineDown');\n"))
(defun moz-scrolldown ()
(interactive)
(moz-send-message "goDoCommand('cmd_scrollPageDown');"))
(defun moz-scrollup-1 ()
(interactive)
(moz-send-message "goDoCommand('cmd_scrollLineUp');\n"))
(defun moz-scrollup ()
(interactive)
(moz-send-message "goDoCommand('cmd_scrollPageUp');"))
(defun moz-top ()
(interactive)
(moz-send-message "goDoCommand('cmd_scrollTop');\n"))
(defun moz-bottom ()
(interactive)
(moz-send-message "goDoCommand('cmd_scrollBottom');\n"))
(require 'smartrep)
(smartrep-define-key
global-map "M-g" '(("n" . moz-scrolldown-1)
("N" . moz-scrolldown)
("p" . moz-scrollup-1)
("P" . moz-scrollup)
("a" . moz-top)
("e" . moz-bottom)))
Many applications use smartrep
. Thanks!!
- Zoom in / out with style · (or emacs
- 連続操作を素敵にするsmartrep.el作った - sheephead (In Japanese)
- smartrep.el 0.0.3をリリースしました - sheephead (In Japanese)
- multiple-cursors.elのキーバインドを少しだけ改善 - 備忘録 (In Japanese)
- Emacs - smartrep.elでrepeatを活性化せよ - http://rubikitch.com/に移転しました (In Japanese)