unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#15137: python mode patch
@ 2013-08-19 21:25 Daniel Elliott
  2013-08-27  1:54 ` Stefan Monnier
  2013-09-02 14:16 ` fgallina
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Elliott @ 2013-08-19 21:25 UTC (permalink / raw)
  To: 15137

Hello,

I'm submitting a patch that has been tremendously helpful to me.
Please consider this for addition into the next release of the world's
most excellent editor.

2013-08-19  Dan Elliott  <danelliottster@gmail.com>

        * progmodes/python.el (python-shell-send-region): added fix
suggested by Barry Warsaw for python-mode.el to fix unexpected
indentation error w\
hen sending region to interpreter



=== modified file 'lisp/progmodes/python.el'
*** lisp/progmodes/python.el    2013-08-16 05:15:51 +0000
--- lisp/progmodes/python.el    2013-08-19 21:14:34 +0000
*************** Returns the output.  See `python-shell-s
*** 2128,2134 ****
        ;; When sending a region, add blank lines for non sent code so
        ;; backtraces remain correct.
        (make-string (1- line-num) ?\n))
!     (buffer-substring start end))
     nil t))

  (defun python-shell-send-buffer (&optional arg)
--- 2128,2137 ----
        ;; When sending a region, add blank lines for non sent code so
        ;; backtraces remain correct.
        (make-string (1- line-num) ?\n))
!     ;; wrap with a conditional to avoid errors about python
unexpected indentation
!     "if True:\n"
!     (buffer-substring start end)
!     "\n")
     nil t))

  (defun python-shell-send-buffer (&optional arg)

Thank you for all of your hard work.

- dan





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15137: python mode patch
  2013-08-19 21:25 bug#15137: python mode patch Daniel Elliott
@ 2013-08-27  1:54 ` Stefan Monnier
  2013-08-31 12:44   ` fabian
  2013-09-02 14:16 ` fgallina
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2013-08-27  1:54 UTC (permalink / raw)
  To: Daniel Elliott, Fabián E. Gallina; +Cc: 15137

> !     (buffer-substring start end))
[...]
> !     ;; wrap with a conditional to avoid errors about python unexpected indentation
> !     "if True:\n"
> !     (buffer-substring start end)
> !     "\n")

That looks pretty good, thank you.
Fabián, could you take a look?


        Stefan





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15137: python mode patch
  2013-08-27  1:54 ` Stefan Monnier
@ 2013-08-31 12:44   ` fabian
  2013-09-01  7:25     ` Andreas Röhler
  2013-09-09 14:15     ` Daniel Elliott
  0 siblings, 2 replies; 6+ messages in thread
From: fabian @ 2013-08-31 12:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Daniel Elliott, Fabián E. Gallina, 15137


monnier@iro.umontreal.ca writes:

>> !     (buffer-substring start end))
> [...]
>> !     ;; wrap with a conditional to avoid errors about python unexpected indentation
>> !     "if True:\n"
>> !     (buffer-substring start end)
>> !     "\n")
>
> That looks pretty good, thank you.
> Fabián, could you take a look?
>

The idea is good but the patch needs bit more of work -- this approach
will work when an indented region is sent but won't when sending a
region which starts with no indentation at all. Also backtraces numbers
will be wrong for a -1 offset.

I'll push something for this soon.


Regards,
Fabián.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15137: python mode patch
  2013-08-31 12:44   ` fabian
@ 2013-09-01  7:25     ` Andreas Röhler
  2013-09-09 14:15     ` Daniel Elliott
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Röhler @ 2013-09-01  7:25 UTC (permalink / raw)
  To: 15137

Am 31.08.2013 14:44, schrieb fabian@anue.biz:
>
> monnier@iro.umontreal.ca writes:
>
>>> !     (buffer-substring start end))
>> [...]
>>> !     ;; wrap with a conditional to avoid errors about python unexpected indentation
>>> !     "if True:\n"
>>> !     (buffer-substring start end)
>>> !     "\n")
>>
>> That looks pretty good, thank you.
>> Fabián, could you take a look?
>>
>
> The idea is good but the patch needs bit more of work -- this approach
> will work when an indented region is sent but won't when sending a
> region which starts with no indentation at all.

Right. Current python-mode.el shifts region-or-whatever-delivered left until it starts at column 0.

> Also backtraces numbers
> will be wrong for a -1 offset.
>

Correct. BTW there is still the Emacs count-lines bug: at BOL it counts one less than from secoond column.


> I'll push something for this soon.
>
>
> Regards,
> Fabián.
>
>
>
>






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15137: python mode patch
  2013-08-19 21:25 bug#15137: python mode patch Daniel Elliott
  2013-08-27  1:54 ` Stefan Monnier
@ 2013-09-02 14:16 ` fgallina
  1 sibling, 0 replies; 6+ messages in thread
From: fgallina @ 2013-09-02 14:16 UTC (permalink / raw)
  To: 15137-done

Solved this in revno 114108.


Regards,
Fabián.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#15137: python mode patch
  2013-08-31 12:44   ` fabian
  2013-09-01  7:25     ` Andreas Röhler
@ 2013-09-09 14:15     ` Daniel Elliott
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Elliott @ 2013-09-09 14:15 UTC (permalink / raw)
  To: fabian; +Cc: Fabián E. Gallina, 15137

Fabian,

You are correct on both counts.  Please let me know if I can be of
assistance to you.  Thanks for your time and effort.

- dan

On Sat, Aug 31, 2013 at 7:44 AM,  <fabian@anue.biz> wrote:
>
> monnier@iro.umontreal.ca writes:
>
>>> !     (buffer-substring start end))
>> [...]
>>> !     ;; wrap with a conditional to avoid errors about python unexpected indentation
>>> !     "if True:\n"
>>> !     (buffer-substring start end)
>>> !     "\n")
>>
>> That looks pretty good, thank you.
>> Fabián, could you take a look?
>>
>
> The idea is good but the patch needs bit more of work -- this approach
> will work when an indented region is sent but won't when sending a
> region which starts with no indentation at all. Also backtraces numbers
> will be wrong for a -1 offset.
>
> I'll push something for this soon.
>
>
> Regards,
> Fabián.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-09-09 14:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-19 21:25 bug#15137: python mode patch Daniel Elliott
2013-08-27  1:54 ` Stefan Monnier
2013-08-31 12:44   ` fabian
2013-09-01  7:25     ` Andreas Röhler
2013-09-09 14:15     ` Daniel Elliott
2013-09-02 14:16 ` fgallina

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).