summaryrefslogtreecommitdiff
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el51
1 files changed, 25 insertions, 26 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 09b89993626..620ea8cd519 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -69,11 +69,7 @@
(require 'comint)
(require 'ansi-color)
-(eval-when-compile
- (require 'compile)
- (require 'hippie-exp))
-
-(autoload 'comint-mode "comint")
+(eval-when-compile (require 'compile))
(defgroup python nil
"Silly walks in the Python language."
@@ -1488,8 +1484,6 @@ Don't save anything for STR matching `inferior-python-filter-regexp'."
res)
(t (concat res s)))))
-(autoload 'comint-check-proc "comint")
-
(defvar python-version-checked nil)
(defun python-check-version (cmd)
"Check that CMD runs a suitable version of Python."
@@ -1607,7 +1601,7 @@ behavior, change `python-remove-cwd-from-path' to nil."
;; Fixme: Write a `coding' header to the temp file if the region is
;; non-ASCII.
(interactive "r")
- (let* ((f (make-temp-file "py"))
+ (let* ((f (make-temp-file "py" nil ".py"))
(command
;; IPython puts the FakeModule module into __main__ so
;; emacs.eexecfile becomes useless.
@@ -1684,8 +1678,6 @@ value to determine defaults."
"Caches (directory . file) pair used in the last `python-load-file' command.
Used for determining the default in the next one.")
-(autoload 'comint-get-source "comint")
-
(defun python-load-file (file-name)
"Load a Python file FILE-NAME into the inferior Python process.
If the file has extension `.py' import or reload it as a module.
@@ -1776,7 +1768,7 @@ will."
;; allow C-c C-f in help buffer.
(let ((temp-buffer-show-hook ; avoid xref stuff
(lambda ()
- (toggle-read-only 1)
+ (setq buffer-read-only t)
(setq view-return-to-alist
(list (cons (selected-window) help-return-method))))))
(with-output-to-temp-buffer (help-buffer)
@@ -2476,15 +2468,6 @@ with skeleton expansions for compound statement templates.
nil t)
(add-hook 'completion-at-point-functions
'python-completion-at-point nil 'local)
- ;; Fixme: should be in hideshow. This seems to be of limited use
- ;; since it isn't (can't be) indentation-based. Also hide-level
- ;; doesn't seem to work properly.
- (add-to-list 'hs-special-modes-alist
- `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#"
- ,(lambda (_arg)
- (python-end-of-defun)
- (skip-chars-backward " \t\n"))
- nil))
(set (make-local-variable 'skeleton-further-elements)
'((< '(backward-delete-char-untabify (min python-indent
(current-column))))
@@ -2623,9 +2606,17 @@ problem."
(let* ((filename (match-string 1 block))
(lineno (string-to-number (match-string 2 block)))
(funcname (match-string 3 block))
+ (msg (get-text-property 0 'compilation-message filename))
+ (loc (and msg (compilation--message->loc msg)))
funcbuffer)
- (cond ((file-exists-p filename)
+ (cond ((and loc (markerp (compilation--loc->marker loc)))
+ (setq funcbuffer (marker-buffer (compilation--loc->marker loc)))
+ (list (with-current-buffer funcbuffer
+ (line-number-at-pos (compilation--loc->marker loc)))
+ funcbuffer))
+
+ ((file-exists-p filename)
(list lineno (find-file-noselect filename)))
((setq funcbuffer (python-pdbtrack-grub-for-buffer funcname lineno))
@@ -2643,15 +2634,12 @@ problem."
(buffer-substring
(point-min) (point-max)))
)))))))
- (list lineno funcbuffer))
+ (list lineno funcbuffer))
((= (elt filename 0) ?\<)
(format "(Non-file source: '%s')" filename))
- (t (format "Not found: %s(), %s" funcname filename)))
- )
- )
- )
+ (t (format "Not found: %s(), %s" funcname filename))))))
(defun python-pdbtrack-grub-for-buffer (funcname _lineno)
"Find recent Python mode buffer named, or having function named FUNCNAME."
@@ -2725,6 +2713,17 @@ comint believe the user typed this string so that
;; continue standard unloading
nil)
+;;;; Finish up
+;; Fixme: should be in hideshow. This seems to be of limited use
+;; since it isn't (can't be) indentation-based. Also hide-level
+;; doesn't seem to work properly.
+(add-to-list 'hs-special-modes-alist
+ `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#"
+ ,(lambda (_arg)
+ (python-end-of-defun)
+ (skip-chars-backward " \t\n"))
+ nil))
+
(provide 'python)
(provide 'python-21)