Skip to content

Instantly share code, notes, and snippets.

@lauratboyer
Created January 26, 2015 20:42
Show Gist options
  • Save lauratboyer/4cb2e7c4fc35ec58d033 to your computer and use it in GitHub Desktop.
Save lauratboyer/4cb2e7c4fc35ec58d033 to your computer and use it in GitHub Desktop.
Emacs configuration file
;;; Define load path
(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
;;; Set preferred encoding to utf-8
;;; when using shell within emacs (M-x shell)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
; run my bash_profile to load program in emacs shell
(setenv "PATH" (shell-command-to-string "source ~/.bash_profile; echo -n $PATH"))
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
(require 'color-theme-buffer-local)
(add-hook 'tex-mode
(lambda nil (color-theme-buffer-local 'color-theme-robin-hood (current-buffer))))
(buffer-local-value 'major-mode (get-buffer "*scratch*"))
(eval-after-load 'autoinsert
'(define-auto-insert '("\\.r\\'"."R Skeleton" )
'(
"Short description: "
"## "
(file-name-nondirectory (buffer-file-name))
\n
"## " str \n
"## -------------------------------------------------------" \n
"## Author: Laura Tremblay-Boyer (l.boyer@fisheries.ubc.ca)" \n
"## Written on: " (format-time-string "%B %e, %Y") \n
"## Time-stamp: <>"
)))
(defun zenburn-init ()
(load-theme 'zenburn)
)
(defun misterioso-init ()
(load-theme 'misterioso)
)
(add-hook 'after-init-hook 'misterioso-init)
;(load "~/.emacs.d/plugins/color-theme-molokai.el")
;(color-theme-molokai)
;(load-theme 'misterioso)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; enable AUCTex
;(require 'tex-site)
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(setq TeX-PDF-mode t)
(add-hook 'LaTeX-mode-hook
(lambda () (local-set-key (kbd "<M-S-mouse-1>") #'TeX-view))
)
(setq-default TeX-master nil)
(setq TeX-parse-self t)
(setq TeX-auto-save t)
'(LaTeX-command "latex -synctex=1")
(require 'tex-site)
(add-hook 'TeX-mode-hook
(lambda ()
(add-to-list 'TeX-output-view-style
'("^pdf$" "."
"/Applications/Skim.app/Contents/SharedSupport/displayline -b %n %o %b")))
)
(server-start)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set path in Emacs so that it can find commands defined in the shell
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell
(replace-regexp-in-string "[[:space:]\n]*$" ""
(shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
(when (equal system-type 'darwin) (set-exec-path-from-shell-PATH))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Font size
(set-face-attribute 'default nil :height 170) ; try 180
;(set-background-color "black")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; moui bof ça a pas trop fonctionné ça
;(global-set-key (kbd "M-7") '{ )
;(global-set-key (kbd "M-8") '} )
; allow curly braces, essai no 2
(setq mac-option-modifier nil
mac-command-modifier 'meta
x-select-enable-clipboard t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; load ESS -- Emacs Speaks Statistics
(load "~/Software_Misc/ESS/ess-12.09-2/lisp/ess-site")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Enable time-stamp function
(add-hook 'before-save-hook 'time-stamp)
(setq time-stamp-pattern nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; truncate lines if they are too long
(setq-default truncate-lines t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; ADMB set-up ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; following instructions in admb.el ;;;;;;
(autoload 'admb-mode "admb" "Edit ADMB code." t)
(add-to-list 'auto-mode-alist '("\\.tpl$" . admb-mode))
(add-to-list 'auto-mode-alist '("\\.dat$" . conf-space-mode))
; use Sweave script as compile function for Rnw files and bind to \C-s\C-c
;(defun ess-swv-SweaveSh ()
; "Use Sweave script to weave an Rnw file and create a pdf."
; (interactive)
; (let
; ((compilation-buffer-name-function (function (lambda(ign)(concat "*" (buffer-file-name) "*")))))
; (compile (concat "Sweave -ld " (buffer-file-name)))
; )
;)
;(define-key noweb-minor-mode-map "\C-s\C-c" 'ess-swv-SweaveSh)
;; Add support for knit and purl
;(add-to-list 'load-path "~/.emacs.d/ess-knitr/")
;(require 'ess-knitr)
(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.
'(custom-enabled-themes (quote (adwaita)))
'(custom-safe-themes (quote ("52b5da0a421b020e2d3429f1d4929089d18a56e8e43fe7470af2cea5a6c96443" default)))
'(ess-swv-processor (quote knitr)))
(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.
)
;; remove default latex template and add my own instead
;; remove default
(add-hook 'TeX-mode-hook '(lambda ()
(remove-hook 'find-file-hooks (car find-file-hooks) 'local)))
; NOT WORKING FOR NOW
;; tell latex to get my version
;(let ((el (assoc 'latex-mode auto-insert-alist)))
; (if el
; (setcdr el "~/Projects/misc-ressources/ltb-file-template.tex")
; (define-auto-insert "\\.tex$" "~/Projects/misc-ressources/ltb-file-template.tex")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment