Created
January 24, 2018 14:19
-
-
Save hhuuggoo/e0bb2b13c970c39915e009801d17cfc9 to your computer and use it in GitHub Desktop.
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
(add-to-list 'load-path "/Users/hugo/.emacs.d/lisp") | |
(add-to-list 'auto-mode-alist '("\\.ini\\'" . python-mode)) | |
(require 'ido) | |
(require 'uniquify) | |
(require 'pbcopy) | |
(require 'etags-select) | |
(require 'find-file-in-tags) | |
(require 'cython-mode) | |
(add-to-list 'auto-mode-alist '("\\.pyx\\'" . cython-mode)) | |
;;;###autoload | |
(add-to-list 'auto-mode-alist '("\\.pxd\\'" . cython-mode)) | |
;;;###autoload | |
(add-to-list 'auto-mode-alist '("\\.pxi\\'" . cython-mode)) | |
(defun put-on-clipboard(text) | |
"copy text on clipboard" | |
(with-temp-buffer | |
(insert text) | |
(clipboard-kill-region (point-min) (point-max))) | |
(message text) | |
) | |
(defun my-put-file-name-on-clipboard () | |
"Put the current file name on the clipboard" | |
(interactive) | |
(let ((filename (if (equal major-mode 'dired-mode) | |
default-directory | |
(buffer-file-name)))) | |
(when filename | |
(with-temp-buffer | |
(insert filename) | |
(clipboard-kill-region (point-min) (point-max))) | |
(message filename)))) | |
(defun copy-current-line-position-to-clipboard () | |
"Copy current line in file to clipboard as '</path/to/file>:<line-number>'" | |
(interactive) | |
(let ((path-with-line-number | |
(concat (buffer-file-name) ":" (number-to-string (line-number-at-pos))))) | |
(put-on-clipboard path-with-line-number))) | |
;;ido config | |
(ido-mode t) | |
(setq ido-enable-flex-matching t) | |
;;uniquify buffers | |
(setq | |
uniquify-buffer-name-style 'post-forward | |
uniquify-separator ":") | |
(turn-off-pbcopy) | |
;; ETAGS | |
(add-hook 'term-mode-hook | |
(lambda() | |
(define-key term-raw-map (kbd "C-x") 'nil) | |
(define-key term-raw-map (kbd "M-x") 'nil) | |
(define-key term-raw-map (kbd "M-i") 'nil) | |
(define-key term-raw-map (kbd "M-o") 'nil) | |
(define-key term-raw-map (kbd "M-0") 'nil) | |
(define-key term-raw-map (kbd "C-M-h") 'nil) | |
(define-key term-raw-map (kbd "C-y") 'term-paste) | |
) | |
) | |
(setq term-buffer-maximum-size 100000) | |
(defvar debug 'nil "help") | |
(global-set-key (kbd "M-.") 'my-ido-find-tag) | |
(define-key etags-select-mode-map (kbd "RET") 'etags-select-goto-tag) | |
(global-set-key (kbd "M-.") 'my-ido-find-tag) | |
;;vars | |
(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. | |
'(ansi-color-names-vector | |
["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#e090d7" "#8cc4ff" "#eeeeec"]) | |
'(column-number-mode t) | |
'(custom-enabled-themes (quote (tango-dark))) | |
'(custom-safe-themes | |
(quote | |
("107c4ea6ac302c9408dec2837521aa1d306adb4f879237abb314418af6187b1a" "f0eb8549338e93c95597b2658af936a9b2fe552018cceca5c19550ab66bd005d" default))) | |
'(exec-path | |
(quote | |
("/usr/local/bin" "/bin" "/usr/bin" "/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9" "/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_9" "/Applications/Emacs.app/Contents/MacOS/libexec" "/Applications/Emacs.app/Contents/MacOS/bin")))) | |
(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 (:inherit nil :stipple nil :foreground "#eeeeec" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 130 :width normal :foundry "nil" :family "Monaco")))) | |
'(term-color-black ((t (:background "gray100" :foreground "gray100")))) | |
'(term-color-blue ((t (:background "blue2" :foreground "cadet blue")))) | |
'(term-color-magenta ((t (:background "color-207" :foreground "color-207")))) | |
'(term-color-red ((t (:background "color-175" :foreground "OrangeRed1")))) | |
'(term-color-yellow ((t (:background "color-227" :foreground "color-227"))))) | |
;;kbd shortcuts | |
(global-set-key (kbd "M-l") 'copy-current-line-position-to-clipboard) | |
(global-set-key (kbd "M-'") 'my-put-file-name-on-clipboard) | |
(global-set-key (kbd "M-i") `previous-multiframe-window) | |
(global-set-key (kbd "M-o") `other-window) | |
(global-set-key (kbd "<f7>") `previous-multiframe-window) | |
(global-set-key (kbd "<f8>") `other-window) | |
(fset 'pdbtrace "import pandas.util.testing; pandas.util.testing.set_trace()") | |
(global-set-key (kbd "<f9>") `pdbtrace) | |
(global-set-key (kbd "C-r") `isearch-backward) | |
(global-set-key (kbd "C-M-h") `rename-buffer) | |
(global-set-key (kbd "M-s") `shell) | |
(global-set-key (kbd "M-0") `delete-window) | |
(global-set-key (kbd "<f3>") `rgrep) | |
(global-set-key (kbd "<f2>") `find-name-dired) | |
(global-set-key (kbd "<f5>") `revert-buffer) | |
(global-set-key (kbd "M-g M-g") `goto-line) | |
;(add-hook 'before-save-hook 'delete-trailing-whitespace) | |
(defvar --backup-directory (concat user-emacs-directory "backups")) | |
(if (not (file-exists-p --backup-directory)) | |
(make-directory --backup-directory t)) | |
(setq backup-directory-alist `(("." . ,--backup-directory))) | |
(setq make-backup-files t ; backup of a file the first time it is saved. | |
backup-by-copying t ; don't clobber symlinks | |
version-control t ; version numbers for backup files | |
delete-old-versions t ; delete excess backup files silently | |
delete-by-moving-to-trash t | |
kept-old-versions 6 ; oldest versions to keep when a new numbered backup is made (default: 2) | |
kept-new-versions 9 ; newest versions to keep when a new numbered backup is made (default: 2) | |
auto-save-default t ; auto-save every buffer that visits a file | |
auto-save-timeout 20 ; number of seconds idle time before auto-save (default: 30) | |
auto-save-interval 200 ; number of keystrokes between auto-saves (default: 300) | |
) | |
(defun ido-find-file-in-tag-files () | |
(interactive) | |
(save-excursion | |
(let ((enable-recursive-minibuffers t)) | |
(visit-tags-table-buffer)) | |
(find-file | |
(expand-file-name | |
(ido-completing-read | |
"Project file: " (tags-table-files) nil t))))) | |
(global-set-key (kbd "M-,") 'ido-find-file-in-tag-files) | |
(setq create-lockfiles nil) | |
(fset 'autoinit | |
"self.\C-@\C-s,\C-b\C-[w = \C-y\C-d\C-m") | |
(global-set-key (kbd "C-x C-a") 'autoinit) | |
(defun do-lines (fun &optional start end) | |
"Invoke function FUN on the text of each line from START to END." | |
(interactive | |
(let ((fn (intern (completing-read "Function: " obarray 'functionp t)))) | |
(if (use-region-p) | |
(list fn (region-beginning) (region-end)) | |
(list fn (point-min) (point-max))))) | |
(save-excursion | |
(goto-char start) | |
(while (< (point) end) | |
(funcall fun (buffer-substring (line-beginning-position) (line-end-position))) | |
(forward-line 1)))) | |
(fset 'reset | |
"reset xterm-256color") | |
(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)) | |
(fset 'split3 | |
"\C-x3\C-x3\C-x+") | |
(setq ring-bell-function 'ignore) | |
(defvar ansi-term-color-vector | |
[term | |
term-color-black | |
term-color-red | |
term-color-green | |
term-color-yellow | |
term-color-blue | |
term-color-magenta | |
term-color-cyan | |
term-color-white]) | |
(set-frame-parameter (selected-frame) 'alpha '(93 100)) | |
(add-to-list 'default-frame-alist '(alpha 93 100)) | |
(when (>= emacs-major-version 24) | |
(require 'package) | |
(add-to-list | |
'package-archives | |
'("melpa" . "http://melpa.org/packages/") | |
t) | |
(package-initialize)) | |
(ac-config-default) | |
;(tool-bar-mode -1) | |
;(scroll-bar-mode -1) | |
(defun copy-from-osx () | |
"Handle copy/paste intelligently on osx." | |
(let ((pbpaste (purecopy "/usr/bin/pbpaste"))) | |
(if (and (eq system-type 'darwin) | |
(file-exists-p pbpaste)) | |
(let ((tramp-mode nil) | |
(default-directory "~")) | |
(shell-command-to-string pbpaste))))) | |
(defun paste-to-osx (text &optional push) | |
(let ((process-connection-type nil)) | |
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy"))) | |
(process-send-string proc text) | |
(process-send-eof proc)))) | |
(setq interprogram-cut-function 'paste-to-osx | |
interprogram-paste-function 'copy-from-osx) | |
(global-auto-revert-mode t) | |
(fset 'import | |
[?\C-s ?\C-a ?\C-s ?t ?z ?s ?t ?a ?t return ?\M-b ?\C-u ?0 ?\C-k ?\C- ?\C-e ?\M-x ?r ?e ?p ?l ?a ?c ?e ?- ?s ?t ?r ?i ?n ?g return ?/ return ?. return ?\C-s ?. ?p ?y return backspace backspace backspace ?\C-k]) | |
(add-hook 'term-mode-hook 'my-term-mode-hook) | |
(defun my-term-mode-hook () | |
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20611 | |
(setq bidi-paragraph-direction 'left-to-right)) | |
(fset 'resetterm | |
"\C-x1\C-x3\C-x3\C-x3\C-x3\C-x+\C-x1") | |
(require 'flymake) | |
(load-library "flymake-cursor") | |
;; Script that flymake uses to check code. This script must be | |
;; present in the system path. | |
(setq pycodechecker "pychecker") | |
(when (load "flymake" t) | |
(defun flymake-pycodecheck-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-inplace)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(list pycodechecker (list local-file)))) | |
(add-to-list 'flymake-allowed-file-name-masks | |
'("\\.py\\'" flymake-pycodecheck-init))) | |
(add-hook 'python-mode-hook 'flymake-mode) | |
(fset 'iq | |
"import os; os._exit(1)\C-m") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment