~a-roehler/python-mode/XEmacs-compat-test

« back to all changes in this revision

Viewing changes to tools/python-mode-utils.el

  • Committer: Andreas Roehler
  • Date: 2012-01-19 09:26:30 UTC
  • Revision ID: andreas.roehler@online.de-20120119092630-g4xatd0hx10pc9an
`py-shell' proceedings further cleanup



Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
(setq py-shells '("python" "python2" "python2.7" "python3" "python3.2" "ipython" "jython"))
40
40
 
41
 
(defun py-provide-installed-shells-commands (&optional force)
 
41
(defun py-provide-installed-shells-commands ()
42
42
  "Reads py-shells, provides commands opening these shell. "
43
 
  (interactive "P")
44
 
  (let ((force (eq 4 (prefix-numeric-value force)))
45
 
        (temp-buffer "*Python Shell Install Buffer*")
46
 
        done)
47
 
    (unless force
48
 
      (dolist (ele py-shells)
49
 
        (unless (commandp (car (read-from-string ele)))
50
 
          (setq done t))))
51
 
    (when (or force done)
52
 
      (set-buffer (get-buffer-create temp-buffer))
53
 
      (erase-buffer)
54
 
      ;; (insert ";; Commands calling installed python shells generated by python-mode's python-mode-shell-install.el.
55
 
;; Install these commands, to get it loaded next time python-mode starts.
56
 
;; Copying it onto the end of python-mode-shell-install.el should do it. ")
57
 
      (newline)
58
 
      (dolist (ele py-shells)
59
 
        (if force
60
 
            (progn
61
 
              (insert (concat "(defun " ele " (&optional argprompt)
62
 
  \"Start an "))
63
 
              (if (string= "ipython" ele)
64
 
                  (insert "IPython")
65
 
                (insert (capitalize ele)))
66
 
              (insert (concat " interpreter in another window.
67
 
   With optional \\\\[universal-argument] user is prompted
68
 
    for options to pass to the "))
69
 
              (if (string= "ipython" ele)
70
 
                  (insert "IPython")
71
 
                (insert (capitalize ele)))
72
 
              (insert (concat " interpreter. \"
73
 
  (interactive)
74
 
  (let ((py-shell-name \"" ele "\"))
75
 
    (local-unset-key [tab])
76
 
    (define-key py-shell-map [tab] 'py-shell-complete)
77
 
    (py-shell argprompt)))\n\n")))
78
 
          (unless (commandp (car (read-from-string ele)))
79
 
            (insert (concat "(defun " ele " (&optional argprompt)
80
 
  \"Start an "))
81
 
            (if (string= "ipython" ele)
82
 
                (insert "IPython")
83
 
              (insert (capitalize ele)))
84
 
            (insert (concat " interpreter in another window.
85
 
   With optional \\\\[universal-argument] user is prompted
86
 
    for options to pass to the "))
87
 
            (if (string= "ipython" ele)
88
 
                (insert "IPython")
89
 
              (insert (capitalize ele)))
90
 
            (insert (concat " interpreter. \"
91
 
  (interactive)
92
 
  (let ((py-shell-name \"" ele "\"))
93
 
    (local-unset-key [tab])
94
 
    (define-key py-shell-map [tab] 'py-shell-complete)
95
 
    (py-shell argprompt)))\n\n")))))))
 
43
  (interactive)
 
44
  (let ((temp-buffer "*Python Shell Install Buffer*"))
 
45
    (set-buffer (get-buffer-create temp-buffer))
 
46
    (erase-buffer) 
 
47
    (insert ";;; Python named shells")
 
48
    (newline)
 
49
    (dolist (ele py-shells)
 
50
      (insert (concat "(defun " ele " (&optional argprompt)
 
51
  \"Start an "))
 
52
      (if (string= "ipython" ele)
 
53
          (insert "IPython")
 
54
        (insert (capitalize ele)))
 
55
      (insert (concat " interpreter in another window.
 
56
   With optional \\\\[universal-argument] user is prompted
 
57
    for options to pass to the "))
 
58
      (if (string= "ipython" ele)
 
59
          (insert "IPython")
 
60
        (insert (capitalize ele)))
 
61
      (insert (concat " interpreter. \"
 
62
  (interactive)
 
63
  (py-set-shell-completion-environment)
 
64
  (py-shell argprompt nil \"" ele "\"))\n\n")))
 
65
    (insert ";; dedicated\n")
 
66
    (dolist (ele py-shells)
 
67
      (insert (concat "(defun " ele "-dedicated (&optional argprompt)
 
68
  \"Start an "))
 
69
      (if (string= "ipython" ele)
 
70
          (insert "IPython")
 
71
        (insert (capitalize ele)))
 
72
      (insert (concat " dedicated interpreter in another window.
 
73
   With optional \\\\[universal-argument] user is prompted
 
74
    for options to pass to the "))
 
75
      (if (string= "ipython" ele)
 
76
          (insert "IPython")
 
77
        (insert (capitalize ele)))
 
78
      (insert (concat " interpreter. \"
 
79
  (interactive)
 
80
  (py-set-shell-completion-environment)
 
81
  (py-shell argprompt t \"" ele "\"))\n\n"))))
96
82
  (emacs-lisp-mode)
97
83
  (switch-to-buffer (current-buffer)))
98
84