Skip to content

Instantly share code, notes, and snippets.

@werelax
Created September 10, 2015 10:05
Show Gist options
  • Save werelax/e635d9a74bcf0f3a2ba0 to your computer and use it in GitHub Desktop.
Save werelax/e635d9a74bcf0f3a2ba0 to your computer and use it in GitHub Desktop.
Super basic emacs config file for quick startup time (alternative setup to use as $EDITOR)
(setq backup-inhibited t
auto-save-default nil)
(menu-bar-mode -1)
;;; package --- Some editing configurations
;;; Commentary:
;;; Code:
;; disable guru mode for kinesis
(setq prelude-guru nil)
;; config (indentation)
(setq-default ident-tabs-mode nil)
(setq tab-width 2)
(defvaralias 'c-basic-offset 'tab-width)
(setq js-indent-level 2)
;; Key bindings
(global-set-key (kbd "RET") 'newline-and-indent)
;; (global-set-key (kbd "RET") 'newline)
; window movement (two sets, testing which one I prefer)
(global-set-key (kbd "C-S-h") 'windmove-left)
(global-set-key (kbd "C-S-j") 'windmove-down)
(global-set-key (kbd "C-S-k") 'windmove-up)
(global-set-key (kbd "C-S-l") 'windmove-right)
(global-set-key (kbd "M-h") 'windmove-left)
(global-set-key (kbd "M-j") 'windmove-down)
(global-set-key (kbd "M-k") 'windmove-up)
(global-set-key (kbd "M-l") 'windmove-right)
; heml-cmd-t jumpt to file (fast way, not fuzzy)
;; (global-set-key (kbd "C-S-t") 'helm-cmd-t)
;; insert cool lambdas!
(global-set-key (kbd "s-l") (lambda ()
(interactive)
(insert-char #x3bb)))
;; modifier keys
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'super)
;; hideshow keybindings
(global-set-key (kbd "s-h") 'hs-hide-block)
(global-set-key (kbd "s-s") 'hs-show-block)
;; Mode-specific customizations
;; (add-to-list 'auto-mode-alist '("\\.hamljs\\'" . haml-mode))
;; load Quack mode (scheme)
;; (require 'quack)
;;; Customizations from Writing GNU Emacs Extensions
(defun other-window-backwards (&optional n)
"Select the Nth previous window."
(interactive "P")
(other-window (- (prefix-numeric-value n))))
(global-set-key "\C-x\C-n" 'other-window)
(global-set-key "\C-x\C-p" 'other-window-backwards)
(global-set-key "\C-c\C-n" 'other-window)
(global-set-key "\C-c\C-p" 'other-window-backwards)
;; Frame switching
(defun other-frame-backwards (&optional n)
"Select the Nth previous frame."
(interactive "P")
(other-frame (- (prefix-numeric-value n))))
;; (global-set-key "\C-c\C-n" 'other-frame)
;; (global-set-key "\C-c\C-p" 'other-frame-backwards)
(global-set-key "\M-`" 'other-frame)
;; Conflicts between yasnippet and autocomplelte-mode
;; [commented-out because it was interferring with undo-tree-redo]
;; (global-set-key "\M-?" 'yas-expand)
;; helm-M-x, which is pretty cool (was 'capitalize-word)
;; (global-set-key "\M-c" 'helm-M-x)
;; helm-occur (was 'split-line)
;; (global-set-key "\M-\C-o" 'helm-occur)
;; helm-mini more accesible
;; (global-set-key "\M-\S-m" 'helm-mini)
;; leave the point at the beggining of the match on after i-search
(defadvice isearch-exit (after my-goto-match-beginning activate)
"Go to beginning of match."
(when (and isearch-forward isearch-other-end)
(goto-char isearch-other-end)))
;; I like this keychrod to redo, feels logical
;; (global-set-key "\C-\\" 'undo-tree-redo)
;; scroll wheel in console (only works with xterm-mouse-mode)
(xterm-mouse-mode t)
(global-set-key [mouse-4] 'scroll-down-line)
(global-set-key [mouse-5] 'scroll-up-line)
;; helm-git-grep (was 'mark-defun)
;; (global-set-key "\C-\M-h" 'helm-git-grep)
;; yegge effective-emmacs advice: C-w to 'backward-kill-word
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region) ;was 'edit-kbd-macro
(global-set-key "\C-c\C-k" 'kill-region)
;; change between header and implementation files (was 'prelude-open-with)
(add-hook 'c-mode-common-hook
(lambda ()
(local-set-key (kbd "C-c C-c") 'ff-find-other-file)))
;; yasnippets folders
;; TODO: remove the following two lines, should be integrated in prelude (by the way, update prelude)
;; (require 'yasnippet)
;; (yas-global-mode 1)
;; (setq yas-snippet-dirs (append yas-snippet-dirs
;; '("~/.emacs.d/personal/snippets")))
;; ;; helm-do-grep (was 'org-store-link)
;; (global-set-key "\C-cl" 'helm-do-grep)
;; I press this by mistake a lot (was 'delete-blank-lines)
(global-set-key "\C-x\C-o" 'other-window)
;; trying to find key not overriden by other modes...
;; (global-set-key "\C-x\C-g" 'helm-git-grep)
;; recurise helm-grep search in the whole project
;; (defun grep-in-project ()
;; "Recursive helm-grep in the whole project."
;; (interactive)
;; (helm-do-grep-1 (list (projectile-project-root))
;; t
;; nil
;; '("*.js" "*.json" "*.html" "*.css" "*.md" "*.c" "*.cpp" "*.h"
;; "*.hpp")))
;; ;; was 'downcase-region
;; (global-set-key "\C-x\C-l" 'grep-in-project)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment