From 38891b58b9efb16f99ac4c5e101cf56599550d4a Mon Sep 17 00:00:00 2001 From: Guru Devanla Date: Tue, 22 Jan 2013 11:50:18 -0600 Subject: [PATCH] .emacs --- yadfr/mac/.emacs | 451 ++++++++++------------------------------------- 1 file changed, 91 insertions(+), 360 deletions(-) diff --git a/yadfr/mac/.emacs b/yadfr/mac/.emacs index de4a8b5..d9d4503 100644 --- a/yadfr/mac/.emacs +++ b/yadfr/mac/.emacs @@ -1,34 +1,26 @@ -(require 'package) -(package-initialize) -(add-to-list 'package-archives - '("marmalade" . "http://marmalade-repo.org/packages/") t) -(add-to-list 'load-path "~/.emacs.d/elpa/pymacs-0.25") - - (setq default-frame-alist (append (list - '(width . 79) ; Width set to 81 characters - '(height . 40)) ; Height set to 60 lines + '(width . 81) ; Width set to 81 characters + '(height . 60)) ; Height set to 60 lines default-frame-alist)) -(require 'python) -(require 'auto-complete) -(require 'yasnippet) -(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)) -;; Initialize Yasnippet -;Don't map TAB to yasnippet -;In fact, set it to something we'll never use because -;we'll only ever trigger it indirectly. -(setq yas/trigger-key (kbd "C-c ")) -;;(yas/initialize) -;;(yas/load-directory "~/.emacs.d/snippets") +;; these were generated by Emacs GUI +(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. + '(column-number-mode t) + '(font-latex-fontify-sectioning (quote color)) + '(tab-width 2)) +(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 :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width semi-condensed :foundry "unknown" :family "DejaVu Serif"))))) -(setq mac-allow-anti-aliasing t) ;; turn on anti-aliasing (default) -;;≈(setq mac-allow-anti-aliasing nil) ;; turn off anti-aliasing -(set-default-font "Monaco-14") ;; ====Configuration from ;; http://homepages.inf.ed.ac.uk/s0243221/emacs/ @@ -39,11 +31,10 @@ (setq query-replace-highlight t) ; Highlight query object (setq mouse-sel-retain-highlight t) ; Keep mouse high-lightening -;;(set-face-background 'region "yellow") ; Set region background color -(set-background-color "black") -(set-foreground-color "white") +(set-face-background 'region "yellow") ; Set region background color +(set-default-font "-adobe-courier-small-r-normal--18-180-75-75-m-110-iso8859-1") -;;(add-to-list 'load-path "~/.emacs.d/") + (add-to-list 'load-path "~/.emacs.d/vendor/") ;;(add-hook 'python-mode-hook @@ -52,6 +43,11 @@ ;; (setq tab-width 2) ;; (setq python-indent 2))) +;; to set fonts +(setq my-font "Monospace-10") +(set-default-font my-font) + + ;; ==== Put autosave and backup files in ~/.emacs.d ==== ;; Thanks to @@ -76,7 +72,7 @@ ;; "~/.abbrev_defs", so don't try to be too clever ;; by changing its name -;;(setq-default abbrev-mode f) +;;(setq-default abbrev-mode t) ;;(read-abbrev-file "~/.abbrev_defs") ;;(setq save-abbrevs t) @@ -160,6 +156,11 @@ ;; Set region background colour (set-face-background 'region "blue") +;; Set emacs background colour +(set-background-color "black") +(set-foreground-color "white") + + ;;https://github.com/asmeurer/dotfiles/blob/master/.emacs ;; ===== Automatically indent with RET ===== @@ -202,6 +203,24 @@ (setq vc-handled-backe:nds nil) +;; Use the turn-on-flyspell one to enable it everywhere, and the +;; flyspell-prog-mode to enable it only in comments/strings +(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t) +(add-hook 'message-mode-hook 'turn-on-flyspell) +(add-hook 'text-mode-hook 'turn-on-flyspell) +(add-hook 'LaTeX-mode-hook 'turn-on-flyspell) +(add-hook 'c-mode-common-hook 'flyspell-prog-mode) +(add-hook 'tcl-mode-hook 'flyspell-prog-mode) +(add-hook 'python-mode-hook 'flyspell-prog-mode) +(add-hook 'lisp-mode-hook 'flyspell-prog-mode) +(add-hook 'emacs-lisp-mode-hook 'flyspell-prog-mode) +(defun turn-on-flyspell () + "Force flyspell-mode on using a positive arg. For use in hooks." + (interactive) + (flyspell-mode 1)) + + + ;; This trick makes C-x C-s clear whitespace, *but*, if there was whitespace ;; between the cursor and the end of the line, it puts it back after the save ;; (but still marks the file as saved). This way, you can save while typing @@ -250,12 +269,12 @@ ;; disable default python.el from loading -;;(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)) +(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)) -;;(require 'ipython) +(require 'ipython) ;;(require 'pymacs) ;;(pymacs-load "ropemacs" "rope-") @@ -271,36 +290,37 @@ ;; Automatically save project python buffers before refactorings (setq ropemacs-confirm-saving 'nil) ) -(global-set-key "\C-x p l" 'load-ropemacs) - -; -;; ;; ===== Enable ropemacs ===== -;; -;; ;; Uncomment these to prevent ropemacs from changing default keybindings -(setq ropemacs-enable-shortcuts nil) -;;(setq ropemacs-local-prefix "C-c C-p") -(require 'pymacs) +(global-set-key "\C-xpl" 'load-ropemacs) ;; ;; ===== Stuff for the pymacs extension ==== ;; -;;(setenv "PYMACS_PYTHON" "python") - (autoload 'pymacs-apply "pymacs") (autoload 'pymacs-call "pymacs") (autoload 'pymacs-eval "pymacs" nil t) (autoload 'pymacs-exec "pymacs" nil t) (autoload 'pymacs-load "pymacs" nil t) -(autoload 'pymacs-autoload "pymacs") - - +;; +;; ;; ===== Enable ropemacs ===== +;; +;; ;; Uncomment these to prevent ropemacs from changing default keybindings +(setq ropemacs-enable-shortcuts nil) +(setq ropemacs-local-prefix "C-c C-p") +(require 'pymacs) (pymacs-load "ropemacs" "rope-") (setq ropemacs-enable-autoimport t) -(setq ropemacs-local-prefix "C-c r") -(setq ropemacs-separate-doc-buffer nil) +;; ;; ===== Enable the anything extension ==== +;; +(require 'anything) + (require 'anything-ipython) + (when (require 'anything-show-completion nil t) + (use-anything-show-completion 'anything-ipython-complete + '(length initial-pattern))) +;;python_mode.el settings +;;http://pedrokroger.com/2010/07/configuring-emacs-as-a-python-ide-2/ ;;http://www.joegrossberg.com/archives/000182.html @@ -308,7 +328,7 @@ (require 'recentf) (recentf-mode 1) (setq recentf-max-menu-items 25) -(global-set-key "\C-x\C-r" 'recentf-open-files) +(global-set-key "\C-x\\C-r" 'recentf-open-files) ;; setting for popping mark rings autimatically (setq set-mark-command-repeat-pop t) @@ -318,16 +338,10 @@ (global-set-key "\C-c\C-m" 'execute-extended-command) ;; note \C-w may have side effects outside emacs -(global-set-key "\C-w" 'backward-kill-word) +(global-set-key "\C-x\C-w" 'backward-kill-word) (global-set-key "\C-x\C-k" 'kill-region) (global-set-key "\C-c\C-k" 'kill-region) -(global-set-key "\M-\C-p" 'scroll-other-window-down) -(global-set-key "\C-z" 'scroll-down-line) -(global-set-key "\M-z" 'scroll-up-line) - - - ;; disable menu bars (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) (if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) @@ -349,22 +363,9 @@ argument" ))) ;; for intercation between emacs and X11 clipboard. -;;(setq x-select-enable-clipboard t) -;;(setq interprogram-paste-function 'x-cut-buffer-or-selection-value) - +(setq x-select-enable-clipboard t) +(setq interprogram-paste-function 'x-cut-buffer-or-selection-value) -;;mac related emacs settings -(defun mac-copy () -(shell-command-to-string "pbpaste")) - -(defun mac-paste (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 'mac-paste) -(setq interprogram-paste-function 'mac-copy) ;; settings to use org-mode for research @@ -410,293 +411,23 @@ argument" (format "\\cite{%s}" search) (format "\\cite[%s]{%s}" desc search)))))) -(require 'php-mode) - - -;; cursor color and type -(setq cursor-type 'hbar) -(set-cursor-color 'red) - - -;; ===== Enable mouse support ==== - -(require 'xt-mouse) -(xterm-mouse-mode) - -;; ==== Save command histories ==== - -;; See -;; http://stackoverflow.com/questions/1229142/how-can-i-save-my-mini-buffer-history-in-emacs -(setq savehist-additional-variables - '(kill-ring search-ring regexp-search-ring)) - -(setq savehist-file "~/.emacs.d/savehist") -(savehist-mode t) - -;; autocomplete settings -(add-to-list 'ac-dictionary-directories "~/.emacs.d/dict") -;; -(require 'auto-complete-config) -;;(ac-config-default) -;; from asmurer -(require 'popup) -(require 'fuzzy) -(add-to-list 'ac-dictionary-directories "~/Documents/auto-complete/dict") -(define-key ac-mode-map (kbd "M-TAB") 'auto-complete) -(ac-set-trigger-key "TAB") -(ac-flyspell-workaround) -(ac-linum-workaround) -(setq ac-ignore-case nil) -(setq ac-use-menu-map t) -(define-key ac-menu-map "\C-n" 'ac-next) -(define-key ac-menu-map "\C-p" 'ac-previous) -;;(add-to-list 'ac-modes 'python-mode) - - -;; highlight-indentation -(require 'highlight-indentation) -(add-hook 'prog-mode-hook 'highlight-indentation) - - -;; mac hook for esc map to meta-key -;;(set-keyboard-coding-system nil) - - -;; TODO: Do something like at -;; http://www.enigmacurry.com/2009/01/21/autocompleteel-python-code-completion-in-emacs/ -;; to make this also be smart about Python (e.g., complete after . in a module -;; name). - - -(defun iwb () - "indent whole buffer" - (interactive) - (delete-trailing-whitespace) - (indent-region (point-min) (point-max) nil) - (untabify (point-min) (point-max))) - - -(put 'set-goal-column 'disabled nil) - - -(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. - '(show-trailing-whitespace t)) -(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. - ) - - -(require 'uniquify) - -(setq uniquify-buffer-name-style 'reverse) -(setq uniquify-separator " • ") -(setq uniquify-after-kill-buffer-p t) -(setq uniquify-ignore-buffers-re "^\\*") - - -(provide 'init-uniquify) - -;;flymake settings - -(add-hook 'find-file-hook 'flymake-find-file-hook) -(when (load "flymake" t) - (defun flymake-pyflakes-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 "epylint" (list local-file)))) - (add-to-list 'flymake-allowed-file-name-masks - '("\\.py\\'" flymake-pyflakes-init))) - -(load-library "flymake-cursor") -(global-set-key [f10] 'flymake-goto-prev-error) -(global-set-key [f11] 'flymake-goto-next-error) -(custom-set-faces - '(flymake-warnline ((((class color)) (:underline t :foreground "Orange")))) - '(flymake-errline ((((class color)) (:underline t :foreground "OrangeRed"))))) - -;; for python-pep8 -(require `tramp) -(require 'python-pep8) - - -;; do not forget to set up PYTHONPATH for pylint, else it will not work. Add -;; this script to .bashrc file - -;;(add-hook 'python-mode-hook -;; '(lambda () (eldoc-mode 1)) t) - -(provide 'python-programming) - -;; (defvar ac-source-python -;; '((candidates . -;; (lambda () -;; (mapcar '(lambda (completion) -;; (first (last (split-string completion "\\." t)))) -;; (python-symbol-completions (python-partial-symbol))))))) -;; (add-hook 'python-mode-hook -;; (lambda() (setq ac-sources '(ac-source-python)))) - -;; makea auto-complete work..some blob of code I have not bothered to understand -;; yet. - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Auto-completion -;;; Integrates: -;;; 1) Rope -;;; 2) Yasnippet -;;; all with AutoComplete.el -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defun prefix-list-elements (list prefix) - (let (value) - (nreverse - (dolist (element list value) - (setq value (cons (format "%s%s" prefix element) value)))))) -(defvar ac-source-rope - '((candidates - . (lambda () - (prefix-list-elements (rope-completions) ac-target)))) - "Source for Rope") -(defun ac-python-find () - "Python `ac-find-function'." - (require 'thingatpt) - (let ((symbol (car-safe (bounds-of-thing-at-point 'symbol)))) - (if (null symbol) - (if (string= "." (buffer-substring (- (point) 1) (point))) - (point) - nil) - symbol))) -(defun ac-python-candidate () - "Python `ac-candidates-function'" - (let (candidates) - (dolist (source ac-sources) - (if (symbolp source) - (setq source (symbol-value source))) - (let* ((ac-limit (or (cdr-safe (assq 'limit source)) ac-limit)) - (requires (cdr-safe (assq 'requires source))) - cand) - (if (or (null requires) - (>= (length ac-target) requires)) - (setq cand - (delq nil - (mapcar (lambda (candidate) - (propertize candidate 'source source)) - (funcall (cdr (assq 'candidates source))))))) - (if (and (> ac-limit 1) - (> (length cand) ac-limit)) - (setcdr (nthcdr (1- ac-limit) cand) nil)) - (setq candidates (append candidates cand)))) - (delete-dups candidates))) - - -(add-hook 'python-mode-hook - (lambda () - (auto-complete-mode t) - (set (make-local-variable 'ac-sources) '(ac-source-rope)) -;; (append ac-sources '(ac-source-rope))) ;; '(ac-source-yasnippet))) - (set (make-local-variable 'ac-find-function) 'ac-python-find) - (set (make-local-variable 'ac-candidate-function) 'ac-python-candidate) - (set (make-local-variable 'ac-auto-start) nil) - )) - - -;;Ryan's python specific tab completion -(defun ryan-python-tab () - ;; Try the following: - ;; 1) Do a yasnippet expansion - ;; 2) Do a Rope code completion - ;; 3) Do an indent - (interactive) - (if (eql (ac-start) t) - (indent-for-tab-command))) - -;; (defadvice ac-start (before advice-turn-on-auto-start activate) -;; (set (make-local-variable 'ac-auto-start) 1)) -;; (defadvice ac-cleanup (after advice-turn-off-auto-start activate) -;; (set (make-local-variable 'ac-auto-start) nil)) - - -;; (add-hook 'python-mode-hook -;; (lambda () -;; (define-key python-mode-map "\t" 'ryan-python-tab) - -;; )) - - -;;End Auto Completion - -(setq ropemacs-enable-autoimport t) -(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) -(add-to-list 'interpreter-mode-alist '("python" . python-mode)) - - -;; (defun generate-header() -;; (interactive) -;; (setq x (cdr(split-string (thing-at-point 'sentence) "[?\(?\,?\:?\?\ )]" -;; ))) -;; (forward-line 1) -;; (insert "\t\"\"\"\n\n\n") -;; (while x -;; (if (/= (length (chomp (car x))) 0) -;; (progn -;; (insert "\t:param ") -;; (insert (chomp (car x))) -;; (insert ": \n"))) -;; (setq x (cdr x))) -;; (insert "\n\t\"\"\"\n\n")) - - -(defun get-function-definition(sentence) - (message sentence) - (if (string-match "def.*(.*):" sentence) - (match-string 0 sentence)) - ) - -(defun get-parameters(sentence) - (setq y (get-function-definition sentence)) - (message y) - (if y - (if (string-match "(.*)" y) - (match-string 0 y))) - ) - - -(require 'thingatpt) -(defun generate-header() - (interactive) - (setq p (get-parameters (thing-at-point 'sentence))) - (forward-line 1) - (insert "\t\"\"\"\n\n\n") - (setq params (split-string p "[?\,?\(?\)?\ ]")) - (while params - (if (/= (length (chomp (car params))) 0) - (progn - (insert "\t:param ") - (insert (chomp (car params))) - (insert ": \n"))) - (setq params (cdr params))) - (insert "\n\t\"\"\"\n\n") - ) - -;; settings from http://ergoemacs.org/emacs/emacs_editing_lisp.html -;; highlight text selection (on by default since emacs 23.2) -(transient-mark-mode 1) +(require 'org) -;; make typing overwrite text selection -(delete-selection-mode 1) ; this turns on transient-mark-mode automatically +(org-add-link-type "rtcite" + 'org-bibtex-open + 'my-rtcite-export-handler) -;; turn on highlight matching brackets when cursor is on one -(show-paren-mode 1) -(setq show-paren-style 'parenthesis) ; highlight just parens -;;(setq show-paren-style 'expression) ; highlight entire expression +;; orgmode to latex +(require 'org-latex) +(unless (boundp 'org-export-latex-classes) + (setq org-export-latex-classes nil)) +(add-to-list 'org-export-latex-classes + '("article" + "\\documentclass{article}" + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) \ No newline at end of file