Skip to content

leuven65/simplify-keybinding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

simplify-keybinding

About

This library is to simplify the Emacs keybinding for the commands which have same prefix leading key, so that we don’t need to press the prefix leading key.

Such as, By defining simplied keybindings for winner-undo (“C-c <left>”) and winner-redo (“C-c <right>”), if last command is one of them, it doesn’t need to press “C-c” again to next command.

image/About/2020-12-26_12-42-50_screenshot.png

It is possible to use Hydra to implement similar functions, but I think the way used here is more simple and clear.

Installation

Clone this git repo to “${user-emacs-directory}/packages/simplify-keybinding”, and add folowing lines to Emacs config file:

(use-package simplify-keybinding
  :defer t
  :ensure nil ; it is github package
  ;; If the path is relative, it is expanded within `user-emacs-directory'
  :load-path "packages/simplify-keybinding"
  :init
  (let ((pkg-name "simplify-keybinding"))
    (ignore-errors
      (package-generate-autoloads pkg-name
                                  (expand-file-name (concat "packages/" pkg-name)
                                                    user-emacs-directory)))
    (load (concat pkg-name "-autoloads.el")))
  )

Usage

Just use SK-define-keymap to define the simplified keybindings, please see the examples below.

SK-setup-default-keymap can setup these example keybindings automatically.

For winner

(SK-define-keymap
 (("<left>" winner-undo "← undo")
  ("<right>" winner-redo "→ redo"))
 "Winner: ")

For “prev-buffer” and “next-buffer”

(SK-define-keymap
 (("<left>" previous-buffer "← prev-buffer")
  ("<right>" next-buffer "→ next-buffer"))
 "Buffer: ")

For navigating on compile errors

(with-eval-after-load 'compile
  (SK-define-keymap
   (("M-n" next-error "M-n next-error")
    ("M-p" previous-error "M-p prev-error"))
   "Compilation error: ")
  )

For navigating on org-mode headlines

(SK-define-keymap
 (("C-n" org-next-visible-heading "C-n next")
  ("C-p" org-previous-visible-heading "C-p pre")
  ("C-u" outline-up-heading "C-u up")
  ("C-f" org-forward-heading-same-level "C-f foward")
  ("C-b" org-backward-heading-same-level "C-b backward")
  )
 "Navigate headlines: "
 (derived-mode-p 'org-mode))

About

Simplify the keybinding in Emacs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published