Last active
March 10, 2016 05:56
-
-
Save zoon/a40c617350f0402a74ba to your computer and use it in GitHub Desktop.
my dot emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; ver <2016-03-10 08:55AM> | |
(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. | |
'(blink-cursor-mode nil) | |
'(browse-url-browser-function (quote browse-url-default-windows-browser)) | |
'(column-number-mode t) | |
'(current-language-environment "UTF-8") | |
'(custom-enabled-themes (quote (tango-dark))) | |
'(debug-on-error t) | |
'(delete-by-moving-to-trash t) | |
'(dired-listing-switches "-alo") | |
'(dired-recursive-copies (quote top)) | |
'(dired-recursive-deletes (quote top)) | |
'(go-mode-hook (quote (flycheck-mode)) t) | |
'(go-play-browse-function (quote browse-url)) | |
'(hippie-expand-try-functions-list | |
(quote | |
(try-expand-dabbrev-visible try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-expand-line try-complete-lisp-symbol-partially try-complete-lisp-symbol try-complete-file-name-partially try-complete-file-name))) | |
'(indicate-buffer-boundaries (quote right)) | |
'(indicate-empty-lines t) | |
'(ls-lisp-dirs-first t) | |
'(markdown-command "multimarkdown") | |
'(package-selected-packages | |
(quote | |
(cl-lib dash epl markdown-mode pkg-info popup swbuff websocket swap-buffers anti-zenburn-theme go-autocomplete auto-complete zenburn-theme pt buttercup flycheck go-mode))) | |
'(scroll-bar-mode nil) | |
'(show-paren-mode t) | |
'(show-paren-style (quote expression)) | |
'(show-trailing-whitespace nil) | |
'(size-indication-mode t) | |
'(tab-width 4) | |
'(tool-bar-mode nil) | |
'(truncate-lines t) | |
'(uniquify-buffer-name-style (quote forward) nil (uniquify))) | |
(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. | |
'(default ((t (:family "Consolas" :foundry "outline" :slant normal :weight normal :height 120 :width normal))))) | |
;;----------------------------------------------------------------------; | |
;; PRELUDE ; | |
;;----------------------------------------------------------------------; | |
(progn | |
(setq view-read-only t) | |
(setq-default | |
frame-title-format "%f") | |
;; some importatnt settings for terminal mode | |
(if (not window-system) | |
(progn | |
(menu-bar-mode nil) | |
(setq show-paren-style 'parenthesis))) | |
(setenv "PATH" (concat "c:\\dev\\Git1\\bin;" (getenv "PATH"))) | |
(setq exec-path (cons "c:/dev/Git1/bin" exec-path)) | |
(setq ring-bell-function 'ignore) | |
(setq inhibit-startup-screen t) | |
(defalias 'yes-or-no-p 'y-or-n-p) | |
;; lf everywhere | |
(setq default-buffer-file-coding-system 'utf-8-unix) | |
;; trailing whitespace | |
(add-hook 'before-save-hook 'delete-trailing-whitespace) | |
;; (menu-bar-mode -1) | |
(when (fboundp 'tool-bar-mode) | |
(tool-bar-mode -1)) | |
(when (fboundp 'scroll-bar-mode) | |
(scroll-bar-mode -1)) | |
(require 'uniquify) | |
(setq uniquify-buffer-name-style 'forward) | |
(require 'saveplace) | |
(setq-default save-place t) | |
(require 'winner) | |
(winner-mode 1) | |
;;-----------------------------; | |
;; Whitespace ; | |
;;-----------------------------; | |
(require 'whitespace) | |
(setq whitespace-style '(face empty tabs lines-tail trailing)) | |
;; (global-whitespace-mode t) | |
;;-----------------------------; | |
;; Global Key Unsets ; | |
;;-----------------------------; | |
;; say no yank by mouse-2 | |
(global-unset-key [(mouse-2)]) | |
(global-unset-key [(M-mouse-2)]) | |
;; disable damned insert | |
(global-unset-key [(insert)]) | |
;; disable damned iconify | |
(global-unset-key [?\C-z]) | |
;; disable mouse-save-then-kill | |
(global-unset-key [mouse-3]) | |
(global-unset-key [right-fringe mouse-3]) | |
(global-unset-key [left-fringe mouse-3]) | |
(global-unset-key [doube-mouse-3]) | |
;;-----------------------------; | |
;; CUA selection mode ; | |
;;-----------------------------; | |
(cua-selection-mode t) | |
(global-set-key (kbd "M-RET") 'cua-set-rectangle-mark) | |
;;-----------------------------; | |
;; Global Key Sets ; | |
;;-----------------------------; | |
(when (and window-system (eq system-type 'windows-nt)) | |
(global-set-key (kbd "M-<f4>") #'save-buffers-kill-emacs)) | |
(global-set-key (kbd "C-x C-k") '(lambda() (interactive) | |
(kill-buffer (current-buffer)))) | |
(global-set-key (kbd "M-/") 'hippie-expand) | |
(global-set-key (kbd "C-x C-b") 'bs-show) ;; or 'ibuffer | |
(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) | |
(global-set-key [(meta down)] 'shrink-window) | |
(global-set-key [(meta up)] 'enlarge-window) | |
(global-set-key (kbd "M-*") 'my-insert-asterisks) | |
(global-set-key (kbd "M-\"") 'my-insert-dquotes) | |
(global-set-key (kbd "M-\'") 'my-insert-quotes) | |
(global-set-key (kbd "M-{") 'my-electric-braces) | |
(global-set-key (kbd "M-[") 'my-insert-sbraces) | |
(global-set-key [?\e ?\M-a] 'auto-complete-mode) | |
(global-set-key [?\e ?\M-t] 'toggle-truncate-lines) | |
(global-set-key [?\e ?\M-r] 'revert-buffer) | |
(global-set-key [?\e ?\M-f] 'font-lock-mode) | |
(global-set-key [?\e ?\M-c] 'compilation-minor-mode) | |
(global-set-key [?\e ?\M-h] 'flycheck-mode) | |
(setq-default indent-tabs-mode nil) | |
(setq select-enable-clipboard t | |
select-enable-primary t | |
save-interprogram-paste-before-kill t | |
apropos-do-all t | |
save-place-file (concat user-emacs-directory "places") | |
backup-directory-alist `(("." . ,(concat user-emacs-directory | |
"backups"))))) | |
;;----------------------------------------------------------------------; | |
;; PACKAGES ; | |
;;----------------------------------------------------------------------; | |
;;------------------------------; | |
;; CL-LIB ; | |
;;------------------------------; | |
(require 'cl-lib) | |
;;-----------------------------; | |
;; MELPA ; | |
;;-----------------------------; | |
(require 'package) | |
(add-to-list 'package-archives | |
'("melpa" . "https://melpa.org/packages/")) | |
(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) | |
;;-----------------------------; | |
;; Small Things ; | |
;;-----------------------------; | |
(require 'swbuff-y) | |
(global-set-key (kbd "C-x C-<left>") 'swbuff-switch-to-previous-buffer) | |
(global-set-key (kbd "C-x C-<right>") 'swbuff-switch-to-next-buffer) | |
(require 'swap-buffers) | |
(global-set-key [?\e ?\M-b] 'swap-buffers) | |
;;-----------------------------; | |
;; Themes ; | |
;;-----------------------------; | |
;; (load-theme 'zenburn t) | |
;; (load-theme 'anti-zenburn t) | |
;;-----------------------------; | |
;; Yasnippet ; | |
;;-----------------------------; | |
;; (require 'yasnippet) | |
;;-----------------------------; | |
;; Autocomplete ; | |
;;-----------------------------; | |
(require 'auto-complete-config) | |
(ac-config-default) | |
(require 'go-autocomplete) | |
;;-----------------------------; | |
;; Golang ; | |
;;-----------------------------; | |
(add-hook 'go-mode-hook | |
'(lambda () | |
(setq parens-require-spaces nil) | |
(setq gofmt-command "goreturns") | |
(add-hook 'before-save-hook 'gofmt-before-save) | |
(if (not (string-match "go" compile-command)) | |
(set (make-local-variable 'compile-command) | |
"go generate && go build -v && go test -v -bench=. && go vet")) | |
(local-set-key (kbd "M-.") 'godef-jump))) | |
(add-hook 'go-mode-hook 'flycheck-mode) | |
;; golint | |
;; (add-to-list 'load-path "c:/dev/all/src/github.com/golang/lint/misc/emacs") | |
;; (require 'golint) | |
;; oracle | |
;; (add-to-list 'load-path "c:/dev/all/src/golang.org/x/tools/cmd/oracle") | |
;; (require 'go-oracle) | |
;;----------------------------------------------------------------------; | |
;; HOOKS ; | |
;;----------------------------------------------------------------------; | |
(defcustom compile-buffer-bury-timeout 3 | |
"Default timeout of compilation buffer bury" | |
:group 'zoon | |
:type 'integer | |
:safe 'inpegerp) | |
(defun bury-compile-buffer-if-successful (buffer string) | |
"Bury a compilation buffer if succeeded without warnings " | |
(if (and | |
(string-match "compilation" (buffer-name buffer)) | |
(string-match "finished" string) | |
(not | |
(with-current-buffer buffer | |
(goto-char (point-min)) | |
(search-forward "warning" nil t)))) | |
(run-with-timer compile-buffer-bury-timeout nil | |
(lambda (buf) | |
(bury-buffer buf) | |
(switch-to-prev-buffer (get-buffer-window buf) 'kill)) | |
buffer))) | |
(add-hook 'compilation-mode-hook | |
#'(lambda () (setq compilation-window-height 8))) | |
(add-hook 'compilation-finish-functions | |
'bury-compile-buffer-if-successful) | |
(add-hook 'dired-mode-hook | |
#'(lambda () (load-library "ls-lisp"))) | |
;;----------------------------------------------------------------------; | |
;; PURGATORY ; | |
;;----------------------------------------------------------------------; | |
(defun uncrfy() | |
"erase all ^M in buffer" | |
(interactive) | |
(save-excursion | |
(perform-replace " | |
" "" nil nil nil nil nil (point-min) (point-max)))) | |
(defun my-insert-pair(&optional arg open close) | |
"as insert-pair but indifferent to state of 'parens-require-spaces'" | |
(interactive "P") | |
(if (and open close) | |
(if (and transient-mark-mode mark-active) | |
(progn | |
(save-excursion (goto-char (region-end)) (insert close)) | |
(save-excursion (goto-char (region-beginning)) (insert open))) | |
(if arg (setq arg (prefix-numeric-value arg)) | |
(setq arg 0)) | |
(cond ((> arg 0) (skip-chars-forward " \t")) | |
((< arg 0) (forward-sexp arg) (setq arg (- arg)))) | |
(insert open) | |
(save-excursion | |
(or (eq arg 0) (forward-sexp arg)) | |
(insert close))) | |
(insert-char (event-bsic-type last-command-event) | |
(prefix-numeric-value arg)))) | |
(defun my-insert-asterisks (&optional arg) | |
(interactive "P") | |
(my-insert-pair arg ?\* ?\*)) | |
(defun my-insert-dquotes (&optional arg) | |
(interactive "P") | |
(my-insert-pair arg ?\" ?\")) | |
(defun my-insert-quotes (&optional arg) | |
(interactive "P") | |
(my-insert-pair arg ?\' ?\')) | |
(defun my-insert-braces (&optional arg) | |
(interactive "P") | |
(insert-pair arg ?\{ ?\})) | |
(defun my-insert-sbraces (&optional arg) | |
(interactive "P") | |
(insert-pair arg ?\[ ?\])) | |
(defun my-electric-braces () | |
"Insert a pair of braces surrounding a blank line, | |
indenting each according to the mode" | |
(interactive "*") | |
(let ((bolp | |
(save-excursion (skip-chars-backward " \t") | |
(equal (current-column) 0)))) | |
(end-of-line) | |
(indent-according-to-mode) | |
(insert " {}") | |
(if bolp | |
(eval (list indent-line-function)))) | |
(backward-char) | |
(newline-and-indent) | |
(previous-line 1) | |
(end-of-line) | |
(newline-and-indent)) | |
(defun skel-section-comment (str) | |
"Sort of wrapper aroung `figlet`. Uses *fill-column* for wide. | |
Use text input to pass additional params to `figlet`, i.e: | |
-f ogre -c TEXT | |
" | |
(interactive "sInsert Text: ") | |
(let* | |
((figlet-out | |
(shell-command-to-string | |
(concat "figlet -f term -w " (number-to-string (- fill-column 1)) | |
" " str))) | |
(text (mapcar #'(lambda (s) (if (string= s "") "" (concat " " s))) | |
(split-string figlet-out "\n"))) | |
(text-len-max (apply 'max (mapcar 'length text))) | |
(lcomm-tok (if (zerop (length comment-start)) | |
"-- " ; <-- default comment: "-- " | |
comment-start)) | |
;; rcomm-tok: transform "-- " to " --" | |
(rcomm-tok (if (zerop (length comment-end)) | |
(replace-in-string lcomm-tok | |
"\\(.+\\)\\(\s+\\)" "\\2\\1") | |
comment-end)) | |
;; pad symbol - is a second comment character | |
(pad-symb (if (and (> (length lcomm-tok) 1) | |
(not (string= " " (substring lcomm-tok 1 2)))) | |
(string-to-char (substring lcomm-tok 1 2)) | |
?-)) ; <-- default pad-symbol: "-" | |
(comment-space (length (concat lcomm-tok rcomm-tok)))) | |
(if (> text-len-max fill-column) | |
(message "Too many text for a line") | |
(let ((top-bottom (concat lcomm-tok | |
(make-string fill-column pad-symb) | |
rcomm-tok "\n"))) | |
(save-excursion | |
(insert top-bottom) | |
(insert | |
(mapconcat | |
#'(lambda (x) (if (not(string= x "")) | |
(concat lcomm-tok | |
x | |
(make-string | |
(- fill-column (length x)) ?\ ) | |
rcomm-tok))) | |
text "\n")) | |
(insert top-bottom)))))) | |
(defun replace-in-string (string regexp newtext &optional literal) | |
(replace-regexp-in-string regexp newtext string nil literal)) | |
(defun my-time-stamp-at-point() | |
"inserts date-taim at point -- <2016-01-01 10:59AM> | |
NOTE: do not forget time-stamp and current-time-string" | |
(interactive "*") | |
(insert (format-time-string "<%Y-%m-%d %R%p>" (current-time)))) | |
(defvar my-lame-dock-height 49) ;; in chars | |
(defvar my-lame-dock-width 81) | |
(defvar my-lame-dock-orig-y 0) | |
(defvar my-lame-dock-display-w 1280) | |
(defvar my-lame-dock-w-delta 7) | |
(defun my-lame-dock(&optional uarg) | |
"dock emacs frame in different ways" | |
(interactive "P") | |
(let( | |
(this-frame (selected-frame))) | |
(progn | |
(set-frame-size this-frame | |
my-lame-dock-width | |
my-lame-dock-height) | |
(cond | |
((null uarg) (message "unsupported")) | |
((consp uarg) (message "unsupported")) | |
(t (set-frame-position | |
this-frame | |
(cond | |
((= uarg 1) 0) ; 1st col | |
((= uarg 2) (+ my-lame-dock-w-delta | |
(frame-pixel-width))) ; 2nd col | |
((= uarg 3) (- my-lame-dock-display-w | |
(frame-pixel-width) | |
my-lame-dock-w-delta)) ; 3th col | |
(t 0)) ; any num -> left | |
0)))))) | |
(global-set-key [?\e ?\M-l] 'my-lame-dock) | |
;;----------------------------------------------------------------------; | |
;; EPILOGUE ; | |
;;----------------------------------------------------------------------; | |
(put 'set-goal-column 'disabled nil) | |
(put 'dired-find-alternate-file 'disabled nil) | |
(put 'narrow-to-region 'disabled nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment