Skip to content

Instantly share code, notes, and snippets.

@markzyu
Last active November 19, 2016 16:31
Show Gist options
  • Save markzyu/e9ff6b33d4f609eacb955dfe640e7e70 to your computer and use it in GitHub Desktop.
Save markzyu/e9ff6b33d4f609eacb955dfe640e7e70 to your computer and use it in GitHub Desktop.
.emacs for OS X
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/"))
(setq package-enable-at-startup nil)
(package-initialize)
(defun ensure-package-installed (&rest packages)
"Assure every package is installed, ask for installation if it’s not.
Return a list of installed packages or nil for every skipped package."
(mapcar
(lambda (package)
(if (package-installed-p package)
nil
(if (y-or-n-p (format "Package %s is missing. Install it? " package))
(package-install package)
package)))
packages))
;; Make sure to have downloaded archive description.
(or (file-exists-p package-user-dir)
(package-refresh-contents))
;; Activate installed packages
(package-initialize)
;; -------------- end of HELPERS for PACKAGE MANAGEment.
(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.
'(package-selected-packages (quote (helm evil-visual-mark-mode auctex))))
(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.
)
;; -------------- end of AUTOMATICALLY generated lines:
(defun addEnvPath (path)
(progn
(setq exec-path (append exec-path '(path)))
(setenv "PATH" (concat (getenv "PATH") ":" path))
)
)
(defun send-string-to-curr-buffer (string)
(process-send-string
(get-buffer-process (current-buffer))
string))
;; -------------- end of helper functions written by ME:
(addEnvPath "/Library/TeX/texbin/")
(addEnvPath "/usr/local/bin/")
(setq preview-gs-command "/usr/local/bin/gs")
;; -------------- end of LaTex setups
(ensure-package-installed 'evil 'helm)
;; This line is required to make sure "M-x evil-mode" works out of the box
(require 'evil)
(global-set-key (kbd "M-x") 'helm-M-x)
;; -------------- end of setup for EVIL and HELM
(setq mac-command-modifier 'meta)
; (setq system-uses-terminfo 't)
;; -------------- end of setup for OS X
; add an advice to close the buffer after the shell was terminated
(defadvice term-sentinel (around my-advice-term-sentinel (proc msg))
(if (memq (process-status proc) '(signal exit))
(let ((buffer (process-buffer proc)))
ad-do-it
(kill-buffer buffer))
ad-do-it))
(ad-activate 'term-sentinel)
; add a hook to force loading .bash_profile
(defun load-bash-profile ()
(send-string-to-curr-buffer ". ~/.bash_profile\n"))
(add-hook 'term-exec-hook 'load-bash-profile)
;; -------------- end of setup for "term"
(defun find-374-HW ()
"call 'find-file from 374 HW directory"
(interactive)
(let ((default-directory "~/School/7-Fall 2016/4-CS 374 HW/"))
(call-interactively 'find-file)))
(defun begin-427 ()
"start working on CS 427 team project"
(interactive)
(progn
(term "/bin/bash")
(send-string-to-curr-buffer
"alias goimp='cd ~/team15-427/k-distribution/tutorial/1_k/2_imp/lesson_4/'\n")
(send-string-to-curr-buffer
"alias goroot='cd ~/team15-427/'\n")
(send-string-to-curr-buffer
"alias gocompile='(goroot; mvn compile)'\n")
(send-string-to-curr-buffer
"alias gopackage='(goroot; mvn package)'\n")
))
;; -------------- end of CUSTOMIZED commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment