mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-04 11:00:45 -08:00
Make Python evaluation work more reliably
* lisp/progmodes/python.el (python-shell-buffer-substring): Make more regions valid Python code (bug#55174). Copyright-paperwork-exempt: yes
This commit is contained in:
parent
2a2b3f5834
commit
5a10e6377c
2 changed files with 16 additions and 25 deletions
|
|
@ -3292,22 +3292,25 @@ the python shell:
|
|||
(goto-char start)
|
||||
(python-util-forward-comment 1)
|
||||
(current-indentation))))
|
||||
(fillstr (and (not no-cookie)
|
||||
(not starts-at-point-min-p)
|
||||
(concat
|
||||
(format "# -*- coding: %s -*-\n" encoding)
|
||||
(make-string
|
||||
;; Subtract 2 because of the coding cookie.
|
||||
(- (line-number-at-pos start) 2) ?\n)))))
|
||||
(fillstr (cond (starts-at-point-min-p
|
||||
nil)
|
||||
((not no-cookie)
|
||||
(concat
|
||||
(format "# -*- coding: %s -*-\n" encoding)
|
||||
(make-string
|
||||
;; Subtract 2 because of the coding cookie.
|
||||
(- (line-number-at-pos start) 2) ?\n)))
|
||||
(t
|
||||
(make-string (- (line-number-at-pos start) 1) ?\n)))))
|
||||
(with-temp-buffer
|
||||
(python-mode)
|
||||
(when fillstr
|
||||
(insert fillstr))
|
||||
(insert substring)
|
||||
(goto-char (point-min))
|
||||
(when (not toplevel-p)
|
||||
(insert "if True:")
|
||||
(forward-line -1)
|
||||
(insert "if True:\n")
|
||||
(delete-region (point) (line-end-position)))
|
||||
(insert substring)
|
||||
(when nomain
|
||||
(let* ((if-name-main-start-end
|
||||
(and nomain
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue