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

« back to all changes in this revision

Viewing changes to python-mode.el

  • Committer: Andreas Roehler
  • Date: 2011-10-27 10:14:29 UTC
  • Revision ID: andreas.roehler@online.de-20111027101429-1f5sg5jj4ro3ar5k
Pymacs integrated

No separate install required any more, works
out-of-the-box.

Customize `py-install-directory', if Pymacs should run from
other place than default set by python-mode.el.

If `py-install-directory' is nil, python-mode assumes
 it's default directory `pymacs' beneath location where
 python-mode.el resides

Show diffs side-by-side

added added

removed removed

Lines of Context:
435
435
 
436
436
;; (defcustom python-send-receive-delay  5
437
437
;;  "Seconds to wait for output, used by `python-send-receive'. "
438
 
;; 
 
438
;;
439
439
;; :type 'number
440
440
;; :group 'python)
441
441
 
1525
1525
  :type 'boolean
1526
1526
  :group 'python)
1527
1527
 
 
1528
;; Pymacs start
 
1529
(defcustom py-load-python-mode-pymacs-p  t
 
1530
 "If Pymacs as delivered with python-mode.el shall be loaded.
 
1531
Default is non-nil.
 
1532
 
 
1533
Pymacs has been written by François Pinard and many others.
 
1534
See original source: http://pymacs.progiciels-bpi.ca"
 
1535
 
 
1536
:type 'boolean
 
1537
:group 'python)
 
1538
 
 
1539
;; Pymacs end
 
1540
 
1528
1541
(defun py-switch-imenu-index-function ()
1529
1542
  "For development only. Good old renamed `py-imenu-create-index'-function hangs with medium size files already. Working `py-imenu-create-index-new' is active by default.
1530
1543
 
1776
1789
 
1777
1790
If `py-install-directory' isn't set, guess from buffer-file-name. "
1778
1791
  (interactive)
1779
 
  (cond ((ignore-errors py-install-directory)
 
1792
  (cond (py-install-directory
1780
1793
         (add-to-list 'load-path (expand-file-name py-install-directory))
1781
1794
         (add-to-list 'load-path (concat (expand-file-name py-install-directory) "/completion"))
1782
1795
         (add-to-list 'load-path (concat py-install-directory "/pymacs"))
1783
1796
         (add-to-list 'load-path (concat (expand-file-name py-install-directory) "/test"))
1784
1797
         (add-to-list 'load-path (concat (expand-file-name py-install-directory) "/tools")))
1785
 
        ((string-match "/test$" default-directory)
1786
 
         (add-to-list 'load-path (concat (expand-file-name "../") "completion"))
1787
 
         (add-to-list 'load-path (concat (expand-file-name "../") "pymacs"))
1788
 
         (add-to-list 'load-path (concat (expand-file-name "../") "test"))
1789
 
         (add-to-list 'load-path (concat (expand-file-name "../") "tools")))
1790
 
        (t
1791
 
         (add-to-list 'load-path (file-name-directory buffer-file-name))
1792
 
         (add-to-list 'load-path (concat (file-name-directory buffer-file-name) "completion"))
1793
 
         (add-to-list 'load-path (concat (file-name-directory buffer-file-name) "pymacs"))
1794
 
         (add-to-list 'load-path (concat (file-name-directory buffer-file-name) "test"))
1795
 
         (add-to-list 'load-path (concat (file-name-directory buffer-file-name) "tools"))))
 
1798
        (t (setq py-install-directory
 
1799
                 (file-name-directory (buffer-file-name (car (find-function-noselect 'python-mode)))))))
1796
1800
  (when (interactive-p) (message "%s" load-path)))
1797
1801
 
 
1802
(defun py-load-python-mode-pymacs ()
 
1803
  "Load Pymacs as delivered with python-mode.el.
 
1804
 
 
1805
Pymacs has been written by François Pinard and many others.
 
1806
See original source: http://pymacs.progiciels-bpi.ca"
 
1807
  (interactive)
 
1808
  (load (concat py-install-directory "/pymacs/pymacs.el") nil t)
 
1809
  ;; let's have an error immediatly, if it fails.
 
1810
  (require 'pymacs))
 
1811
 
1798
1812
(define-derived-mode python2-mode python-mode "Python2"
1799
1813
  "Edit and run code used by Python version 2 series. "
1800
1814
  :group 'Python
1934
1948
  ;; Set the default shell if not already set
1935
1949
  (when (null py-shell-name)
1936
1950
    (py-toggle-shells (py-choose-shell)))
 
1951
  (unless py-install-directory
 
1952
    (cond ((file-name-directory buffer-file-name)
 
1953
           (setq py-install-directory (file-name-directory buffer-file-name)))
 
1954
          (default-directory
 
1955
            (setq py-install-directory default-directory))))
 
1956
  (when py-load-python-mode-pymacs-p (py-load-python-mode-pymacs))
1937
1957
  (when (interactive-p) (message "python-mode loaded from: %s" "python-mode.el")))
1938
1958
 
1939
1959
(make-obsolete 'jpython-mode 'jython-mode nil)