aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el79
1 files changed, 44 insertions, 35 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index bfa507b851a..000e16013d1 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -66,10 +66,8 @@
66(require 'comint) 66(require 'comint)
67(eval-when-compile 67(eval-when-compile
68 (require 'compile) 68 (require 'compile)
69 (autoload 'Info-last "info")
70 (autoload 'Info-exit "info")
71 (autoload 'info-lookup-maybe-add-help "info-look")) 69 (autoload 'info-lookup-maybe-add-help "info-look"))
72(autoload 'compilation-start "compile") ; spurious compiler warning anyway 70(autoload 'compilation-start "compile")
73 71
74(defgroup python nil 72(defgroup python nil
75 "Silly walks in the Python language" 73 "Silly walks in the Python language"
@@ -829,7 +827,8 @@ move and return nil. Otherwise return t."
829Makes nested Imenu menus from nested `class' and `def' statements. 827Makes nested Imenu menus from nested `class' and `def' statements.
830The nested menus are headed by an item referencing the outer 828The nested menus are headed by an item referencing the outer
831definition; it has a space prepended to the name so that it sorts 829definition; it has a space prepended to the name so that it sorts
832first with `imenu--sort-by-name'." 830first with `imenu--sort-by-name' (though, unfortunately, sub-menus
831precede it)."
833 (unless (boundp 'python-recursing) ; dynamically bound below 832 (unless (boundp 'python-recursing) ; dynamically bound below
834 (goto-char (point-min))) ; normal call from Imenu 833 (goto-char (point-min))) ; normal call from Imenu
835 (let (index-alist ; accumulated value to return 834 (let (index-alist ; accumulated value to return
@@ -937,32 +936,37 @@ Additional arguments are added when the command is used by `run-python'
937et al.") 936et al.")
938 937
939(defvar python-buffer nil 938(defvar python-buffer nil
940 "*The current python process buffer. 939 "The current python process buffer."
941To run multiple Python processes, start the first with \\[run-python]. 940 ;; Fixme: a single process is currently assumed, so that this doc
942It will be in a buffer named *Python*. Rename that with 941 ;; is misleading.
943\\[rename-buffer]. Now start a new process with \\[run-python]. It 942
944will be in a new buffer, named *Python*. Switch between the different 943;; "*The current python process buffer.
945process buffers with \\[switch-to-buffer]. 944;; To run multiple Python processes, start the first with \\[run-python].
946 945;; It will be in a buffer named *Python*. Rename that with
947Commands that send text from source buffers to Python processes have 946;; \\[rename-buffer]. Now start a new process with \\[run-python]. It
948to choose a process to send to. This is determined by global variable 947;; will be in a new buffer, named *Python*. Switch between the different
949`python-buffer'. Suppose you have three inferior Pythons running: 948;; process buffers with \\[switch-to-buffer].
950 Buffer Process 949
951 foo python 950;; Commands that send text from source buffers to Python processes have
952 bar python<2> 951;; to choose a process to send to. This is determined by global variable
953 *Python* python<3> 952;; `python-buffer'. Suppose you have three inferior Pythons running:
954If you do a \\[python-send-region-and-go] command on some Python source 953;; Buffer Process
955code, what process does it go to? 954;; foo python
956 955;; bar python<2>
957- In a process buffer (foo, bar, or *Python*), send it to that process. 956;; *Python* python<3>
958- In some other buffer (e.g. a source file), send it to the process 957;; If you do a \\[python-send-region-and-go] command on some Python source
959 attached to `python-buffer'. 958;; code, what process does it go to?
960Process selection is done by function `python-proc'. 959
961 960;; - In a process buffer (foo, bar, or *Python*), send it to that process.
962Whenever \\[run-python] starts a new process, it resets `python-buffer' 961;; - In some other buffer (e.g. a source file), send it to the process
963to be the new process's buffer. If you only run one process, this will 962;; attached to `python-buffer'.
964do the right thing. If you run multiple processes, you can change 963;; Process selection is done by function `python-proc'.
965`python-buffer' to another process buffer with \\[set-variable].") 964
965;; Whenever \\[run-python] starts a new process, it resets `python-buffer'
966;; to be the new process's buffer. If you only run one process, this will
967;; do the right thing. If you run multiple processes, you can change
968;; `python-buffer' to another process buffer with \\[set-variable]."
969 )
966 970
967(defconst python-compilation-regexp-alist 971(defconst python-compilation-regexp-alist
968 `((,(rx (and line-start (1+ (any " \t")) "File \"" 972 `((,(rx (and line-start (1+ (any " \t")) "File \""
@@ -971,6 +975,9 @@ do the right thing. If you run multiple processes, you can change
971 1 python-compilation-line-number)) 975 1 python-compilation-line-number))
972 "`compilation-error-regexp-alist' for inferior Python.") 976 "`compilation-error-regexp-alist' for inferior Python.")
973 977
978;; Fixme: This should inherit some stuff from python-mode, but I'm not
979;; sure how much: at least some keybindings, like C-c C-f; syntax?;
980;; font-locking, e.g. for triple-quoted strings?
974(define-derived-mode inferior-python-mode comint-mode "Inferior Python" 981(define-derived-mode inferior-python-mode comint-mode "Inferior Python"
975 "Major mode for interacting with an inferior Python process. 982 "Major mode for interacting with an inferior Python process.
976A Python process can be started with \\[run-python]. 983A Python process can be started with \\[run-python].
@@ -997,7 +1004,8 @@ For running multiple processes in multiple buffers, see `python-buffer'.
997 (add-hook 'comint-input-filter-functions 'python-input-filter nil t) 1004 (add-hook 'comint-input-filter-functions 'python-input-filter nil t)
998 (add-hook 'comint-preoutput-filter-functions #'python-preoutput-filter 1005 (add-hook 'comint-preoutput-filter-functions #'python-preoutput-filter
999 nil t) 1006 nil t)
1000 ;; Still required by `comint-redirect-send-command', for instance: 1007 ;; Still required by `comint-redirect-send-command', for instance
1008 ;; (and we need to match things like `>>> ... >>> '):
1001 (set (make-local-variable 'comint-prompt-regexp) "^\\([>.]\\{3\\} \\)+") 1009 (set (make-local-variable 'comint-prompt-regexp) "^\\([>.]\\{3\\} \\)+")
1002 (set (make-local-variable 'compilation-error-regexp-alist) 1010 (set (make-local-variable 'compilation-error-regexp-alist)
1003 python-compilation-regexp-alist) 1011 python-compilation-regexp-alist)
@@ -1329,13 +1337,14 @@ Used with `eval-after-load'."
1329 (string-match "^Python \\([0-9]+\\.[0-9]+\\>\\)" s) 1337 (string-match "^Python \\([0-9]+\\.[0-9]+\\>\\)" s)
1330 (match-string 1 s))) 1338 (match-string 1 s)))
1331 ;; Whether info files have a Python version suffix, e.g. in Debian. 1339 ;; Whether info files have a Python version suffix, e.g. in Debian.
1332 (versioned 1340 (versioned
1333 (with-temp-buffer 1341 (with-temp-buffer
1334 (Info-mode) 1342 (with-no-warnings (Info-mode))
1335 (condition-case () 1343 (condition-case ()
1336 ;; Don't use `info' because it would pop-up a *info* buffer. 1344 ;; Don't use `info' because it would pop-up a *info* buffer.
1337 (Info-goto-node (format "(python%s-lib)Miscellaneous Index" 1345 (with-no-warnings
1338 version)) 1346 (Info-goto-node (format "(python%s-lib)Miscellaneous Index"
1347 version)))
1339 (error nil))))) 1348 (error nil)))))
1340 (info-lookup-maybe-add-help 1349 (info-lookup-maybe-add-help
1341 :mode 'python-mode 1350 :mode 'python-mode