Skip to content

Instantly share code, notes, and snippets.

@freakhill freakhill/.gitignore
Last active Dec 24, 2016

What would you like to do?
emacs init script
;; This file is automatically generated by the multiple-cursors extension.
;; It keeps track of your preferences for running commands with multiple cursors.
(setq mc/cmds-to-run-for-all
(setq mc/cmds-to-run-once
(source gnu)
(source melpa)
(source "sayid" "")
(depends-on "cask")
;; --- themes
(depends-on "color-theme")
(depends-on "monokai-theme")
(depends-on "zenburn-theme")
;; --- mode line
(depends-on "smart-mode-line")
(depends-on "smart-mode-line-powerline-theme")
;; --- evil
(depends-on "evil")
(depends-on "god-mode")
(depends-on "evil-terminal-cursor-changer")
(depends-on "evil-numbers")
(depends-on "evil-surround")
(depends-on "evil-god-state")
(depends-on "evil-multiedit")
(depends-on "evil-magit")
(depends-on "evil-matchit")
(depends-on "evil-exchange")
(depends-on "evil-lispy" :git "")
;; --- completion
;;(depends-on "auto-complete")
(depends-on "company")
(depends-on "browse-kill-ring")
(depends-on "bbyac")
(depends-on "guide-key")
;; --- flycheck
(depends-on "flycheck-clojure")
(depends-on "flycheck-pos-tip")
;; --- projectile
(depends-on "org-projectile")
;; --- git
(depends-on "git-gutter-fringe")
(depends-on "git-timemachine")
(depends-on "git-messenger")
;; --- ace
(depends-on "ace-jump-buffer")
;; --- irc
(depends-on "rcirc")
(depends-on "rcirc-color")
(depends-on "rainbow-delimiters")
;; --- helm
(depends-on "helm")
(depends-on "helm-ag")
(depends-on "helm-make")
(depends-on "helm-swoop")
(depends-on "helm-themes")
(depends-on "helm-projectile")
(depends-on "helm-mode-manager")
;; --- clojure
(depends-on "clojure-mode")
(depends-on "clojure-mode-extra-font-locking")
(depends-on "cider")
(depends-on "cider-profile")
(depends-on "clj-refactor")
(depends-on "align-cljlet")
(depends-on "ac-cider")
(depends-on "helm-cider")
(depends-on "sayid")
;; --- racket
(depends-on "racket-mode")
;; --- groovy (jenkinsfile)
(depends-on "groovy-mode")
;; --- rust
(depends-on "rust-mode")
(depends-on "toml-mode")
(depends-on "racer") ;; cargo install racer
;; --- c#
(depends-on "csharp-mode")
(depends-on "omnisharp")
;; --- c/c++
(depends-on "irony")
(depends-on "company-irony")
(depends-on "irony-eldoc")
;; --- haskell
(depends-on "haskell-mode")
;; --- android
(depends-on "android-mode")
;; --- markdown
(depends-on "markdown-mode")
(depends-on "markdown-preview-eww") ;; requires "gem install redcarpet"
;; --- AsciiDoc
(depends-on "adoc-mode") ;; gem install asciidoctor (not required)
;; --- various stuff
(depends-on "projectile")
(depends-on "dockerfile-mode") ;;
(depends-on "shell-pop") ;; display and hide a shell
(depends-on "discover-my-major") ;;
(depends-on "ido-ubiquitous") ;;
(depends-on "flx-ido") ;;
(depends-on "ibuffer-vc") ;;
(depends-on "dired+") ;;
(depends-on "fancy-narrow") ;;
(depends-on "epl") ;;
(depends-on "pkg-info") ;;
(depends-on "undo-tree") ;; undo tree
(depends-on "clipmon") ;; clipboard monitor
(depends-on "fill-column-indicator") ;;
(depends-on "restclient") ;; rest client
(depends-on "json-reformat") ;; json reformatter
(depends-on "buffer-move") ;;
(depends-on "vlf") ;;
(depends-on "diff-hl") ;;
(depends-on "grizzl") ;;
(depends-on "vkill") ;; view and kill Unix processes
(depends-on "rich-minority") ;; hide/highlists list of minor modes
(depends-on "highlight") ;;
(depends-on "hl-anything") ;;
(depends-on "framesize") ;;
(depends-on "window-numbering") ;;
(depends-on "elmacro") ;; save macros as emacs lisp
(depends-on "tiny") ;; generates linear ranges
(depends-on "deft") ;; quicknote tool sync through my dropbox
(depends-on "bind-key")
(depends-on "dash")
(depends-on "drag-stuff")
(depends-on "exec-path-from-shell")
(depends-on "f")
(depends-on "flycheck")
(depends-on "flycheck-cask")
(depends-on "htmlize")
(depends-on "idle-highlight-mode")
(depends-on "nyan-mode")
(depends-on "popwin")
(depends-on "prodigy")
(depends-on "projectile")
(depends-on "s")
(depends-on "smex")
(depends-on "use-package")
(depends-on "web-mode")
(depends-on "auto-yasnippet")
(depends-on "find-file-in-project")
(depends-on "avy")
(depends-on "vimish-fold")
(depends-on "ripgrep")
(depends-on "polymode")
Set oShell = CreateObject ("Wscript.Shell")
Dim strArgs
strArgs = "cmd /c" & chr(34) & "C:/ProgramData/chocolatey/bin/emacsclientw.exe -c -f C:/Users/jp11629.LINECORP/.emacs.d/server/server -na C:/Users/jp11629.LINECORP/.emacs.d/emacsserver.bat"
oShell.Run strArgs, 0, false
cmd /k "C:\bin\cmder\vendor\init.bat & runemacs.exe & exit"
; -*- coding: utf-8-unix -*-
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;; 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.
["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
'(custom-enabled-themes (quote (tango-dark)))
("3c83b3676d796422704082049fc38b6966bcad960f896669dfc21a7a37a748fa" "26614652a4b3515b4bbbb9828d71e206cc249b67c9142c06239ed3418eff95e2" "f0b0710b7e1260ead8f7808b3ee13c3bb38d45564e369cbe15fc6d312f0cd7a0" "a27c00821ccfd5a78b01e4f35dc056706dd9ede09a8b90c6955ae6a390eb1c1e" "e56f1b1c1daec5dbddc50abd00fcd00f6ce4079f4a7f66052cf16d96412a09a9" "b71d5d49d0b9611c0afce5c6237aacab4f1775b74e513d8ba36ab67dfab35e5a" "756597b162f1be60a12dbd52bab71d40d6a2845a3e3c2584c6573ee9c332a66e" "cdc7555f0b34ed32eb510be295b6b967526dd8060e5d04ff0dce719af789f8e5" "6a37be365d1d95fad2f4d185e51928c789ef7a4ccf17e7ca13ad63a8bf5b922f" default)))
'(flycheck-display-errors-function (function flycheck-pos-tip-error-messages))
'(global-ede-mode t)
'(inhibit-startup-screen t)
(sayid markdown-mode+ polymode yaml-mode zenburn-theme window-numbering web-mode vlf vkill vimish-fold use-package toml-mode tiny smex smart-mode-line-powerline-theme slamhound shell-pop restclient rcirc-color rainbow-delimiters racket-mode racer prodigy org-projectile omnisharp nyan-mode monokai-theme markdown-preview-eww markdown-mode json-reformat irony-eldoc ido-ubiquitous idle-highlight-mode ibuffer-vc htmlize hl-anything highlight helm-themes helm-swoop helm-projectile helm-mode-manager helm-make helm-cider helm-ag haskell-mode guide-key groovy-mode grizzl git-timemachine git-messenger git-gutter-fringe framesize flycheck-pos-tip flycheck-clojure flycheck-cask flx-ido find-file-in-project fill-column-indicator fancy-narrow exec-path-from-shell evil-terminal-cursor-changer evil-surround evil-numbers evil-multiedit evil-matchit evil-magit evil-lispy evil-god-state evil-exchange elmacro drag-stuff dockerfile-mode discover-my-major dired+ diff-hl deft company-irony color-theme clojure-mode-extra-font-locking clj-refactor clipmon cider-profile cask buffer-move bbyac auto-yasnippet android-mode align-cljlet adoc-mode ace-jump-buffer ac-cider)))
'(safe-local-variable-values (quote ((c-basic-indent . 4))))
'(semantic-mode t)
'(uniquify-buffer-name-style (quote post-forward-angle-brackets) nil (uniquify)))
;; 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.
'(diff-added ((t (:foreground "Green"))))
'(diff-removed ((t (:foreground "Red"))))
'(ediff-even-diff-A ((((class color) (background dark)) (:background "dark green"))))
'(ediff-even-diff-B ((((class color) (background dark)) (:background "dark red"))))
'(ediff-odd-diff-A ((((class color) (background dark)) (:background "dark green"))))
'(ediff-odd-diff-B ((((class color) (background dark)) (:background "dark red"))))
'(mumamo-background-chunk-major ((((class color) (background dark)) (:background "black"))) t)
'(mumamo-background-chunk-submode1 ((((class color) (background dark)) (:background "black"))) t)
'(shm-current-face ((t (:background "green" :foreground "black"))) t)
'(shm-quarantine-face ((t (:background "yellow"))) t))
;;--- for emacs 24+ --
(defun my-ensure-dir (d)
(unless (file-exists-p d)
(make-directory d)))
(defvar my-save-dir "~/.emacs.d/save")
(defvar my-temp-dir "~/.emacs.d/tmp")
(defvar my-irony-dir "~/.emacs.d/irony")
(defun my-ensure-save-dir ()
(my-ensure-dir my-save-dir))
(defun my-ensure-irony-dir ()
(my-ensure-dir my-irony-dir))
(defun my-ensure-temp-dir ()
(my-ensure-dir my-temp-dir))
(defun my-basic-init ()
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(setq inhibit-startup-message t)
(setq inhibit-startup-echo-area-message t)
(put 'narrow-to-region 'disabled nil)
(blink-cursor-mode -1)
(setq scroll-margin 0
scroll-conservatively 100000
scroll-preserve-screen-position 1)
(defalias 'yes-or-no-p 'y-or-n-p)
(show-paren-mode t)
(semantic-mode t)
(setq large-file-warning-threshold 100000000)
(defconst backup-dir "~/.backups")
(my-ensure-dir backup-dir)
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
make-backup-files t
backup-by-copying t
version-control t
delete-old-versions t
kept-old-versions 6
kept-new-versions 9
auto-save-default t
auto-save-timeout 20
auto-save-interval 200)
dired-recursive-copies 'always
dired-recursive-deletes 'top
dired-listing-switches "-lha")
(add-hook 'dired-mode-hook #'auto-revert-mode)
(setq c-basic-indent 2)
(setq tab-width 4)
(setq indent-tabs-mode nil)
(global-set-key (kbd "C-l") 'goto-line)
(define-key global-map (kbd "RET") 'reindent-then-newline-and-indent)
(setq uniquify-buffer-name-style 'forward)
(setq uniquify-separator "/")
(setq uniquify-after-kill-buffer-p t)
(setq uniquify-ignore-buffers-re "^\\*")
(setq initial-major-mode 'lisp-interaction-mode
redisplay-dont-pause t
column-number-mode t
echo-keystrokes 0.02
inhibit-startup-message t
transient-mark-mode t
shift-select-mode nil
require-final-newline t
truncate-partial-width-windows nil
delete-by-moving-to-trash nil
confirm-nonexistent-file-or-buffer nil
query-replace-highlight t
next-error-highlight t
next-error-highlight-no-select t)
;;set all coding systems to utf-8-unix
(prefer-coding-system 'utf-8)
(setq coding-system-for-read 'utf-8)
(setq coding-system-for-write 'utf-8)
(set-language-environment 'UTF-8) ; prefer utf-8 for language settings
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
(prefer-coding-system 'utf-8)
(setq buffer-file-coding-system 'utf-8-unix)
(setq default-file-name-coding-system 'utf-8-unix)
(setq default-keyboard-coding-system 'utf-8-unix)
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))
(setq default-sendmail-coding-system 'utf-8-unix)
(setq default-terminal-coding-system 'utf-8-unix)
(set-default 'indent-tabs-mode nil)
(auto-compression-mode t)
(show-paren-mode 1)
;; make emacs use the clipboard
(setq x-select-enable-clipboard t)
;;remove all trailing whitespace and trailing blank lines before
;;saving the file
(defvar live-ignore-whitespace-modes '(markdown-mode))
(defun live-cleanup-whitespace ()
(if (not (member major-mode live-ignore-whitespace-modes))
(let ((whitespace-style '(trailing empty)) )
(add-hook 'before-save-hook #'live-cleanup-whitespace)
;; savehist keeps track of some history
(setq savehist-additional-variables
;; search entries
'(search ring regexp-search-ring)
;; save every minute
savehist-autosave-interval 60
;; keep the home clean
savehist-file (concat my-temp-dir "savehist"))
(savehist-mode t)
(require 'midnight)
(require 'saveplace)
(setq-default save-place t)
;; recompile binding
(global-set-key (kbd "<f8>") #'recompile)
;; C-x r j i -- to edit my init file
;; C-x r j c -- to edit my cask file
(setq user-cask-init-file
(expand-file-name "Cask" (file-name-directory user-init-file)))
(set-register ?c `(file . ,user-cask-init-file))
(set-register ?i `(file . ,user-init-file)))
(defun my-load-extra-files ()
((dl-dir "~/.emacs.d/dl")
(ac-dict-dir "~/.emacs.d/ac-dict")
(dl-and-load (lambda (dir url filename &optional module-name)
(let ((filename (concat dir "/" filename))
(message (concat "loat extra file: " filename)))
(unless (file-exists-p filename)
(url-copy-file url filename))
(when module-name
(if (symbolp module-name)
(require module-name)
(load module-name))))))
(dl-and-load-mode (lambda (&rest r) (apply dl-and-load (cons dl-dir r))))
(dl-and-load-ac-dict (lambda (&rest r) (apply dl-and-load (cons ac-dict-dir r)))))
(my-ensure-dir dl-dir)
(my-ensure-dir ac-dict-dir)
(add-to-list 'load-path dl-dir)
(-each ;; packages
(lambda (pkg)
(condition-case e
(apply dl-and-load-mode pkg)
((debug error) e))))
(-each ;; ac-dict dictionaries
(lambda (dict) (condition-case e
(apply dl-and-load-ac-dict dict)
((debug-error) e))))))
(defun my-tramp ()
(setq tramp-default-method "ssh")
(setq tramp-default-proxies-alist
'(("\\.nhnjp\\.ism" nil "/ssh:kerberos:"))))
(defun my-discover-my-major ()
(define-key 'help-command (kbd "C-m") 'discover-my-major))
(defun my-buffer-move ()
(global-set-key (kbd "C-c <up>") 'buf-move-up)
(global-set-key (kbd "C-c <down>") 'buf-move-down)
(global-set-key (kbd "C-c <left>") 'buf-move-left)
(global-set-key (kbd "C-c <right>") 'buf-move-right))
(defun my-evil ()
;; C-z switches between modes (states in evil parlance)
(setq evil-mode-line-format 'before)
(setq evil-emacs-state-cursor '("red" box))
(setq evil-normal-state-custor '("gray" box))
(setq evil-visual-state-cursor '("gray" box))
(setq evil-insert-state-cursor '("gray" bar))
(setq evil-motion-state-cursor '("gray" box))
(evil-mode 1)
(evil-define-key 'normal global-map "," 'evil-execute-in-god-state)
(evil-define-key 'normal global-map (kbd "M") 'evil-goto-mark-line))
(defun my-evil-numbers ()
(global-set-key (kbd "C-c +") 'evil-numbers/inc-at-pt)
(global-set-key (kbd "C-c -") 'evil-numbers/dec-at-pt))
(defun my-evil-surround ()
(require 'evil-surround)
(global-evil-surround-mode 1))
(defun my-evil-mc ()
;; "gru" remove all cursors
;; C-n C-p add cursor
;; M-n M-p cycle thorugh cursor
;; C-t skip cursor
;;(require 'evil-mc)
;;(global-evil-mc-mode 1)
(defun my-evil-matchit ()
(require 'evil-matchit)
;; use "%" to travel through matching syntax elements
(global-evil-matchit-mode 1))
(defun my-evil-exchange ()
(require 'evil-exchange)
(defun my-evil-magit ()
(require 'evil-magit))
(defun my-magit ()
(setq magit-last-seen-setup-instructions "1.4.0")
(add-hook 'magit-log-edit-mode-hook
(lambda ()
(set-fill-column 72)
(auto-fill-mode 1)))
;; ,cgs in god-mode
(global-set-key (kbd "C-c s") 'magit-status))
(defun my-modeline ()
(require 'rich-minority)
(require 'smart-mode-line)
;;(sml/apply-theme 'powerline)
(setq sml/shorten-modes t
sml/shorten-directory t)
(add-to-list 'rm-blacklist '("SkelC" "UndoTree" "Projectile.*" "AC" "SP" "SP/s" "ht"))
(defun my-bbyac ()
(require 'bbyac)
(bbyac-global-mode 1))
(defun my-avy ()
(define-key evil-motion-state-map (kbd "SPC") #'avy-goto-word-1)
(define-key evil-motion-state-map (kbd "C-SPC") #'avy-goto-char-2)
(define-key evil-normal-state-map (kbd "SPC") #'avy-goto-word-1))
(defun my-vimish-fold ()
(vimish-fold-global-mode 1)
(define-key evil-visual-state-map (kbd "C-f") #'vimish-fold)
(define-key evil-normal-state-map (kbd "C-f") #'vimish-fold-toggle)
(define-key evil-normal-state-map (kbd "M-f") #'vimish-fold-delete))
(defun my-ace-jump-buffer ()
(define-key evil-normal-state-map "b" 'ace-jump-buffer))
(defun my-help-swoop ()
(define-key evil-normal-state-map "s" 'helm-swoop))
(defun my-window-numbering ()
(window-numbering-mode t)
(setq window-numbering-assign-func
(lambda () (when (equal (buffer-name) "*scratch*") 0))))
(defun my-mouse ()
;; Mouse in terminal
(require 'mouse)
;; mouse mode must be initialised for each new terminal
;; see
(defun initialise-mouse-mode (&optional frame)
"Initialise mouse mode for the current terminal."
(if (not frame) ;; The initial call.
(xterm-mouse-mode 1)
;; Otherwise called via after-make-frame-functions.
(if xterm-mouse-mode
;; Re-initialise the mode in case of a new terminal.
(xterm-mouse-mode 1))))
;; Evaluate both now (for non-daemon emacs) and upon frame creation
;; (for new terminals via emacsclient).
(add-hook 'after-make-frame-functions 'initialise-mouse-mode)
;;(setq mouse-yank-at-point t)
(global-set-key [mouse-4] '(lambda ()
(scroll-down 1)))
(global-set-key [mouse-5] '(lambda ()
(scroll-up 1))))
(defun my-nyan ()
(nyan-mode t))
(defun my-windmove ()
(when (fboundp 'windmove-default-keybindings)
(defun my-ibuffer ()
(autoload 'ibuffer "ibuffer" "List buffers." t)
(global-set-key (kbd "C-c C-b") 'ibuffer)
(setq ibuffer-use-other-window t)
(add-hook 'ibuffer-hook
(lambda () (ibuffer-vc-set-filter-groups-by-vc-root)
(unless (eq ibuffer-sorting-mode 'alphabetic)
(setq ibuffer-formats
'((mark modified read-only vc-status-mini " "
(name 18 18 :left :elide)
" "
(size 9 -1 :right)
" "
(mode 16 16 :left :elide)
" "
(vc-status 16 16 :left)
" "
(defun my-hippie ()
(global-set-key "\M- " 'hippie-expand)
(setq hippie-expand-try-functions-list
(defun my-auto-compile ()
(require 'auto-compile)
(auto-compile-on-load-mode 1)
(auto-compile-on-save-mode 1))
(defun my-popwin ()
(require 'popwin)
(setq display-buffer-function 'popwin:display-buffer)
(setq popwin:special-display-config
'(("*Help*" :height 30)
("*undo-tree*" :width 72 :heigth 40)
("*Completions*" :noselect t)
("*Messages*" :noselect t :height 30)
("*Apropos*" :noselect t :height 30)
("*compilation*" :noselect t)
("*Backtrace*" :height 30)
("*Messages*" :height 30)
("*HTTP Response*" :height 30)
("*Occur*" :noselect t)
("*Ido Completions*" :noselect t :height 30)
("*magit-commit*" :noselect t :height 40 :width 80 :stick t)
("*magit-diff*" :noselect t :height 40 :width 80)
("*magit-edit-log*" :noselect t :height 15 :width 80)
("\\*ansi-term\\*.*" :regexp t :height 30)
("*shell*" :height 30)
(".*overtone.log" :regexp t :height 30)
("*gists*" :height 30)
("*sldb.*":regexp t :height 30)
("*cider-error*" :height 30 :stick t)
("*cider-doc*" :height 30 :stick t)
("*cider-src*" :height 30 :stick t)
("*cider-result*" :height 30 :stick t)
("*cider-macroexpansion*" :height 30 :stick t)
("*Kill Ring*" :height 30)
("*Compile-Log*" :height 30 :stick t)
("*git-gutter:diff*" :height 30 :stick t))))
(defun my-markdown ()
;;(require 'markdown-mode)
(autoload 'markdown-mode "markdown-mode.el"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.md" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown" . markdown-mode)))
(defun my-auto-complete ()
(defconst my-ac-dict-dir "~/.emacs.d/ac-dict")
(my-ensure-dir my-ac-dict-dir)
(add-to-list 'ac-dictionary-directories my-ac-dict-dir))
(setq ac-delay 0.0)
(setq ac-use-quick-help t)
(setq ac-quick-help-delay 0.05)
(setq ac-use-fuzzy t)
(setq ac-auto-start 1)
(setq ac-auto-show-menu t)
(defun my-ido ()
(require 'ido)
(require 'ido-ubiquitous)
(require 'flx-ido)
(setq ido-enable-prefix nil
ido-enable-flex-matching t
ido-create-new-buffer 'always
ido-use-filename-at-point 'guess
ido-max-prospects 10
ido-save-directory-list-file (expand-file-name "ido.hist" my-save-dir)
ido-default-file-method 'selected-window
ido-auto-merge-work-directories-length -1)
(ido-mode +1)
(ido-ubiquitous-mode +1)
;; smarter fuzzy matching for ido
(flx-ido-mode +1)
;; disable ido faces to see flx highlights
(setq ido-use-faces nil))
(defun my-flycheck ()
(with-eval-after-load 'flycheck
(eval-after-load 'flycheck
'(flycheck-display-errors-function #'flycheck-pos-tip-error-messages)))
(add-hook 'after-init-hook #'global-flycheck-mode))
(defun my-smex ()
(require 'smex)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands))
(defun my-helm-and-projectile ()
(require 'helm)
(require 'projectile)
(require 'helm-projectile)
(defun my-open-files ()
"picked from -> mr. Renn Seo"
(if (projectile-project-p)
(global-set-key (kbd "C-x x") 'helm-M-x)
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
(global-set-key (kbd "C-c C-i") 'helm-semantic-or-imenu)
(global-set-key (kbd "C-c C-o") 'helm-occur)
(global-set-key (kbd "C-c C-r") 'helm-all-mark-rings)
(global-set-key (kbd "C-o") 'my-open-files)
(global-set-key (kbd "C-x C-f" ) 'helm-find-files)
(setq projectile-completion-system 'grizzl)
(setq projectile-show-paths-function 'projectile-hashify-with-relative-paths))
(defun my-undo-tree ()
(define-key undo-tree-map (kbd "C-/") 'undo-tree-visualize)
(global-set-key (kbd "C-c C-u") 'undo-tree-visualize))
(defun my-git-messenger ()
;; ,cgc in god-mode
(global-set-key (kbd "C-c M-c") 'git-messenger:popup-message))
(defun my-git-timemachine ()
(global-set-key (kbd "C-c M-h") 'git-timemachine))
(defun my-diff-hl ()
(add-hook 'dired-mode-hook 'diff-hl-dired-mode))
(defun my-dired+ ()
(require 'dired+)
(quote (when (eq system-type 'darwin)
(require 'ls-lisp)
(setq ls-lisp-use-insert-directory-program nil))))
(defun my-vlf ()
(require 'vlf-integrate)
(setq vlf-application 'dont-ask))
(defun my-yasnippet ()
(global-set-key (kbd "C-c C-c") 'aya-create)
(global-set-key (kbd "C-c C-v") 'aya-expand)
(evil-define-key 'insert global-map (kbd "C-<tab>") 'aya-open-line))
(defun my-guide-key ()
(guide-key-mode t)
(setq guide-key/recursive-key-sequence-flag t)
(setq guide-key/guide-key-sequence '("C-x" "C-c" "C-r")))
(defun my-android ()
((string= system-name "W010391306024")
(setq android-mode-sdk-dir "d:/adt-bundle-windows/sdk"))
((string= system-name "localhost.localdomain")
(message "go not configured for my centos vm yet..."))))
(defun my-deft ()
(setq deft-extension "org")
(setq deft-directory "~/Dropbox/notes")
(setq deft-text-mode 'org-mode)
(setq deft-use-filename-as-title t))
(defun my-history ()
;; Add history just before `find-tag' executed.
;; (add-to-list 'history-advised-before-functions 'find-tag-noselect t)
;; Add history just before `find-file' executed.
;; (add-to-list 'history-advised-before-functions 'find-file-noselect t)
(setq history-history-max 999)
(defun my-rust ()
(setq racer-cmd "/home/johan/.cargo/bin/racer")
(autoload 'rust-mode "rust-mode" nil t)
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode)
(add-hook 'racer-mode-hook #'company-mode)
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)))
(defun my-set-shell-to-bash ()
(setq shell-file-name "bash")
(setq explicit-shell-file-name shell-file-name))
(defun my-evil-multiedit ()
(require 'evil-multiedit)
;; Highlights all matches of the selection in the buffer.
(define-key evil-visual-state-map "R" 'evil-multiedit-match-all)
;; Match the word under cursor (i.e. make it an edit region). Consecutive presses will
;; incrementally add the next unmatched match.
(define-key evil-normal-state-map (kbd "M-d") 'evil-multiedit-match-and-next)
;; Match selected region.
(define-key evil-visual-state-map (kbd "M-d") 'evil-multiedit-match-and-next)
;; Same as M-d but in reverse.
(define-key evil-normal-state-map (kbd "M-D") 'evil-multiedit-match-and-prev)
(define-key evil-visual-state-map (kbd "M-D") 'evil-multiedit-match-and-prev)
;; OPTIONAL: If you prefer to grab symbols rather than words, use
;; `evil-multiedit-match-symbol-and-next` (or prev).
;; Restore the last group of multiedit regions.
(define-key evil-visual-state-map (kbd "C-M-D") 'evil-multiedit-restore)
;; RET will toggle the region under the cursor
(define-key evil-multiedit-state-map (kbd "RET") 'evil-multiedit-toggle-or-restrict-region)
;; ...and in visual mode, RET will disable all fields outside the selected region
(define-key evil-motion-state-map (kbd "RET") 'evil-multiedit-toggle-or-restrict-region)
;; For moving between edit regions
(define-key evil-multiedit-state-map (kbd "C-n") 'evil-multiedit-next)
(define-key evil-multiedit-state-map (kbd "C-p") 'evil-multiedit-prev)
(define-key evil-multiedit-insert-state-map (kbd "C-n") 'evil-multiedit-next)
(define-key evil-multiedit-insert-state-map (kbd "C-p") 'evil-multiedit-prev)
;; Ex command that allows you to invoke evil-multiedit with a regular expression, e.g.
(evil-ex-define-cmd "ie[dit]" 'evil-multiedit-ex-match))
(defun my-ruby ()
(add-hook 'ruby-mode-hook 'robe-mode)
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Thorfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.thor$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile$" . ruby-mode)))
(defun my-fill-column-indicator ()
(setq fci-rule-column 80)
(defun my-fci-enabled-p () (symbol-value 'fci-mode))
(defvar my-fci-mode-suppressed nil)
(make-variable-buffer-local 'my-fci-mode-suppressed)
(defadvice popup-create (before suppress-fci-mode activate)
"Suspend fci-mode while popups are visible"
(let ((fci-enabled (my-fci-enabled-p)))
(when fci-enabled
(setq my-fci-mode-suppressed fci-enabled)
(defadvice popup-delete (after restore-fci-mode activate)
"Restore fci-mode when all popups have closed"
(when (and my-fci-mode-suppressed
(null popup-instances))
(setq my-fci-mode-suppressed nil)
(add-hook 'prog-mode-hook (lambda () (fci-mode t))))
(defvar my-lisp-minor-mode-map
(let ((map (make-sparse-keymap)))
"Keymap used for `mylisp-minor-mode'.")
(define-minor-mode my-lisp-minor-mode
"My custom made lisp minor mode."
:init-value nil
:lighter " mylisp"
:group 'my-modes
:keymap my-lisp-minor-mode-map
(require 'evil-lispy)
(evil-lispy-mode t)
(rainbow-delimiters-mode t)
(hs-minor-mode t)))
(defun my-clojure-custom ()
(require 'clojure-mode-extra-font-locking)
(require 'clj-refactor)
(require 'icomplete) ;; for cider minibuffer completion
;;(eval-after-load 'flycheck '(flycheck-clojure-setup))
(clj-refactor-mode 1)
(yas-minor-mode 1)
(helm-cider-mode 1)
(flycheck-mode t)
(cljr-add-keybindings-with-prefix "C-r")
(setq clrj-warn-on-eval nil)
;;(setq cider-repl-use-pretty-printing t)
;;(setq cider-repl-display-help-banner nil)
;;(setq cider-cljs-lein-repl "(do (use 'figwheel-sidecar.repl-api) (start-figwheel!) (cljs-repl))")
(local-set-key (kbd "C-c C-a") 'align-cljlet)
(local-set-key (kbd "C-h C-h") 'hydra-cljr-help-menu/body)
;; remove the cider bind that overshadows the git messenger bind
(local-unset-key (kbd "C-c M-c")))
(defun my-lisp ()
(dolist (h '(clojure-mode-hook
(add-hook h #'my-lisp-minor-mode))
(dolist (h '(clojure-mode-hook
(add-hook h 'my-clojure-custom))
;;--- cider
(add-hook 'cider-mode-hook #'company-mode)
(add-hook 'cider-repl-mode-hook #'company-mode)
(add-hook 'cider-repl-mode-hook #'subword-mode)
(add-hook 'cider-mode-hook #'eldoc-mode)
(setq cider-repl-use-clojure-font-lock t)
(setq cider-repl-tab-command #'indent-for-tab-command)
(setq cider-prefer-local-resources t)
(setq nrepl-log-messages t)
(setq nrepl-hide-special-buffers t
nrepl-popup-stacktraces-in-repl t
nrepl-history-file "~/nrepl-history.dat")
(add-to-list 'auto-mode-alist '("\\.boot$" . clojure-mode)))
(defun my-rtags ()
((string-match "darwin" system-configuration)
(message "rtags for MacOS")
(load-file "~/rtags/src/rtags.el")
(load-file "~/rtags/src/company-rtags.el")
;;(load-file "~/rtags/src/flycheck-rtags.el")
(rtags-enable-standard-keybindings c-mode-base-map)
(setq rtags-autostart-diagnostic t
rtags-completion-enabled t
rtags-path "~/rtags/bin"))
((string-match "linux" system-configuration)
(message "no rtags for Linux yet"))
((string-match "i686-pc-mingw32" system-configuration)
(message "no rtags for Win 7 yet"))
((string-match "nt6" system-configuration)
(message "no rtags for Win 7 yet"))))
(defun my-compilation-buffer ()
(require 'ansi-color)
(setq compilation-scroll-output 'first-error)
(add-hook 'compilation-filter-hook
(lambda ()
(ansi-color-apply-on-region compilation-filter-start (point))
(defun my-racket ()
(add-to-list 'auto-mode-alist '("\\.rkt$" . racket-mode))
((string= system-name "W010391306024")
(setq racket-racket-program "d:/Racket/Racket.exe"
racket-raco-program "d:/Racket/raco.exe")))
((string= system-name "i022311303784m.local")
(setq racket-racket-program "/usr/local/bin/racket"
racket-raco-program "/usr/local/bin/raco")))
((string= system-name "jojovm")
(setq racket-racket-program "/usr/bin/racket"
racket-raco-program "/usr/bin/raco")))))
(defun my-fancy-narrow ()
(define-key evil-visual-state-map (kbd "n") #'fancy-narrow-to-region)
(define-key evil-normal-state-map (kbd "g r w") #'fancy-widen))
(defun my-csharp ()
(autoload 'csharp-mode "csharp-mode" "Major mode for editing C# code." t)
(setq auto-mode-alist
(append '(("\\.cs$" . csharp-mode)) auto-mode-alist))
(add-hook 'csharp-mode-hook #'omnisharp-mode)
(eval-after-load 'company-css '(add-to-list 'company-backends 'company-omnisharp)))
(defun my-shell-pop ()
(global-set-key (kbd "<f9>") 'shell-pop))
(defun my-asciidoc ()
(autoload 'adoc-mode "adoc-mode" nil t)
(add-to-list 'auto-mode-alist (cons "\\.txt\\'" 'adoc-mode)))
(defun my-groovy ()
(autoload 'groovy-mode "groovy-mode" nil t)
(add-to-list 'auto-mode-alist (cons "\\Jenkinsfile\\'" 'groovy-mode)))
(defun my-capnp ()
(add-to-list 'auto-mode-alist '("\\.capnp\\'" . capnp-mode)))
(defun my-polymodes ()
(require 'polymode)
(defcustom pm-host/C++
(pm-bchunkmode "C++"
:mode 'c++-mode)
"C++ host chunkmode"
:group 'hostmodes
:type 'object)
(defcustom pm-inner/Org
(pm-hbtchunkmode "Org"
:mode 'org-mode
:head-reg "^[ \t]*/\\*\\*org$"
:tail-reg "^[ \t]*org\\*/$"
:font-lock-narrow t)
"Org inner chunk"
:group 'innermodes
:type 'object)
(defcustom pm-inner/Markdown
(pm-hbtchunkmode "Markdown"
:mode 'markdown-mode
:head-reg "^[ \t]*/\\*\\*md[ \t]+"
:tail-reg ".*md\\*/$"
:font-lock-narrow t)
"Org inner chunk"
:group 'innermodes
:type 'object)
(defcustom pm-poly/c++doc
(pm-polymode-multi "c++doc"
:hostmode 'pm-host/C++
:innermodes '(pm-inner/Org
"C++ & Org polymode."
:group 'polymodes
:type 'object)
(define-polymode poly-c++doc pm-poly/c++doc))
(defun my-os-custom ()
;;--- set firefox as browser
;;(setq browse-url-browser-function 'browse-url-generic
;; browse-url-generic-program "firefox")
;; fix it to be multiplatform
(defun my-swap-meta-and-super ()
"picked from emacs prelude"
(if (eq mac-command-modifier 'super)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'super)
(message "Command is now bound to META and Option is bound to SUPER."))
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'super)
(message "Command is now bound to SUPER and Option is bound to META."))))
(defun my-macos-custom ()
;;(require 'exec-path-from-shell)
(setq ns-function-modifier 'hyper)
(autoload 'vkill "vkill" nil t)
(setq dired-listing-switches "-lha --group-directories-first")
;; from prelude, proced mode doesnt work on macos
(global-set-key (kbd "C-x p") 'vkill)
(global-set-key (kbd "s-/") 'hippie-expand)
(global-set-key (kbd "C-c w") 'my-swap-meta-and-super)
;; Work around a bug on OS X where system-name is a fully qualified
;; domain name
;; (setq system-name (car (split-string system-name "\\.")))
;; Ignore .DS_Store files with ido mode
(setq ido-ignore-files '("\\.DS_Store"))
(switch-to-buffer "*Messages*"))
(defun my-windows-custom ()
(switch-to-buffer "*Messages*"))
(defun my-linux-custom ()
;; (server-start) ;; should use emacs --daemon
(switch-to-buffer "*Messages*")
(setq dired-listing-switches "-lha --group-directories-first")
((string-match "darwin" system-configuration)
(message "customizing GNU Emacs for MacOS")
((string-match "linux" system-configuration)
(message "customizing GNU Emacs for Linux")
((string-match "i686-pc-mingw32" system-configuration)
(message "customizing GNU Emacs for Win 7")
((string-match "nt6" system-configuration)
(message "customizing GNU Emacs for Win 7")
(defun my-cask-init ()
((string-match "darwin" system-configuration)
(require 'cask "/usr/local/share/emacs/site-lisp/cask/cask.el"))
((string-match "linux" system-configuration)
(require 'cask "~/.cask/cask.el"))
((string-match "i686-pc-mingw32" system-configuration)
(require 'cask "~/.cask/cask.el"))
((string-match "nt6" system-configuration)
(require 'cask "~/.cask/cask.el")))
(defun my-funcs ()
;; ---
(defun copy-to-clipboard ()
(if (region-active-p)
;; my clipboard manager only intercept CLIPBOARD
(shell-command-on-region (region-beginning) (region-end)
((eq system-type 'cygwin) "putclip")
((eq system-type 'darwin) "pbcopy")
(t "xsel -ib")))
(message "Yanked region to clipboard!")
(message "No region active; can't yank to clipboard!")))
;; ---
(defun paste-from-clipboard()
((eq system-type 'cygwin) "getclip")
((eq system-type 'darwin) "pbpaste")
(t "xsel -ob"))
;; ---
(defun myfn-eval-last-sexp-with-value (value &optional prefix)
(interactive "svalue: \nP")
(cider-interactive-eval (s-concat "(" (cider-last-sexp) " " value " )")
(when prefix (cider-eval-print-handler))))
(add-hook 'cider-mode-hook (lambda () (define-key cider-mode-map (kbd "C-c e") 'myfn-eval-last-sexp-with-value)))
;; ---
(defun myfn-delete-region-if-uniq ()
(setq deactivate-mark t)
(let ((p1 (region-beginning))
(p2 (region-end)))
(if (= 1 (count-matches (buffer-substring p1 p2)))
(delete-region p1 p2)
(message "deleted region.")))
(message "not unique!"))))
;; ---
(defun myfn-narrow-indirect (start end)
(interactive "r")
(let ((buf (clone-indirect-buffer nil nil)))
(with-current-buffer buf
(narrow-to-region start end)
(switch-to-buffer buf))))
(global-set-key (kbd "C-x n i") 'myfn-narrow-indirect))
(defmacro my-wordy (&rest prog)
(cons 'progn
(-mapcat (lambda (sexp)
(list (list 'message "running %s..." (list 'quote sexp))
(defun my-init()
;; -- getting external packages
(message "PACKAGE LOADING!")
;; little library for following code
(require 'dash)
;; --------------------------------------
;; -- Base
;; --------------------------------------
;; --------------------------------------
;; -- configuring global packages
;; --------------------------------------
;; --------------------------------------
;; -- configuring ide packages
;; --------------------------------------
;; --------------------------------------
;; other
;; --------------------------------------

This comment has been minimized.

Copy link

vermiculus commented Jan 6, 2016

Most of the places you use progn don't actually need it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.