Skip to content

Instantly share code, notes, and snippets.

@rksm
Last active August 29, 2015 14:22
Show Gist options
  • Save rksm/8359cb0f992f3e573a46 to your computer and use it in GitHub Desktop.
Save rksm/8359cb0f992f3e573a46 to your computer and use it in GitHub Desktop.
windows emacs config
;; quite useful:
;; http://www.aaronbedra.com/emacs.d/
;; basic settings
(setq inhibit-splash-screen t
initial-scratch-message nil
initial-major-mode 'org-mode)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
;; windows
(setq pop-up-windows nil)
(setq same-window-buffer-names '("*Occur*"))
(delete-selection-mode t)
(transient-mark-mode t)
(setq tab-width 2
indent-tabs-mode nil)
(setq make-backup-files nil)
(defalias 'yes-or-no-p 'y-or-n-p)
;; -=-=-=-=-=-=-=-=-==-=
;; packages
(load "package")
(package-initialize)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(setq package-archive-enable-alist '(("melpa" deft magit)))
(defvar rksm/packages '(ac-slime
auto-complete
autopair
clojure-mode
flycheck
graphviz-dot-mode
magit
markdown-mode
paredit
smex
ido-vertical-mode
leuven-theme)
"Default packages")
(defun rksm/install-packages ()
(interactive)
(package-refresh-contents)
(dolist (pkg rksm/packages)
(if (not (package-installed-p pkg))
(package-install pkg))))
;; -=-=-=-=-=-=-=-=-=-=-
;; some key shortcuts
(global-set-key (kbd "C-;") 'comment-or-uncomment-region)
(global-set-key (kbd "M-/") 'hippie-expand)
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-a") (lambda () (interactive) (if (bolp) (back-to-indentation) (move-beginning-of-line 1))))
(global-set-key (kbd "C-s-<left>") 'windmove-left)
(global-set-key (kbd "C-s-<right>") 'windmove-right)
(global-set-key (kbd "C-s-<up>") 'windmove-up)
(global-set-key (kbd "C-s-<down>") 'windmove-down)
(global-set-key (kbd "C-x v <SPC>") 'magit-status)
;; -=-=-=-=-=-=-=-=-=-=-
;;; magit
(setq magit-last-seen-setup-instructions "1.4.0")
;; -=-=-=-=-=-=-=-=-=-=-
;;; movement + edits
(defun rksm/duplicate-line ()
(interactive)
(save-excursion
(move-end-of-line 1)
(push-mark nil t t)
(move-beginning-of-line 1)
(kill-ring-save (region-beginning) (region-end))
(move-end-of-line 1)
(newline)
(yank))
(next-line))
(global-set-key (kbd "C-c j") 'join-line)
(global-set-key (kbd "C-c J") (lambda () (interactive) (join-line 1)))
(global-set-key (kbd "C-c p") 'rksm/duplicate-line)
;; lists and autopair
(show-paren-mode t)
(setq echo-keystrokes 0.1
use-dialog-box nil
visible-bell t)
(require 'paredit)
(require 'autopair)
(autopair-global-mode t)
(add-hook 'paredit-mode-hook (lambda () (autopair-mode -1)) t)
(define-key paredit-mode-map (kbd "C-M-<backspace>") 'backward-kill-sexp)
(add-hook 'lisp-mode-hook 'enable-paredit-mode)
(add-hook 'emacs-lisp-mode-hook 'enable-paredit-mode)
(eldoc-mode 1)
;; eldoc
(add-hook 'lisp-mode-hook (lambda () (eldoc-mode t)))
(add-hook 'emacs-lisp-mode-hook (lambda () (eldoc-mode t)))
;; smex
(setq smex-save-file (expand-file-name ".smex-items" user-emacs-directory))
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; ido
(ido-mode t)
(ido-vertical-mode t)
(setq ido-enable-flex-matching t
ido-use-virtual-buffers t)
;; auto complete
(require 'auto-complete-config)
(ac-config-default)
;; isearch / occur
;; see http://emacswiki.org/emacs/OccurFromIsearch
(defun rksm/forward-to-match (re)
""
(re-search-forward re (point-max) t)
(goto-char (match-beginning 0)))
(defun isearch-occur ()
"Invoke `occur' from within isearch."
(interactive)
(let ((case-fold-search isearch-case-fold-search)
(current-line (line-number-at-pos)))
(occur (if isearch-regexp isearch-string (regexp-quote isearch-string)))
(isearch-exit)
(with-current-buffer "*Occur*"
(rksm/forward-to-match (format "^\\s-*%s:" current-line)))))
(define-key isearch-mode-map (kbd "C-o") 'isearch-occur)
;; -=-=-=-=-=-=-=-=-=-=-
;; js
;; -=-=-=-=-=-=-=-=-=-=-
;; font and themes
;; (print (font-family-list))
(set-face-attribute 'default nil :font "DejaVu Sans Mono")
(load-theme 'leuven)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
(quote
("146cc293f18ea1e17d29833b495193d0455bf1e2b30ecc0f2551a77027338576" default))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; TAGS
(if (not (equal window-system 'w32))
(compile (format "find %s/elpa -type d | xargs -I{} etags -a {}/*.el" user-emacs-directory)))
; custom
(put 'downcase-region 'disabled nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment