Skip to content

Instantly share code, notes, and snippets.

@JacksonGariety
Created May 29, 2016 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JacksonGariety/0522a40016a1f535473f70128eab8c39 to your computer and use it in GitHub Desktop.
Save JacksonGariety/0522a40016a1f535473f70128eab8c39 to your computer and use it in GitHub Desktop.
;;; Nudity
(setq visible-bell t) ; disable visual beep
(transient-mark-mode t) ; show region, drop mark
(global-font-lock-mode t) ; for all buffers
(global-visual-line-mode t) ; word-wrap
(show-paren-mode t) ; show matching parentheses
(setq initial-scratch-message "")
(setq inhibit-startup-screen t)
;; Packages
(when (>= emacs-major-version 24)
(require 'package)
(package-initialize)
(add-to-list 'package-archives
'("gnu" . "http://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives
'("felpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t))
;; Scrolling
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed t) ;; accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
(setq scroll-step 1) ;; keyboard scroll one line at a time
(scroll-bar-mode -1)
;; Auto-modes
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.clj\\'" . clojure-mode))
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\Vagrantfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\Gemfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
;; Bells
(setq visible-bell nil)
(setq ring-bell-function 'ignore)
;; Mouse
(unless window-system
(require 'mouse)
(xterm-mouse-mode t)
(global-set-key [mouse-4] (lambda ()
(interactive)
(scroll-down 1)))
(global-set-key [mouse-5] (lambda ()
(interactive)
(scroll-up 1)))
(defun track-mouse (e))
(setq mouse-sel-mode t))
;; Column numbers
(setq column-number-mode t)
;; Windmove OS X
;; (setq windmove-wrap-around t)
;; (windmove-default-keybindings 'meta)
;; Windmove iTerm2
(global-set-key (kbd "ESC <up>") 'windmove-up)
(global-set-key (kbd "ESC <down>") 'windmove-down)
(global-set-key (kbd "ESC <left>") 'windmove-left)
(global-set-key (kbd "ESC <right>") 'windmove-right)
;; Golang
(setq exec-path (cons "/usr/local/Cellar/go/1.6/libexec" exec-path))
(add-to-list 'exec-path "~/Sites/gocode/bin")
(add-hook 'before-save-hook 'gofmt-before-save)
;; Font-face-under-cursor
(defun what-face (pos)
(interactive "d")
(let ((face (or (get-char-property (point) 'read-face-name)
(get-char-property (point) 'face))))
(if face (message "Face: %s" face) (message "No face at %d" pos))))
;; Fonts
(set-frame-font (font-spec :family "Inconsolata" :size 15 :weight 'thin :embolden nil :antialias t))
;; Remove whitespace on save (web-mode)
(add-hook 'web-mode-hook
(lambda () (add-to-list 'write-file-functions 'delete-trailing-whitespace)))
;; Superior Lisp Interaction ModE
;; (load (expand-file-name "~/quicklisp/slime-helper.el"))
;; (setq inferior-lisp-program "sbcl")
;; (setq slime-default-lisp 'sbcl)
;; (make-directory "/tmp/slime-fasls/" t)
;; (setq slime-compile-file-options '(:fasl-directory "/tmp/slime-fasls/"))
;; (setq compilation-ask-about-save nil)
;; Replace selection
(delete-selection-mode 1)
;; Changes all yes/no questions to y/n type
(fset 'yes-or-no-p 'y-or-n-p)
;; Disable lockfiles in server mode
(setq create-lockfiles nil)
;; store all backup and autosave files in the tmp dir
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
;;; coding systems
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;; highlgiht
(global-hl-line-mode 0)
;; fuck flyspell
;; (setq flyspell-issue-welcome-flag nil)
;; Hide menubar
(menu-bar-mode -1)
(tool-bar-mode 0)
;; Soft Tabs
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
;; JSX
(setq web-mode-content-types-alist
'(("jsx" . "\\.js[x]?\\'")))
(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.
'(ac-auto-start 2)
'(blink-cursor-interval 0.2)
'(blink-cursor-mode t)
'(compilation-message-face (quote default))
'(css-indent-offset 2)
'(cua-global-mark-cursor-color "#2aa198")
'(cua-normal-cursor-color "#657b83")
'(cua-overwrite-cursor-color "#b58900")
'(cua-read-only-cursor-color "#859900")
'(cua-rectangle-modifier-key (quote meta))
'(custom-safe-themes
(quote
("d677ef584c6dfc0697901a44b885cc18e206f05114c8a3b7fde674fce6180879" default)))
'(global-auto-complete-mode t)
'(highlight-changes-colors (quote ("#d33682" "#6c71c4")))
'(ido-cannot-complete-command (quote ido-next-match))
'(js2-allow-member-expr-as-function-name t)
'(js2-basic-offset 2)
'(js2-bounce-indent-p t)
'(js2-global-externs nil)
'(js2-highlight-level 3)
'(js2-include-node-externs t)
'(js2-include-rhino-externs t)
'(js2-indent-switch-body t)
'(js2-missing-semi-one-line-override t)
'(js2-mode-indent-ignore-first-tab nil)
'(js2-strict-inconsistent-return-warning nil)
'(js2-strict-missing-semi-warning nil)
'(jsx-indent-level 4)
'(jsx-use-auto-complete t)
'(linum-format "")
'(magit-diff-use-overlays nil)
'(pos-tip-background-color "#eee8d5")
'(pos-tip-foreground-color "#586e75")
'(vc-follow-symlinks t)
'(wakatime-api-key "c251e0c4-f6fb-4721-8a1e-cefea394f407")
'(wakatime-cli-path "/Users/Jackson/Sites/wakatime/wakatime-cli.py")
'(web-mode-code-indent-offset 2)
'(web-mode-disable-auto-indentation t)
'(web-mode-disable-auto-opening nil)
'(web-mode-disable-auto-pairing nil)
'(web-mode-enable-auto-indentation nil)
'(web-mode-enable-control-block-indentation nil)
'(weechat-color-list
(quote
(unspecified "#fdf6e3" "#eee8d5" "#990A1B" "#dc322f" "#546E00" "#859900" "#7B6000" "#b58900" "#00629D" "#268bd2" "#93115C" "#d33682" "#00736F" "#2aa198" "#657b83" "#839496"))))
;; Select up
(defadvice terminal-init-xterm (after select-shift-up activate)
(define-key input-decode-map "\e[1;2A" [S-up]))
;; Ido
(ido-mode)
(ido-everywhere 1)
(ido-ubiquitous-mode 1)
(ido-vertical-mode 1)
(flx-ido-mode 1)
(setq ido-enable-flex-matching t)
(setq ido-use-faces t)
(global-set-key (kbd "<backtab>") 'ido-prev-match)
;; Smex
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; Auto close brackets
(electric-pair-mode 1)
;; Hide status bar
(setq mode-line-format nil)
(transient-mark-mode 1) ; highlight text selection
(delete-selection-mode 1) ; delete seleted text when typing
;; Cider
(setq cider-prompt-save-file-on-load 'always-save)
;; Clojure
(add-hook 'clojure-mode-hook #'smartparens-strict-mode)
;; Clipboard interoperability
(defun copy-from-osx ()
(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)
(setq interprogram-paste-function 'copy-from-osx)
;; compile
(defun save-and-compile ()
(interactive)
(save-some-buffers 1)
(recompile))
(global-set-key (kbd "C-c C-c") 'save-and-compile)
;; projectile
(projectile-global-mode)
(global-set-key (kbd "C-x C-d") 'projectile-find-file)
(global-set-key (kbd "C-x C-g") 'projectile-grep)
(defun xah-run-current-file ()
"Execute the current file.
For example, if the current buffer is the file x.py, then it'll call 「python x.py」 in a shell.
The file can be Emacs Lisp, PHP, Perl, Python, Ruby, JavaScript, Bash, Ocaml, Visual Basic, TeX, Java, Clojure.
File suffix is used to determine what program to run.
If the file is modified or not saved, save it automatically before run.
URL `http://ergoemacs.org/emacs/elisp_run_current_file.html'
version 2016-01-28"
(interactive)
(let (
(ξsuffix-map
;; (‹extension› . ‹shell program name›)
`(
("php" . "php")
("pl" . "perl")
("py" . "python")
("py3" . ,(if (string-equal system-type "windows-nt") "c:/Python32/python.exe" "python3"))
("rb" . "ruby")
("go" . "go run")
("js" . "node") ; node.js
("sh" . "bash")
("rkt" . "racket")
("ml" . "ocaml")
("vbs" . "cscript")
("tex" . "pdflatex")
("latex" . "pdflatex")
("java" . "javac")
("scm" . "gosh")
("lisp" . "clisp")
;; ("pov" . "/usr/local/bin/povray +R2 +A0.1 +J1.2 +Am2 +Q9 +H480 +W640")
))
ξfname
ξfSuffix
ξprog-name
ξcmd-str)
(when (null (buffer-file-name)) (save-buffer))
(when (buffer-modified-p) (save-buffer))
(setq ξfname (buffer-file-name))
(setq ξfSuffix (file-name-extension ξfname))
(setq ξprog-name (cdr (assoc ξfSuffix ξsuffix-map)))
(setq ξcmd-str (concat ξprog-name " \"" ξfname "\""))
(cond
((string-equal ξfSuffix "el") (load ξfname))
((string-equal ξfSuffix "java")
(progn
(shell-command ξcmd-str "*xah-run-current-file output*" )
(shell-command
(format "java %s" (file-name-sans-extension (file-name-nondirectory ξfname))))))
(t (if ξprog-name
(progn
(shell-command ξcmd-str "*xah-run-current-file output*" ))
(message "No recognized program file suffix for this file."))))))
(global-set-key (kbd "<f8>") 'xah-run-current-file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment