Created
March 22, 2012 08:22
-
-
Save copyninja/2157110 to your computer and use it in GitHub Desktop.
My customization to make it easy to learn python3 using emacs without breaking working of existing python related stuff
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
;; Python3 customization | |
;; Path to Python3 only required for windows.. :) | |
(setq python3-executable "C:/Users/invakam2/Documents/Programs/python3.2/App/python.exe") | |
;; Function similar to python-shell but this | |
;; is my crude implementation | |
(defun python3-shell() | |
(interactive) | |
;; explicit-shell-file-name if non nil it will be used by M-x shell | |
;; as shell to be executed | |
(setq explicit-shell-file-name | |
python3-executable) | |
;; Now launch shell (Python3) | |
(shell) | |
;; Lets have Python3 as name | |
(rename-buffer "*Python3*") | |
;; Now reset the variable I don't want to mess around | |
(setq explicit-shell-file-name nil)) | |
(defun run-python3(script-file) | |
;; Gee I don't know how this works nor I know this is how we take input | |
;; D goes for Directory and I threw a stone in dark thinking f takes file | |
;; and it did take file name!.. | |
;; Now don't ask me how the file-name gets assigned to script-file symbol | |
;; I don't have a clue! | |
(interactive "fScript Name: ") | |
(let ( | |
;; Output buffer | |
( python-output "Python3-Output")) | |
;; Split winows vertically | |
(split-window-vertically) | |
;; move to down part of split windows | |
(windmove-down) | |
;; now create and change to buffer | |
(switch-to-buffer (get-buffer-create python-output)) | |
;; Insert the output to buffer! | |
(insert (apply #'call-process python3-executable nil t nil (list script-file))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Holy cow this is useful! I am new to Emacs and have been groaning over my inability to run both python 2 and python 3 shells. Nothing I did to the python mode files helped. Now there's this!