diff options
| author | Fabián Ezequiel Gallina | 2014-12-27 17:22:29 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2014-12-27 17:22:29 -0300 |
| commit | 433af0a06089885f5a57ef0f3e7d6283e8d51bd5 (patch) | |
| tree | 982766b3e0d415584d1d06c08b5cebb1bc16dd47 /lisp/progmodes/python.el | |
| parent | a5f38fa1cc8eafe13f2073ebfaa8205b5e919d17 (diff) | |
| download | emacs-433af0a06089885f5a57ef0f3e7d6283e8d51bd5.tar.gz emacs-433af0a06089885f5a57ef0f3e7d6283e8d51bd5.zip | |
* lisp/progmodes/python.el (python-shell-buffer-substring): Handle
cornercase when region sent starts at point-min.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 4a4e320cd65..0d80110f7b7 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -2523,17 +2523,16 @@ the python shell: | |||
| 2523 | 4. Wraps indented regions under an \"if True:\" block so the | 2523 | 4. Wraps indented regions under an \"if True:\" block so the |
| 2524 | interpreter evaluates them correctly." | 2524 | interpreter evaluates them correctly." |
| 2525 | (let* ((substring (buffer-substring-no-properties start end)) | 2525 | (let* ((substring (buffer-substring-no-properties start end)) |
| 2526 | (buffer-substring-p (save-restriction | 2526 | (starts-at-point-min-p (save-restriction |
| 2527 | (widen) | 2527 | (widen) |
| 2528 | (not (equal (list (point-min) (point-max)) | 2528 | (= (point-min) start))) |
| 2529 | (list start end))))) | ||
| 2530 | (encoding (python-info-encoding)) | 2529 | (encoding (python-info-encoding)) |
| 2531 | (fillstr (concat | 2530 | (fillstr (when (not starts-at-point-min-p) |
| 2532 | (when buffer-substring-p | 2531 | (concat |
| 2533 | (format "# -*- coding: %s -*-\n" encoding)) | 2532 | (format "# -*- coding: %s -*-\n" encoding) |
| 2534 | (make-string | 2533 | (make-string |
| 2535 | (- (line-number-at-pos start) | 2534 | ;; Substract 2 because of the coding cookie. |
| 2536 | (if buffer-substring-p 2 1)) ?\n))) | 2535 | (- (line-number-at-pos start) 2) ?\n)))) |
| 2537 | (toplevel-block-p (save-excursion | 2536 | (toplevel-block-p (save-excursion |
| 2538 | (goto-char start) | 2537 | (goto-char start) |
| 2539 | (or (zerop (line-number-at-pos start)) | 2538 | (or (zerop (line-number-at-pos start)) |