Last active
March 25, 2018 23:39
-
-
Save tokestermw/10022739 to your computer and use it in GitHub Desktop.
My .emacs implementation (Python, R, scientific computing) (Mac OS 10.9 Mavericks)
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
| ;; Revo64 | |
| ;(setenv "PATH" (concat (getenv "PATH") ":/sw/bin")) | |
| ;(setq exec-path (append '("/opt/REvolution/Revo-3.2/Revo64/R.framework/Resources/"))) | |
| ; (setq exec-path (append exec-path '("/sw/bin"))) | |
| ; scroll when running code | |
| (setq comint-prompt-read-only nil) | |
| (setq comint-scroll-to-bottom-on-input t) | |
| (setq comint-scroll-to-bottom-on-output t) | |
| (setq comint-move-point-for-output t) | |
| ; don't scroll so much | |
| ; http://linux-quirks.blogspot.com/2010/02/emacs-mouse-scrolling.html | |
| (defun up-slightly () (interactive) (scroll-up 1)) | |
| (defun down-slightly () (interactive) (scroll-down 1)) | |
| (global-set-key [mouse-4] 'down-slightly) | |
| (global-set-key [mouse-5] 'up-slightly) | |
| ; https://github.com/motus/pig-mode | |
| (add-to-list 'load-path "~/elisp/pig-mode") | |
| (require 'pig-mode) | |
| ;; set default font size | |
| ;(set-default-font "9x12") | |
| ;; set default font familly | |
| ;(add-to-list 'default-frame-alist '(font . "Droid Sans Mono-10" )) | |
| (set-face-attribute 'default nil | |
| :family "Bitstream Vera Sans Mono" :height 120 :weight 'bold | |
| :foreground "grey10") | |
| ;:family "Inconsolata" :height 140) | |
| (set-face-attribute 'font-lock-comment-face nil | |
| :family "Inconsolata" :height 120 :slant 'italic | |
| :background "#eeeeff" :foreground "#545454") | |
| (set-face-attribute 'font-lock-string-face nil | |
| :family "Bitstream Vera Sans Mono" :height 120 :weight 'normal | |
| :foreground "#006400" :background 'unspecified) | |
| ;(set-default-font "Bitstream Vera Sans Mono-7 10") | |
| ;(set-frame-font "DejaVu Sans Mono-10" nil t) ; set font for all windows | |
| ;n(set-face-attribute 'default nil | |
| ; :family "Inconsolata" :height 145 :weight 'normal) | |
| ;; turn on font-lock mode | |
| (when (fboundp 'global-font-lock-mode) | |
| (global-font-lock-mode t)) | |
| ;; enable visual feedback on selections | |
| (setq transient-mark-mode t) | |
| ;; default to better frame titlesb | |
| (setq frame-title-format | |
| (concat "%b " )) | |
| ;; ctrl+j to run code from text file in ESS | |
| (global-set-key (kbd "C-j") 'ess-eval-line-and-step) | |
| ;;(global-set-key (kbd "C-M-j") 'ess-eval-region) | |
| (global-set-key (kbd "C-M-j") 'ess-eval-region-and-go) | |
| ;; default to unified diffs | |
| (setq diff-switches "-u") | |
| ;; always end a file with a newline | |
| ;(setq require-final-newline 'query) | |
| ;; admb.el config | |
| (autoload 'admb-mode "admb" "Edit ADMB code." t) | |
| (add-to-list 'auto-mode-alist '("\\.tpl$" . admb-mode)) | |
| ; using the meta key to jump between windows | |
| (global-set-key (kbd "M-0") 'delete-window) | |
| (global-set-key (kbd "M-1") 'delete-other-windows) | |
| (global-set-key (kbd "M-2") 'split-window-vertically) | |
| (global-set-key (kbd "M-3") 'split-window-horizontally) | |
| (global-set-key (kbd "M-o") 'other-window) | |
| ; using the C-b to jump between windows | |
| (global-set-key (kbd "C-b") 'switch-to-buffer) | |
| ; Windows binding for 'undo | |
| (global-set-key (kbd "C-z") 'undo) | |
| ; turn off tool-bar | |
| (tool-bar-mode -1) | |
| ; turn off menu bar | |
| (menu-bar-mode -1) | |
| ; turn on clipboard | |
| (setq x-select-enable-clipboard t) | |
| ;;The following function changes the way you switch buffers. You are | |
| ;;presented with a list of buffers that shrinks as you type the name, | |
| ;;only the matching buffers are shown, making buffer switching much | |
| ;;easier. | |
| ; (iswitchb-default-keybindings) | |
| ;; turn on font-lock mode | |
| (when (fboundp 'global-font-lock-mode) | |
| (global-font-lock-mode t)) | |
| ;; ;; Shift-arrows a la windows... | |
| ;; (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. | |
| ;; '(mouse-wheel-mode t -1 (mwheel)) | |
| ;; '(mouse-wheel-scroll-amount (quote (1 ((shift) . 1) ((control))))) | |
| ;; '(muse-project-alist (quote (("test" ("~/" :default "index") (:base "html" :path "~/Desktop/public_html") (:base "pdf" :path "~/Desktop/public_html/pdf"))))) | |
| ;; '(pc-select-meta-moves-sexps t) | |
| ;; '(pc-select-selection-keys-only t) | |
| ;; '(pc-selection-mode t -1 (pc-select)) | |
| ;; '(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify))) | |
| ;; '(transient-mark-mode t)) | |
| ;; Ability use Shift - arrow keys to select and whatnot.. just like notepad | |
| ;(pc-selection-mode t) | |
| ;(require 'pc-select) | |
| ; (pc-selection-mode) | |
| (cua-mode 1) | |
| (transient-mark-mode 1) | |
| ;; set the command history short cut to Alt+L | |
| ;; Default::: | |
| ;; M-p (comint-previous-input) | |
| ;; Select the previous command in the input history. | |
| ;; M-n (comint-next-input) | |
| ;; Select the next command in the input history | |
| ;; (define-key ess-mode-map [f1] 'comint-previous-input) | |
| ;; so we can find our css-mode | |
| (setq load-path (append load-path (list "~/elisp"))) | |
| ;; css-mode.el | |
| (autoload 'css-mode "css-mode" "Mode for editing CSS files" t) | |
| (setq auto-mode-alist | |
| (append '(("\\.css$" . css-mode)) | |
| auto-mode-alist)) | |
| (global-set-key (kbd "M-[ 5 d") 'backward-word) | |
| (global-set-key (kbd "M-[ 5 c") 'forward-word) | |
| (global-set-key (kbd "C-<right>") 'forward-word) | |
| (global-set-key (kbd "C-<left>") 'backward-word) | |
| ;; matlab mode | |
| ;; Set up matlab-mode to load on .m files | |
| (autoload 'matlab-mode "matlab" "Enter MATLAB mode." t) | |
| (setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist)) | |
| (autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t) | |
| ;; Customization: | |
| (setq matlab-indent-function t) ; if you want function bodies indented | |
| (setq matlab-verify-on-save-flag -1) ; turn off auto-verify on save | |
| (defun my-matlab-mode-hook () | |
| (setq fill-column 76)) ; where auto-fill should wrap | |
| (add-hook 'matlab-mode-hook 'my-matlab-mode-hook) | |
| (defun my-matlab-shell-mode-hook () | |
| '()) | |
| (add-hook 'matlab-shell-mode-hook 'my-matlab-shell-mode-hook) | |
| ;; Turn off Matlab desktop | |
| (setq matlab-shell-command-switches '("-nojvm")) | |
| ;; turn on IDO-mode | |
| ;;in the .emacs | |
| (require 'ido) | |
| (ido-mode t) | |
| ;(tabbar-mode 1) | |
| ;(define-key global-map [(control prior)] 'tabbar-backward) | |
| ;(define-key global-map [(control next)] 'tabbar-forward) | |
| ;; don't move too much! | |
| (setq scroll-conservatively 1) | |
| (add-to-list 'load-path "~/elisp/ess-site/lisp") | |
| (load "ess-site") | |
| ;; https://stat.ethz.ch/pipermail/ess-help/2005-September/002875.html | |
| ; separate window for help | |
| (require 'ess-site) | |
| ;(setq inferior-ess-own-frame t) | |
| ;(setq inferior-ess-same-window -1) | |
| ;;create a new frame for each help instance | |
| (setq ess-help-own-frame t) | |
| ;; If you want all help | |
| ;; buffers to go into one frame do: | |
| (setq ess-help-own-frame 'one) | |
| ;; site to change keyboard bindings | |
| ;; http://xahlee.org/emacs/keyboard_shortcuts.html | |
| ;; function key to use for home , end | |
| ;; (global-set-key (kbd "fn-<right>") 'beginning-of-buffer) | |
| ;; (global-set-key (kbd "fn-<left>") 'end-of-buffer) | |
| (global-set-key [home] 'beginning-of-buffer) | |
| (global-set-key [end] 'end-of-buffer) | |
| ;; http://www.popcornfarmer.com/2008/04/mac-home-and-end-keys/ | |
| ;; (setq hah-key-map global-map)) | |
| ;; (define-key hah-key-map [home] 'beginning-of-buffer) | |
| ;; (define-key hah-key-map [end] 'end-of-buffer) | |
| ;; http://orgmode.org/org.html | |
| (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) | |
| (setq load-path (cons "~/org-mode/lisp" load-path)) | |
| (global-set-key "\C-cl" 'org-store-link) | |
| (global-set-key "\C-cc" 'org-capture) | |
| (global-set-key "\C-ca" 'org-agenda) | |
| (global-set-key "\C-cb" 'org-iswitchb) | |
| ; http://jblevins.org/projects/markdown-mode/ | |
| (autoload 'markdown-mode "markdown-mode.el" | |
| "Major mode for editing Markdown files" t) | |
| (setq auto-mode-alist | |
| (cons '("\\.md" . markdown-mode) auto-mode-alist)) | |
| (require 'org-install) | |
| ;(require 'ob-tangle) | |
| ; http://renard.github.com/o-blog/ | |
| (add-to-list 'load-path "~/.emacs.d/o-blog") | |
| (require 'o-blog) | |
| ; I want ability to shift arrow keys highlight region in org-mode | |
| ; http://www.gnu.org/software/emacs/manual/html_node/org/Conflicts.html | |
| ; how to add comments to org-mode, unintrusively? | |
| ; http://stackoverflow.com/questions/9212737/how-to-make-inline-comments-in-org-mode | |
| ; title bar menu should include file path! | |
| ;; Frame title bar formatting to show full path of file | |
| (setq org-support-shift-select -1) | |
| ;(setq shift-selection-mode t) | |
| ; http://stackoverflow.com/questions/1771981/how-to-keep-indentation-with-emacs-org-mode-visual-line-mode | |
| ;(global-visual-line-mode 1) ; 1 for on, 0 for off. | |
| (setq org-replace-disputed-keys t) | |
| ;(setq shift-select-mode t) | |
| (global-hl-line-mode 1) | |
| (set-face-background hl-line-face "light cyan") | |
| ; /Library/Preferences/Aquamacs Emacs/Preferences.el | |
| ;;; I prefer cmd key for meta | |
| (setq mac-option-key-is-meta nil | |
| mac-command-key-is-meta t | |
| mac-command-modifier 'meta | |
| mac-option-modifier 'super) | |
| (setq ess-eval-visibly nil) | |
| ; ESS will not print the evaluated comands, also speeds up the evaluation | |
| ; http://www.kurup.org/blog/2012/10/24/emacs-for-python-programming/ | |
| (setq-default ispell-program-name "/usr/local/bin/aspell") | |
| ;; make sure shell python has correct path | |
| (setenv "PATH" "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin:/usr/X11/bin") | |
| (setq exec-path (split-string (getenv "PATH") path-separator)) | |
| ; http://stackoverflow.com/questions/12805873/changing-indentation-in-emacs-ess | |
| ;; R-internals manual | |
| ;;; ESS | |
| ;; (add-hook 'ess-mode-hook | |
| ;; (lambda () | |
| ;; (ess-set-style 'GNU 'quiet) | |
| ;; ;; Because | |
| ;; ;; DEF GNU BSD K&R C++ | |
| ;; ;; ess-indent-level 2 2 8 5 4 | |
| ;; ;; ess-continued-statement-offset 2 2 8 5 4 | |
| ;; ;; ess-brace-offset 0 0 -8 -5 -4 | |
| ;; ;; ess-arg-function-offset 2 4 0 0 0 | |
| ;; ;; ess-expression-offset 4 2 8 5 4 | |
| ;; ;; ess-else-offset 0 0 0 0 0 | |
| ;; ;; ess-close-brace-offset 0 0 0 0 0 | |
| ;; (add-hook 'local-write-file-hooks | |
| ;; (lambda () | |
| ;; (ess-nuke-trailing-whitespace))))) | |
| ;;(setq ess-nuke-trailing-whitespace-p 'ask) | |
| ;; or even | |
| (setq ess-nuke-trailing-whitespace-p t) | |
| ;; Perl | |
| ;; (add-hook 'perl-mode-hook | |
| ;; (lambda () (setq perl-indent-level 4))) | |
| ;(desktop-save-mode 1) | |
| (require 'package) | |
| (add-to-list 'package-archives | |
| '("marmalade" . "http://marmalade-repo.org/packages/")) | |
| (package-initialize) | |
| ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) | |
| (add-hook 'haskell-mode-hook 'turn-on-haskell-indent) | |
| ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent) | |
| ; http://www.masteringemacs.org/articles/2013/03/11/whats-new-emacs-24-3/ | |
| ; (add-hook 'python-mode-hook | |
| ;; (lambda () | |
| ;; (setq indent-tabs-mode nil) | |
| ;; (setq tab-width 4) | |
| ;; (setq python-indent-guess-indent-offset 1) | |
| ;; (setq python-indent-offset 4))) | |
| ; use python-mode instead downloaded from package manager | |
| ;; (autoload 'python-mode "python-mode" "Python Mode." t) | |
| ;; (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) | |
| ;; (add-to-list 'interpreter-mode-alist '("python" . python-mode)) | |
| (global-set-key (kbd "C-<delete>") 'kill-word) | |
| (require 'sql) | |
| ; https://github.com/gabrielelanaro/emacs-for-python | |
| ;(load-file "~/elisp/emacs-for-python/epy-init.el") | |
| ;(add-to-list 'load-path "~/elisp/emacs-for-python/") ;; tell where to load the various files | |
| ;(require 'epy-setup) ;; It will setup other loads, it is required! | |
| ;; (require 'epy-python) ;; If you want the python facilities [optional] | |
| ;; (require 'epy-completion) ;; If you want the autocompletion settings [optional] | |
| ;; (require 'epy-editing) ;; For configurations related to editing [optional] | |
| ;; (require 'epy-bindings) ;; For my suggested keybindings [optional] | |
| ;; (require 'epy-nose) ;; For nose integration | |
| ; http://stackoverflow.com/questions/17986194/emacs-disable-automatic-file-search-in-ido-mode | |
| (setq ido-auto-merge-work-directories-length -1) | |
| ;; ;; Standard package.el + MELPA setup | |
| ;; ;; (See also: https://github.com/milkypostman/melpa#usage) | |
| ;; (require 'package) | |
| ;; (add-to-list 'package-archives | |
| ;; '("melpa" . "http://melpa.milkbox.net/packages/") t) | |
| ;; (package-initialize) | |
| ;; (require 'package) | |
| ;; (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") | |
| ;; ("marmalade" . "http://marmalade-repo.org/packages/") | |
| ;; ("melpa" . "http://melpa.milkbox.net/packages/"))) | |
| ;; (package-initialize) | |
| ;; ;; Standard Jedi.el setting | |
| ;; (add-hook 'python-mode-hook 'jedi:setup) | |
| ;; (setq jedi:complete-on-dot t) | |
| ;; Type: | |
| ;; M-x package-install RET jedi RET | |
| ;; M-x jedi:install-server RET | |
| ;; Then open Python file. | |
| (show-paren-mode 1) | |
| ;(electric-pair-mode 1) | |
| ;; (add-to-list 'load-path | |
| ;; "~/.emacs.d/plugins/yasnippet") | |
| ;; (require 'yasnippet) | |
| ;; (setq yas-snippet-dirs | |
| ;; '("~/elisp/emacs-for-python/snippets/django" | |
| ;; "~/.emacs.d/plugins/yasnippet/snippets")) | |
| ;; (yas-global-mode 1) | |
| ; https://github.com/gabrielelanaro/emacs-for-python | |
| ;(load-file "~/elisp/emacs-for-python/epy-init.el") | |
| ;(add-to-list 'load-path "~/elisp/emacs-for-python/") ;; tell where to load the various files | |
| ;(require 'epy-setup) ;; It will setup other loads, it is required! | |
| ;(require 'epy-python) ;; If you want the python facilities [optional] | |
| ;; (require 'epy-completion) ;; If you want the autocompletion settings [optional] | |
| ;; (require 'epy-editing) ;; For configurations related to editing [optional] | |
| ;; (require 'epy-bindings) ;; For my suggested keybindings [optional] | |
| ;; (require 'epy-nose) ;; For nose integration | |
| ;; (epy-django-snippets) | |
| ;; (require 'highlight-indentation) | |
| ;; (add-hook 'python-mode-hook 'highlight-indentation) | |
| ; disabling ropemacs | |
| (setq epy-enable-ropemacs nil) | |
| ; http://www.emacswiki.org/emacs/SrSpeedbar | |
| ;(require 'sr-speedbar) | |
| ; http://www.r-bloggers.com/a-small-customization-of-ess/ | |
| (setq ess-S-assign-key (kbd "C--")) | |
| (ess-toggle-S-assign-key t) ; enable above key definition | |
| ;; leave my underscore key alone! | |
| (ess-toggle-underscore nil) | |
| ; https://github.com/JuliaLang/julia/blob/master/contrib/julia-mode.el | |
| (require 'julia-mode) | |
| (add-to-list 'auto-mode-alist '("\\.jl\\'" . julia-mode)) | |
| ; https://launchpad.net/python-mode | |
| (add-to-list 'load-path "~/elisp/python-mode") | |
| (require 'python-mode) | |
| (autoload 'python-mode "python-mode" "Python Mode." t) | |
| (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) | |
| (add-to-list 'interpreter-mode-alist '("python" . python-mode)) | |
| ;(desktop-save-mode 1) | |
| ; change shell file name | |
| ; http://www.emacswiki.org/emacs/setup-cygwin.el | |
| (setq shell-file-name "/bin/bash") | |
| ;(setenv "SHELL" shell-file-name) | |
| (require 'uniquify) | |
| (setq uniquify-buffer-name-style 'forward) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment