Giter Site home page Giter Site logo

smartrep.el's Introduction

Smartrep http://melpa.org/packages/smartrep-badge.svg http://stable.melpa.org/packages/smartrep-badge.svg https://travis-ci.org/myuhe/smartrep.el.svg?branch=master https://coveralls.io/repos/myuhe/smartrep.el/badge.svg?branch=master

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 …)

Contents

Usage

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.

Examples

Control Two Buffers

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))))

Change Window Size

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)))

Move header on Org-mode

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))))

Remotely Control Firefox

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)))

Smartrep Works In Many Applications

Many applications use smartrep. Thanks!!

Related article

Similar Applications

abo-abo/hydra

smartrep.el's People

Contributors

myuhe avatar buzztaiki avatar syohex avatar tkf avatar rgiar avatar rolandwalker avatar wqer555 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.