;;; Nick Alexander's python, ipython, pyrex and sage configuration ;; (add-to-list 'load-path (expand-file-name "~/emacs/python-mode")) ;; (add-to-list 'interpreter-mode-alist '("python" . python-mode)) ;; (autoload 'python-mode "python-mode" "Python editing mode." t) ;; ;; pyrex-mode stands on its own ;; (load (expand-file-name "~/emacs/sage/pyrex-mode")) ;; (add-to-list 'auto-mode-alist '("\\.spyx\\'" . pyrex-mode)) ;; (add-to-list 'auto-mode-alist '("\\.pyx\\'" . pyrex-mode)) ;; (add-to-list 'auto-mode-alist '("\\.pxd\\'" . pyrex-mode)) ;; ;; sage-mode ;; (load (expand-file-name "~/emacs/sage/sage")) ;; (require 'ipython) ;; (setq ipython-command "/Users/nalexand/bin/sage") ;; ; (setq py-python-command "/Users/nalexand/bin/sage") ;; ; (setq py-python-command-args nil) ;; '("-ipython")) ;; (setq ansi-color-for-comint-mode t) ;; (fset 'py-shell-fullscreen ;; [?\M-x ?p ?y ?- ?s ?h ?e ?l ?l return ?\C-x ?1]) ;; (define-key esc-map "i" 'py-shell-fullscreen) ;; (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) ;; (add-to-list 'auto-mode-alist '("\\.pxi\\'" . python-mode)) ;; (add-to-list 'auto-mode-alist '("\\.sage\\'" . python-mode)) ;; customization ;; (require 'column-marker) ;; (require 'python) ;; (require 'pyrex "pyrex-mode") ;; (require 'sage "sage-mode") (defun nca-python-mode-hook () (interactive) ; auto-fill-mode ;; (turn-on-auto-fill) ; Mark far right column in programming modes (column-marker-1 78) ; Use python completion last, not first (setq hippie-expand-try-functions-list (append (remove 'python-try-complete hippie-expand-try-functions-list) (list 'python-try-complete))) ; Always blah-and-go ) ;;; original `python-switch-to-python' insists on switching window ;;; original `python-switch-to-python' prints a message, which ;;; obliterates legitimate output before hand. (defadvice python-switch-to-python (around nca-python-switch-to-python first (eob-p)) "Switch to the Python process buffer, maybe starting new process. With prefix arg, position cursor at end of buffer." (interactive "P") (pop-to-buffer (process-buffer (python-proc))) ; Runs python if needed. (when eob-p (push-mark (point) t) ; don't display a "Mark set" message (goto-char (point-max)))) (ad-activate 'python-switch-to-python) (defun nca-python-switch-to-python () "Switch to python and go to eob." (interactive) (python-switch-to-python t)) (defadvice python-send-region (after nca-python-send-region-and-go last) "Always bring python-buffer forward and go when sending from user land." (nca-python-switch-to-python)) (ad-activate 'python-send-region) (defadvice python-load-file (after nca-python-load-file-and-go last) "Always bring python-buffer forward and go when loading." (nca-python-switch-to-python)) (ad-activate 'python-load-file) ;;; I'm want SAGE so often, let's make it global (global-set-key "\C-c\C-z" 'run-sage) ; nca-python-switch-to-python) (global-set-key "\C-c\C-t" 'sage-test) (global-set-key "\C-c\C-b" 'sage-build) (add-hook 'python-mode-hook 'nca-python-mode-hook) (add-hook 'sage-mode-hook 'nca-python-mode-hook) (add-hook 'pyrex-mode-hook 'nca-python-mode-hook) (add-hook 'sage-mode-hook 'sage-bindings) (add-hook 'pyrex-mode-hook 'sage-bindings)