Project

General

Profile

Design #998

Emacs UI: sending empty input from cocoa5 buffer

Added by John Abbott over 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
EmacsUI
Start date:
18 Jan 2017
Due date:
% Done:

100%

Estimated time:
3.10 h
Spent time:

Description

What should the correct behaviour be when sending "empty input" to CoCoA-5 from a cocoa5-mode buffer in Emacs.

Currently cocoa5 receives an "empty line" (perhaps of length zero, or containing just white space).
And responds by printing out an empty line (and then another line with a new prompt).

In particular this happens when doing C-c C-l (or C-RET) when at the end of the cocoa5-mode buffer.


Related issues

Related to CoCoA-5 - Bug #1002: Emacs UI: cocoa5-send-line skips too many charsClosed2017-01-24

History

#1 Updated by John Abbott over 7 years ago

Consider a buffer containing the following:


1+2;

3+4;


Note that there are 3 empty lines: one at the start, one in the middle, and one at the end.

If I send the whole buffer to CoCoA-5 then it prints out:

3
7


In contrast, if I try sending the lines one at a time, starting on the first (empty) line, then the first empty line causes cocoa5 to produce an empty line and another with a new prompt. The second line is sent fine, and cocoa5-send-line "cleverly" skips over the following empty line to place the cursor at the start of 3+4;.

I think it might be nice to make cocoa5-send-line send nothing to cocoa5 if the current line is empty (or contains only whitespace), and then make it skip to the next non-empty line (i.e. which contains at least one non-whitespace character) or end of buffer.

What do you think?

#2 Updated by John Abbott over 7 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

Here is another example:

1+2;
3+4;

where the last line does not have a "newline" at the end.
Calling cocoa5-send-line repeatedly will evaluate the last line many times.

I think it would be better if cocoa5-send-line did nothing (other than perhaps "beep") when called with the cursor at the end of the buffer.

What do you think?

#3 Updated by Anna Maria Bigatti about 7 years ago

John Abbott wrote:

Here is another example:
[...]
where the last line does not have a "newline" at the end.
Calling cocoa5-send-line repeatedly will evaluate the last line many times.

I think it would be better if cocoa5-send-line did nothing (other than perhaps "beep") when called with the cursor at the end of the buffer.

I would leave it as it is, I think this is too difficult to deal well:
we would need to separate the case (probably impossible) whether or not it is the first time we call that line ("beep" makes me think it does nothing, but it should execute the line at least once).

#4 Updated by John Abbott about 7 years ago

Another possibility is to make cocoa5-send-line insert a newline into the buffer if the line (is non-empty and) does not end with one -- the only possible case is the very last line in a file. This just assume that the buffer is modifiable.

Maybe Anna is right: the problem is not that serious, and there appears to be no (easy?) solution which works well in all cases.

#5 Updated by John Abbott about 7 years ago

  • Related to Bug #1002: Emacs UI: cocoa5-send-line skips too many chars added

#6 Updated by John Abbott about 7 years ago

I reiterate my suggestion to make cocoa5-send-line send nothing to CoCoA-5 if the line it is on contains only white space. It can simply move forward to the next non-empty line.

Any objections to this idea? (other than "is it worth the effort?")

#7 Updated by Anna Maria Bigatti about 7 years ago

John Abbott wrote:

I reiterate my suggestion to make cocoa5-send-line send nothing to CoCoA-5 if the line it is on contains only white space. It can simply move forward to the next non-empty line.

No particular objection. But the case you mention should happen only if the user has explicitely placed the cursor in an empty line, because, after sending a line to CoCoA, the cursor is moved automatically to the following non-empty line.

#8 Updated by John Abbott about 7 years ago

  • Status changed from In Progress to Feedback
  • Assignee set to John Abbott
  • Target version changed from CoCoA-5.?.? to CoCoA-5.2.0 spring 2017
  • % Done changed from 10 to 90
  • Estimated time set to 3.10 h

This was done some while ago. I've been using the revised version of cocoa5.el for at least a month without any problem.

I have also just added the feature where a NEWLINE is added at the end of the buffer if the last line does not end with NEWLINE. If the buffer is not modifiable then emacs gives an error about the buffer being read-only (and the NEWLINE is not added). I have not yet checked in this final modification.

#9 Updated by Anna Maria Bigatti almost 7 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100

Also available in: Atom PDF