Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

411 lines (324 sloc) 14.703 kb

Starter Kit Bindings

This is part of the Emacs Starter Kit.

Starter Kit Bindings

Key Bindings.

Mac commands

My carry-over stuff–influenced by Mac and Aquamacs


(defvar aqm-keys-minor-mode-map (make-keymap) "aqm-keys-minor-mode keymap.")

(define-minor-mode aqm-keys-minor-mode
  "A minor mode for converting aquamacs emacs to emacs 23 (cocoa)"
  t " aqm" 'aqm-keys-minor-mode-map)

(aqm-keys-minor-mode 1)         ;; activate

;; recentf, kill buffer
(define-key aqm-keys-minor-mode-map (kbd "C-x C-r") 'recentf-open-files)
                    ;(define-key aqm-keys-minor-mode-map (kbd "C-l") 'recenter-top-bottom)
(define-key aqm-keys-minor-mode-map (kbd "C-c C-w") 'kill-this-buffer)
(define-key aqm-keys-minor-mode-map (kbd "S-w") 'kill-this-buffer)

;; Full screen
(define-key aqm-keys-minor-mode-map (kbd "s-<return>") 'ns-toggle-fullscreen)
(define-key aqm-keys-minor-mode-map (kbd "s-}") 'tabbar-forward-tab)
(define-key aqm-keys-minor-mode-map (kbd "s-{") 'tabbar-backward-tab)
(define-key aqm-keys-minor-mode-map (kbd "s-c") 'clipboard-kill-ring-save)
(define-key aqm-keys-minor-mode-map (kbd "s-v") 'cua-paste)

;;; inspired by iTerm...yeah!
(define-key aqm-keys-minor-mode-map (kbd "s-]") 'other-window)
(define-key aqm-keys-minor-mode-map (kbd "s-[") '(lambda () (interactive) (other-window -1)))

Lisp Keys


;; (define-globalized-minor-mode global-paredit-mode paredit-mode paredit-mode)
;; (global-paredit-mode t)

(defvar myLisp-keys-minor-mode-map (make-keymap) "myLisp-keys-minor-mode keymap.")
(define-minor-mode myLisp-keys-minor-mode
  "A minor mode for programming"
  t " myCL" 'myLisp-keys-minor-mode-map)

(define-key myLisp-keys-minor-mode-map (kbd "C-#") 'slime)
(define-key myLisp-keys-minor-mode-map (kbd "S-s") (lambda () (interactive) (insert "[]") (backward-char 1)))
(define-key myLisp-keys-minor-mode-map (kbd "S-d") (lambda () (interactive) (insert "()") (backward-char 1)))
(define-key myLisp-keys-minor-mode-map (kbd "S-f") (lambda () (interactive) (insert "{}") (backward-char 1)))

(add-hook 'lisp-mode-hook '(lambda ()
                 (myLisp-keys-minor-mode 1)
                 ))

(add-hook 'scheme-mode-hook '(lambda ()
                             (myLisp-keys-minor-mode 1)
                             ))

Chris keys

  (defvar chris-keys-minor-mode-map (make-keymap) "chris-keys-minor-mode keymap.")
  
  (define-minor-mode chris-keys-minor-mode
    "A minor mode so that my key settings override annoying major modes."
    t " wcb" 'chris-keys-minor-mode-map)
  
  (chris-keys-minor-mode 1)
  
  ;;; Org table to Latex
  (define-key chris-keys-minor-mode-map (kbd "C-c m") 'i-matrixify)
  
  ;; Fastnav
  (define-key chris-keys-minor-mode-map "\M-z" 'zap-up-to-char-forward)
  (define-key chris-keys-minor-mode-map "\M-Z" 'zap-up-to-char-backward)
  ;; (define-key chris-keys-minor-mode-map "\M-i" 'sprint-forward)
  ;; (define-key chris-keys-minor-mode-map "\M-I" 'sprint-backward)
  (define-key chris-keys-minor-mode-map "\M-i" 'jump-to-char-forward)
  (define-key chris-keys-minor-mode-map "\M-I" 'jump-to-char-backward)
  
  (define-key chris-keys-minor-mode-map (kbd "C-.") 'repeat-complex-command)
  
                                          ;    (define-key chris-keys-minor-mode "\M-i" 'ido-goto-symbol)
  
    ;; Files
  (define-key chris-keys-minor-mode-map (kbd "C-c C-r") 'revert-buffer)
  (define-key chris-keys-minor-mode-map (kbd "C-c f") 'ffap)
  (define-key chris-keys-minor-mode-map "\M-s" 'anything)
  (define-key chris-keys-minor-mode-map "\C-xaf" 'anything-for-files)
  
  
  
;; Yasnippet
(define-key chris-keys-minor-mode-map (kbd "M-<tab>") 'yas/expand)

For moving around in and resizing Windows/buffers

  ;; Resize Windows
(define-key chris-keys-minor-mode-map (kbd "S-C-<left>") 'shrink-window-horizontally)
(define-key chris-keys-minor-mode-map (kbd "S-C-<right>") 'enlarge-window-horizontally)
(define-key chris-keys-minor-mode-map (kbd "S-C-<down>") 'enlarge-window)
(define-key chris-keys-minor-mode-map (kbd "S-C-<up>") 'shrink-window)
;; Select Windows
;; (define-key chris-keys-minor-mode-map (kbd "S-M-<right>") 'select-next-window)
;; (define-key chris-keys-minor-mode-map (kbd "S-M-<left>")  'select-previous-window)


;; Scrolling
(global-set-key "\M-\S-n" 'gcm-scroll-down)
(global-set-key "\M-\S-p" 'gcm-scroll-up)

(global-set-key (kbd "M-n") 'big-move-down)  ; Defined in defuns, along with transparency functions
(global-set-key (kbd "M-p") 'big-move-up)

;; Transparency
(global-set-key (kbd "C-!") 'transparency-set-value)
;; The two below let for smooth transparency control
(global-set-key (kbd "C-~") 'transparency-increase)
(global-set-key (kbd "C-`") 'transparency-decrease)

My word editing

Bindings for editing in the trenches.

(define-key chris-keys-minor-mode-map (kbd "C-S-<tab>") 'tabbar-backward)

 ; see if this is already taken care of in starter kit
;; (define-key  chris-keys-minor-mode-map (kbd "C-j") 'newline-and-indent)
;; reindent-then-newline-and-indent)
 ;  ; this messes up 'RET' for some reason

;;; Killing and copying Commands
(define-key chris-keys-minor-mode-map (kbd "C-S-k") 'kill-whole-line)
(define-key chris-keys-minor-mode-map (kbd "C-M-<backspace>") 'backward-kill-sexp)
(define-key chris-keys-minor-mode-map (kbd "C-M-}") 'kill-paragraph)
(define-key chris-keys-minor-mode-map (kbd "C-M-{") 'backward-kill-paragraph)
(define-key chris-keys-minor-mode-map "\C-x\C-k" 'kill-ring-save)
(define-key chris-keys-minor-mode-map "\C-c\C-y" 'copy-whole-line)
(define-key chris-keys-minor-mode-map "\C-c\C-k" 'copy-line)
(define-key chris-keys-minor-mode-map "\C-w" 'backward-kill-word)
(define-key chris-keys-minor-mode-map "\M-w" 'kill-region)
(define-key chris-keys-minor-mode-map "\C-h" 'backward-delete-char)

;;; To replace the help command
(define-key chris-keys-minor-mode-map (kbd "C-S-?") 'help-command)
(define-key chris-keys-minor-mode-map (kbd "M-?") 'help-command)

;;; Get rid of weird toggle-input replacement
(define-key chris-keys-minor-mode-map (kbd "<f3>") 'toggle-input-method)

;;; Evaluating
(define-key chris-keys-minor-mode-map "\M-j" 'eval-last-sexp)

(define-key chris-keys-minor-mode-map "\M-'" 'toggle-letter-case)

Isearch keys

Mostly to make it consistent with setup for other modes.


(define-key isearch-mode-map "\C-h" 'isearch-delete-char)
(define-key isearch-mode-map "\C-y" 'isearch-yank-word)
(define-key isearch-mode-map "\C-g" 'isearch-exit)

Ido keys

(add-hook 'ido-define-mode-map-hook 'ido-my-keys)

(defun ido-my-keys ()
  "Set up the keymap for `ido'."

  ;; backspace functions
  (define-key ido-mode-map "\C-h" 'ido-delete-backward-updir)
  (define-key ido-mode-map "\C-w" 'ido-delete-backward-word-updir)
  (define-key ido-mode-map [backspace] 'ido-up-directory)
  ;; http://people.ku.edu/~syliu/shredderyin/ido.html
  )

Programming keys


(defvar myProgramming-keys-minor-mode-map (make-keymap) "myProgramming-keys-minor-mode keymap.")
(define-minor-mode myProgramming-keys-minor-mode
  "A minor mode for programming"
  t " prog" 'myProgramming-keys-minor-mode-map)

(define-key myProgramming-keys-minor-mode-map (kbd "C-<tab>") 'ff-find-other-file )
;; (define-key myProgramming-keys-minor-mode-map (kbd "M-'") 'comment-kill)
(define-key myProgramming-keys-minor-mode-map (kbd "M-]") 'my-toggle-selective-display)

(add-hook 'c-mode-common-hook '(lambda ()
				 (myProgramming-keys-minor-mode 1)
				 ))

Matlab and Octave

;  (mapcar (lambda(x)(car(rassq x minor-mode-map-alist)))(current-minor-mode-maps))

(add-hook 'matlab-mode-hook
          (lambda ()
            (define-key matlab-mode-map (kbd "M-;") 'comment-dwim)))
(add-hook 'matlab-mode-hook
          (lambda ()
            (define-key matlab-mode-map "\C-c\C-il" 'matlab-shell-run-region-or-line)))  

(add-hook 'octave-mode-hook
          (lambda ()
            (define-key octave-mode-map (kbd "<tab>") 'my-octave-complete-symbol)))

You know, like Readline.

(global-set-key (kbd "C-M-h") 'backward-kill-word)

Align your code in a pretty way.

(global-set-key (kbd "C-x \\") 'align-regexp)

Completion that uses many different methods to find options.

(global-set-key (kbd "M-/") 'hippie-expand)

Perform general cleanup.

(global-set-key (kbd "C-c n") 'cleanup-buffer)

Turn on the menu bar for exploring new modes

(global-set-key [f1] 'menu-bar-mode)

Font size

(define-key global-map (kbd "C-+") 'text-scale-increase)
(define-key global-map (kbd "C--") 'text-scale-decrease)
(define-key global-map (kbd "s-=") 'text-scale-increase)
(define-key global-map (kbd "s--") 'text-scale-decrease)

Use regex searches by default.

Not sure about this… -wcb

;; (global-set-key (kbd "C-s") 'isearch-forward-regexp)
;; (global-set-key (kbd "\C-r") 'isearch-backward-regexp)
;; (global-set-key (kbd "C-M-s") 'isearch-forward)
;; (global-set-key (kbd "C-M-r") 'isearch-backward)

Jump to a definition in the current file. (This is awesome.)

(global-set-key (kbd "C-x C-i") 'ido-imenu)

File finding

(global-set-key (kbd "C-x M-f") 'ido-find-file-other-window)
(global-set-key (kbd "C-x C-M-f") 'find-file-in-project)
(global-set-key (kbd "C-x f") 'recentf-ido-find-file)
(global-set-key (kbd "C-x C-p") 'find-file-at-point)
(global-set-key (kbd "C-c y") 'bury-buffer)
(global-set-key (kbd "C-c r") 'revert-buffer)
(global-set-key (kbd "M-`") 'file-cache-minibuffer-complete)
(global-set-key (kbd "C-x C-b") 'ibuffer)

Window switching and resizing. (C-x o goes to the next window)

(windmove-default-keybindings) ;; Shift+direction
(global-set-key (kbd "C-x O") (lambda () (interactive) (other-window -1))) ;; back one
(global-set-key (kbd "C-x C-o") (lambda () (interactive) (other-window 2))) ;; forward two

Indentation help

(global-set-key (kbd "C-x ^") 'join-line)

Start eshell or switch to it if it’s active.

(global-set-key (kbd "C-x m") 'eshell)

Start a new eshell even if one is active.

(global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))

Start a regular shell if you prefer that.

(global-set-key (kbd "C-x M-m") 'shell)

If you want to be able to M-x without meta

(global-set-key (kbd "C-x C-m") 'execute-extended-command)

Fetch the contents at a URL, display it raw.

(global-set-key (kbd "C-x h") 'view-url)

Help should search more than just commands

(global-set-key (kbd "C-h a") 'apropos)

Should be able to eval-and-replace anywhere.

(global-set-key (kbd "C-c e") 'eval-and-replace)

Applications


(global-set-key (kbd "C-c j") (lambda () (interactive) (switch-or-start 'jabber-connect "*-jabber-*")))
(global-set-key (kbd "C-c g") (lambda () (interactive) (switch-or-start 'gnus "*Group*")))
(global-set-key (kbd "C-c i") (lambda () (interactive) (switch-or-start (lambda ()
                                                                     (rcirc-connect "irc.freenode.net"))
                                                                   "*irc.freenode.net*")))
(global-set-key (kbd "C-c J") 'jabber-send-presence)
(global-set-key (kbd "C-c M-j") 'jabber-disconnect)
(global-set-key (kbd "C-x g") 'magit-status)

This is a little hacky since VC doesn’t support git add internally

(eval-after-load 'vc
  (define-key vc-prefix-map "i" '(lambda () (interactive)
                                   (if (not (eq 'Git (vc-backend buffer-file-name)))
                                       (vc-register)
                                     (shell-command (format "git add %s" buffer-file-name))
                                     (message "Staged changes.")))))

Activate occur easily inside isearch

(define-key isearch-mode-map (kbd "C-o")
  (lambda () (interactive)
    (let ((case-fold-search isearch-case-fold-search))
      (occur (if isearch-regexp isearch-string (regexp-quote isearch-string))))))

Closing

(provide 'starter-kit-bindings)
;;; starter-kit-bindings.el ends here

Org-mode

Two global binding for Org-mode (see starter-kit-org)

The Org-mode agenda is good to have close at hand

(define-key global-map "\C-ca" 'org-agenda)

Org-mode supports links, this command allows you to store links globally for later insertion into an Org-mode buffer. See Handling-links in the Org-mode manual.

(define-key global-map "\C-cl" 'org-store-link)

Magit

It’s to the point now where I almost can’t use git without magit.

(require 'magit)
(define-key global-map "\M-\C-g" 'magit-status)
magit-status

Rgrep

Rgrep is infinitely useful in multi-file projects.

(see elisp:(describe-function ‘rgrep))

(define-key global-map "\C-x\C-r" 'rgrep)
Jump to Line
Something went wrong with that request. Please try again.