Skip to content

Instantly share code, notes, and snippets.

@fvbock
Created August 9, 2014 01:45
Show Gist options
  • Save fvbock/57d3bb90e8bf0229fd2d to your computer and use it in GitHub Desktop.
Save fvbock/57d3bb90e8bf0229fd2d to your computer and use it in GitHub Desktop.
.emacs
(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.
'(TeX-newline-function (quote newline))
'(auto-image-file-mode t nil (image-file))
'(blink-cursor-mode nil)
'(case-fold-search t)
'(deft-auto-save-interval 120.0)
'(desktop-enable t nil (desktop))
'(fill-column 0)
'(global-font-lock-mode t nil (font-lock))
'(js-indent-level 2)
'(markdown-command "markdown -o html")
'(markdown-command-needs-filename t)
'(ps-paper-type (quote a4))
'(show-paren-mode t nil (paren))
'(standard-indent 2)
'(tab-always-indent nil)
'(tab-width 4)
'(transient-mark-mode t)
'(undo-limit 90000)
'(uniquify-buffer-name-style (quote forward) nil (uniquify))
'(x-select-enable-clipboard t))
(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.
'(cursor ((t (:background "royal blue"))))
'(region ((t (:background "dim gray")))))
;; external path search
(setq load-path (cons "~/emacs-lisp" load-path))
(setq load-path (cons "/usr/share/emacs/site-lisp" load-path))
;; Enable versioning with default values
(setq version-control t)
;; Save all backup file in this directory.
(setq backup-directory-alist (quote ((".*" . "/home/morpheus/emacs_tmp/"))))
(setq delete-old-versions t)
(setq bell-volume 0)
(setq sound-alist nil)
(setq visible-bell t)
;; (set-background-color "grey92" )
(set-background-color "grey20" )
(set-foreground-color "white" )
(set-buffer-file-coding-system 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)
(setq-default indent-tabs-mode nil)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(add-hook 'before-save-hook 'untabify (point-min) (point-max))
(set-frame-position (selected-frame) 0 0)
(tool-bar-mode 0)
(column-number-mode nil)
(set-scroll-bar-mode 'right)
(fset 'yes-or-no-p 'y-or-n-p)
(setq inhibit-startup-message t)
(setq interprogram-cut-function 'x-select-text)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
(setq enable-hightlight t)
(iswitchb-mode 1)
;; hightlight line
(defun start-hightlight()
"Start hightlight line"
(interactive)
(progn
(require 'highlight-current-line)
(highlight-current-line-on t)
(highlight-current-line-set-bg-color "grey")
(highlight-current-line-set-fg-color "black")))
(if enable-hightlight
(start-hightlight))
;; setup w3m
(setq browse-url-browser-function 'w3m-browse-url)
(autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
(set-face-font 'default "-Adobe-Courier-normal-normal-normal-*-14-140-75-75-m-90-iso10646-1")
;; (set-face-font 'default "-*-courier 10 pitch-*-*-*-*-13-*-*-*-*-*-*-*")
(set-frame-size (selected-frame) 320 120)
;; functions
(defun sel-and-x-line (type)
(interactive)
(beginning-of-line)
(set-mark (point))
(end-of-line)
(cond
((string= type "c")
(kill-ring-save (region-beginning) (region-end)))
((string= type "x")
(kill-region (region-beginning) (region-end)))
((string= type "co")
(comment-region (region-beginning) (region-end)))
((string= type "uc")
(uncomment-region (region-beginning) (region-end)))))
(defun sel-and-copy-line () (interactive) (sel-and-x-line "c"))
(defun sel-and-cut-line () (interactive) (sel-and-x-line "x"))
(defun sel-and-comment-line () (interactive) (sel-and-x-line "co"))
(defun sel-and-uncomment-line () (interactive) (sel-and-x-line "uc"))
(defun uml2entity ()
(interactive)
(beginning-of-buffer)
(replace-string "ä" "ä")
(beginning-of-buffer)
(replace-string "ö" "ö")
(beginning-of-buffer)
(replace-string "ü" "ü")
(beginning-of-buffer)
(replace-string "ß" "ß")
(beginning-of-buffer)
(replace-string "Ä" "Ä")
(beginning-of-buffer)
(replace-string "Ö" "Ö")
(beginning-of-buffer)
(replace-string "Ü" "Ü"))
(defun space_brackets ()
(interactive)
(beginning-of-buffer)
(replace-string "(" "( ")
(beginning-of-buffer)
(replace-string ")" " )")
(beginning-of-buffer)
(replace-string "( )" "()")
(beginning-of-buffer)
(replace-string "[" "[ ")
(beginning-of-buffer)
(replace-string "]" " ]")
(beginning-of-buffer)
(replace-string "[ ]" "[]"))
(defun unspace_brackets ()
(interactive)
(beginning-of-buffer)
(replace-string "( " "(")
(beginning-of-buffer)
(replace-string " )" ")")
(beginning-of-buffer)
(replace-string "[ " "[")
(beginning-of-buffer)
(replace-string " ]" "]"))
(defun format-sql ()
(interactive)
(shell-command-on-region (region-beginning) (region-end) "/usr/bin/fsqlf" 1))
(defun three-balanced-buffers ()
"split-window-horizontally and decrease font-size"
(interactive)
(split-window-horizontally)
(split-window-horizontally)
(balance-windows) )
(defun tile-and-resize ()
"split-window-horizontally and decrease font-size"
(interactive)
(split-window-horizontally)
)
;; packages
(require 'anything)
(require 'dired+)
;; key bindings
(define-key global-map "\C-x1" 'del-other-windows-and-resize)
(define-key global-map "\C-x3" 'tile-and-resize)
(global-set-key (quote [f4] ) 'three-balanced-buffers)
(define-key global-map "\M-o" 'goto-line)
;; (define-key global-map "\C-c\C-r" 'recentf-open-files)
(define-key global-map "\C-c\C-f" 'open-in-current-dir)
(define-key global-map "\M-a" 'beginning-of-line-text)
(define-key global-map "\M-\S-a" 'apropos)
(define-key global-map "\C-cc" 'sel-and-copy-line)
(define-key global-map "\C-cx" 'sel-and-cut-line)
(define-key global-map [C-tab] 'set-mark-command)
(define-key global-map "\C-cq" 'comment-region)
(define-key global-map "\C-cw" 'uncomment-region)
(define-key global-map "\C-ci" 'indent-region)
(define-key global-map "\M-[" 'sel-and-comment-line)
(define-key global-map "\M-]" 'sel-and-uncomment-line)
(define-key global-map "\M-_" 'replace-string)
(define-key global-map "\M-\C-_" 'replace-regexp)
(define-key global-map "\M-n" 'setnu-mode)
(define-key global-map "\C-c\C-t" 'term)
(define-key global-map "\C-c\C-s" 'shell)
(define-key global-map "\C-c\C-cf" 'find-dired)
(define-key global-map "\C-c\C-p" 'ps-print-buffer)
(define-key global-map "\C-c\C-l" '(switch-im "l"))
(define-key global-map "\C-c\C-j" '(switch-im "j"))
(define-key global-map "\C-c\C-k" '(switch-im "k"))
(define-key global-map "\C-z" 'yank)
(define-key global-map "\M-1" 'undo)
(define-key global-map "\M-2" 'anything)
(define-key global-map "\C-cfs" 'format-sql)
;; (define-key global-map [C-9] 'next-multiframe-window)
;; (define-key global-map [C-8] 'previous-multiframe-window)
(global-set-key (quote [f5]) 'find-grep)
(global-set-key (quote [f6]) 'untabify)
(global-set-key (quote [f7]) 'tabify)
(global-set-key (quote [f8]) 'toggle-truncate-lines)
(global-set-key (quote [f9]) 'run-current-file)
(global-set-key (quote [f10]) 'show-ws-toggle-show-tabs)
(global-set-key (quote [f12]) 'deft)
(global-set-key "\C-co" 'other-frame)
;; (require 'magit)
;; (autoload 'magit-status "magit" nil t)
;; (global-set-key "\M-ss" 'magit-status)
;; (global-set-key "\M-sb" 'magit-show-branches)
(require 'deft)
(setq deft-extension "txt")
(setq deft-directory "~/.deft")
(setq deft-text-mode 'markdown-mode)
;; python mode
(add-to-list 'load-path "/home/morpheus/emacs-lisp/python-mode/")
(setq py-install-directory "/home/morpheus/emacs-lisp/python-mode/")
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-to-list 'auto-mode-alist '("\\.pyx\\'" . python-mode))
(require 'ipython)
(setq py-shell-name "ipython")
(require 'lambda-mode)
(add-hook 'python-mode-hook #'lambda-mode 1)
(setq lambda-symbol (string (make-char 'greek-iso8859-7 107)))
;; (require 'anything-ipython)
;; (when (require 'anything-show-completion nil t)
;; (use-anything-show-completion 'anything-ipython-complete
;; '(length initial-pattern)))
;; pylookup
(setq pylookup-dir "~/emacs-lisp/pylookup/")
(add-to-list 'load-path pylookup-dir)
;; load pylookup when compile time
(eval-when-compile (require 'pylookup))
;; set executable file and db file
(setq pylookup-program (concat pylookup-dir "/pylookup.py"))
(setq pylookup-db-file (concat pylookup-dir "/pylookup.db"))
;; to speedup, just load it on demand
(autoload 'pylookup-lookup "pylookup"
"Lookup SEARCH-TERM in the Python HTML indexes." t)
(autoload 'pylookup-update "pylookup"
"Run pylookup-update and create the database at `pylookup-db-file'." t)
(global-set-key "\C-ch" 'pylookup-lookup)
;; autopair
(autoload 'autopair-global-mode "autopair" nil t)
(autopair-global-mode)
(add-hook 'lisp-mode-hook #'(lambda () (setq autopair-dont-activate t)))
(add-hook 'python-mode-hook
#'(lambda () (push '(?' . ?')
(getf autopair-extra-pairs :code))
(setq autopair-handle-action-fns
(list #'autopair-default-handle-action
#'autopair-python-triple-quote-action))))
(require 'python-pep8)
(require 'python-pylint)
;; RST
(require 'rst)
(setq auto-mode-alist
(append '(("\\.txt$" . rst-mode)
("\\.rst$" . rst-mode)
("\\.rest$" . rst-mode)) auto-mode-alist))
;; golang
(require 'go-mode)
(setq gofmt-command "goimports")
(add-hook 'before-save-hook 'gofmt-before-save)
(setq auto-mode-alist
(append '(("\\.go$" . go-mode)) auto-mode-alist))
;; (add-to-list 'load-path "~/data/dev/go/src/github.com/dougm/goflymake")
;; (require 'go-flymake)
;; ack(-grep)
(require 'ack-and-a-half)
;; Create shorter aliases
(defalias 'ack 'ack-and-a-half)
(defalias 'ack-same 'ack-and-a-half-same)
(defalias 'ack-find-file 'ack-and-a-half-find-file)
(defalias 'ack-find-file-same 'ack-and-a-half-find-file-same)
;; (setq ack-executable (executable-find “ack-grep”))
(put 'upcase-region 'disabled nil)
;; ace jump
;; (add-to-list 'load-path "/full/path/where/ace-jump-mode.el/in/")
(autoload
'ace-jump-mode
"ace-jump-mode"
"Emacs quick move minor mode"
t)
;; you can select the key you prefer to
(define-key global-map (kbd "C-c s") 'ace-jump-mode)
;;
;; enable a more powerful jump back function from ace jump mode
;;
(autoload
'ace-jump-mode-pop-mark
"ace-jump-mode"
"Ace jump back:-)"
t)
(eval-after-load "ace-jump-mode"
'(ace-jump-mode-enable-mark-sync))
(define-key global-map (kbd "C-c C-c s") 'ace-jump-mode-pop-mark)
;; markdown
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
;; start server
(server-start)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Auto complete
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'auto-complete)
(require 'auto-complete-config)
(require 'auto-complete-nxml)
(add-to-list 'ac-dictionary-directories
"~/.emacs.d/auto-complete/dict"
)
(ac-config-default)
(ac-flyspell-workaround)
(setq ac-delay 0.1
ac-auto-start 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SQL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'sql-interactive-mode-hook
'(lambda ()
(auto-complete-mode)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Java
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (load "~/.emacs.d/java.el")
(require 'auto-complete-config)
(ac-config-default)
(require 'cedet)
(require 'semantic)
(load "semantic/loaddefs.el")
(semantic-mode 1);;
(require 'malabar-mode)
(add-to-list 'auto-mode-alist '("\\.java\\'" . malabar-mode))
(define-key malabar-mode-map (kbd "\C-c \C-v u") 'malabar-update-package)
(define-key malabar-mode-map (kbd "\C-c \C-v o") 'malabar-import-one-class)
(define-key malabar-mode-map (kbd "\C-c \C-v O") 'malabar-import-all)
;; ctags
(setq tags-revert-without-query t)
(global-set-key (kbd "<f7>") 'ctags-create-or-update-tags-table)
(require 'ctags)
(require 'expand-region)
(global-set-key (kbd "C-@") 'er/expand-region)
;; yaml
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
;; (add-hook 'yaml-mode-hook
;; '(lambda ()
;; (define-key yaml-mode-map "\C-m" 'newline-and-indent)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment