unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21242: 24.5.1; python.el: should display output buffer on exceptions when using python-shell-send-region
@ 2015-08-12 14:05 Yuri D'Elia
  2015-08-13  6:48 ` Andreas Röhler
  2020-09-17 18:01 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Yuri D'Elia @ 2015-08-12 14:05 UTC (permalink / raw)
  To: 21242

[-- Attachment #1: Type: text/plain, Size: 811 bytes --]

When evaluating the code interactively, there's currently no
notification about evaluation errors. Exceptions in the output buffer go
simply unnoticed, unless you watch for them closely. I like to keep the
output buffer buried, and assume that no-notification==no-error.

Exceptions caused by interactive evaluation should either:

- show a notification of sorts in the minibuffer
- display the output buffer for inspection

For inspiration about the second, see:

https://github.com/wavexx/python-x.el/blob/master/python-x.el#L424

Given previous experience with python-mode.el (which tends to break the
current window layout with his own splitting logic), I find it important
that the notification function (which displays the output buffer) should
be customizable, and this is reflected in the example code.

[-- Attachment #2: python-buffer-substring.patch --]
[-- Type: text/x-diff, Size: 1471 bytes --]

--- python.el.Orig	2015-07-18 18:00:49.367517569 +0200
+++ python.el	2015-07-18 18:03:01.203659502 +0200
@@ -2548,18 +2548,22 @@
                      (make-string
                       ;; Subtract 2 because of the coding cookie.
                       (- (line-number-at-pos start) 2) ?\n))))
-         (toplevel-block-p (save-excursion
-                             (goto-char start)
-                             (or (zerop (line-number-at-pos start))
-                                 (progn
-                                   (python-util-forward-comment 1)
-                                   (zerop (current-indentation)))))))
+         (block-param (save-excursion
+                        (goto-char start)
+                        (progn
+                          (python-util-forward-comment 1)
+                          (list (current-indentation)
+                                (/= (point) start)))))
+         (block-indentation (car block-param))
+         (starts-with-indentation-p (cadr block-param)))
     (with-temp-buffer
       (python-mode)
       (if fillstr (insert fillstr))
+      (when (and (> block-indentation 0) (not starts-with-indentation-p))
+        (insert (make-string block-indentation ?\s)))
       (insert substring)
       (goto-char (point-min))
-      (when (not toplevel-block-p)
+      (when (> block-indentation 0)
         (insert "if True:")
         (delete-region (point) (line-end-position)))
       (when nomain


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

* bug#21242: 24.5.1; python.el: should display output buffer on exceptions when using python-shell-send-region
  2015-08-12 14:05 bug#21242: 24.5.1; python.el: should display output buffer on exceptions when using python-shell-send-region Yuri D'Elia
@ 2015-08-13  6:48 ` Andreas Röhler
  2020-09-17 18:01 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Andreas Röhler @ 2015-08-13  6:48 UTC (permalink / raw)
  To: 21242


Am 12.08.2015 um 16:05 schrieb Yuri D'Elia:
> When evaluating the code interactively, there's currently no
> notification about evaluation errors. Exceptions in the output buffer go
> simply unnoticed, unless you watch for them closely. I like to keep the
> output buffer buried, and assume that no-notification==no-error.
>
> Exceptions caused by interactive evaluation should either:
>
> - show a notification of sorts in the minibuffer
> - display the output buffer for inspection
>
> For inspiration about the second, see:
>
> https://github.com/wavexx/python-x.el/blob/master/python-x.el#L424
>
> Given previous experience with python-mode.el (which tends to break the
> current window layout with his own splitting logic), I find it important
> that the notification function (which displays the output buffer) should
> be customizable, and this is reflected in the example code.

WRT python-mode.el:

Splitting-behavior _is_ customizable. It only occurs if 
py-split-window-on-execute is non-nil - default is 'just-two.
Also there is py-keep-windows-configuration, when non-nil it precedes 
other settings.





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

* bug#21242: 24.5.1; python.el: should display output buffer on exceptions when using python-shell-send-region
  2015-08-12 14:05 bug#21242: 24.5.1; python.el: should display output buffer on exceptions when using python-shell-send-region Yuri D'Elia
  2015-08-13  6:48 ` Andreas Röhler
@ 2020-09-17 18:01 ` Lars Ingebrigtsen
  2020-09-17 18:44   ` Yuri D'Elia
  1 sibling, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-17 18:01 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: 21242

Yuri D'Elia <wavexx@thregr.org> writes:

> When evaluating the code interactively, there's currently no
> notification about evaluation errors. Exceptions in the output buffer go
> simply unnoticed, unless you watch for them closely. I like to keep the
> output buffer buried, and assume that no-notification==no-error.
>
> Exceptions caused by interactive evaluation should either:
>
> - show a notification of sorts in the minibuffer
> - display the output buffer for inspection

I don't use this stuff a lot, but I just don't understand how the patch
attached relates to the reported problem.

And there's also Andreas's comment (at the end).

Yuri, could you explain a bit more about how this patch fixes the
problem?

> -         (toplevel-block-p (save-excursion
> -                             (goto-char start)
> -                             (or (zerop (line-number-at-pos start))
> -                                 (progn
> -                                   (python-util-forward-comment 1)
> -                                   (zerop (current-indentation)))))))
> +         (block-param (save-excursion
> +                        (goto-char start)
> +                        (progn
> +                          (python-util-forward-comment 1)
> +                          (list (current-indentation)
> +                                (/= (point) start)))))
> +         (block-indentation (car block-param))
> +         (starts-with-indentation-p (cadr block-param)))
>      (with-temp-buffer
>        (python-mode)
>        (if fillstr (insert fillstr))
> +      (when (and (> block-indentation 0) (not starts-with-indentation-p))
> +        (insert (make-string block-indentation ?\s)))
>        (insert substring)
>        (goto-char (point-min))
> -      (when (not toplevel-block-p)
> +      (when (> block-indentation 0)
>          (insert "if True:")
>          (delete-region (point) (line-end-position)))

Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

>> Given previous experience with python-mode.el (which tends to break the
>> current window layout with his own splitting logic), I find it important
>> that the notification function (which displays the output buffer) should
>> be customizable, and this is reflected in the example code.
>
> WRT python-mode.el:
>
> Splitting-behavior _is_ customizable. It only occurs if
> py-split-window-on-execute is non-nil - default is 'just-two.
> Also there is py-keep-windows-configuration, when non-nil it precedes
> other settings.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#21242: 24.5.1; python.el: should display output buffer on exceptions when using python-shell-send-region
  2020-09-17 18:01 ` Lars Ingebrigtsen
@ 2020-09-17 18:44   ` Yuri D'Elia
  2020-09-18 11:07     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Yuri D'Elia @ 2020-09-17 18:44 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 21242

On Thu, Sep 17 2020, Lars Ingebrigtsen wrote:
> I don't use this stuff a lot, but I just don't understand how the patch
> attached relates to the reported problem.
>
> And there's also Andreas's comment (at the end).
>
> Yuri, could you explain a bit more about how this patch fixes the
> problem?

I won't lie here, I have _no_ clue anymore what I had in mind with that
code at a first glance.





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

* bug#21242: 24.5.1; python.el: should display output buffer on exceptions when using python-shell-send-region
  2020-09-17 18:44   ` Yuri D'Elia
@ 2020-09-18 11:07     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-18 11:07 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: 21242

Yuri D'Elia <wavexx@thregr.org> writes:

>> Yuri, could you explain a bit more about how this patch fixes the
>> problem?
>
> I won't lie here, I have _no_ clue anymore what I had in mind with that
> code at a first glance.

:-)

But it sounds like there probably won't be more progress here in this
bug report, then, so I'm closing it.  If further progress can be made,
please respond to the debbugs address, and we'll reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2020-09-18 11:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-12 14:05 bug#21242: 24.5.1; python.el: should display output buffer on exceptions when using python-shell-send-region Yuri D'Elia
2015-08-13  6:48 ` Andreas Röhler
2020-09-17 18:01 ` Lars Ingebrigtsen
2020-09-17 18:44   ` Yuri D'Elia
2020-09-18 11:07     ` Lars Ingebrigtsen

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).