Project

General

Profile

Feature #1038

Emacs: sent interrupt to CoCoA

Added by Anna Maria Bigatti about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Category:
EmacsUI
Start date:
04 Apr 2017
Due date:
% Done:

100%

Estimated time:
4.01 h
Spent time:

Description

It would be handy to have a menu item or a key-binding to send interrupt to the cocoa5 buffer from a cocoa file.

History

#1 Updated by John Abbott about 7 years ago

It would be nice.
It would be nice if the key-sequence were the same as when the cursor is in the cocoa5 buffer, but that is a problem. The key-sequence for the cocoa5 buffer is C-c C-c which is already defined in a cocoa5-mode buffer as comment-region.

In the cocoa5 buffer the sequence C-c C-\ sends a KILL signal. Perhaps we could use C-c C-\ to send an interrupt? If you type C-c C-\ several times then it could send a KILL signal. Not ideal....

#2 Updated by Anna Maria Bigatti about 7 years ago

  • % Done changed from 0 to 10

John Abbott wrote:

It would be nice if the key-sequence were the same as when the cursor is in the cocoa5 buffer, but that is a problem. The key-sequence for the cocoa5 buffer is C-c C-c which is already defined in a cocoa5-mode buffer as comment-region.

I'm not sure (and I'll investigate how to do this ;-) but I think that one could detect whether there is a region selected (--> comment-region) or not (--> interrupt)

In the cocoa5 buffer the sequence C-c C-\ sends a KILL signal. Perhaps we could use C-c C-\ to send an interrupt? If you type C-c C-\ several times then it could send a KILL signal. Not ideal....

Hmmm, I'd rather have C-c C-i: easier to remember.

#3 Updated by John Abbott about 7 years ago

  • Status changed from New to In Progress

There are emacs commands region-active-p and use-region-p.
After reading the manual, I'm not really sure what they do (or what the difference between them is).

#4 Updated by John Abbott about 7 years ago

Adding a new key-sequence should be quite easy; actually you probably need 2 new key-sequences (one for C-c C-c eqivalent, and one for C-c C-\ equivalent). Maybe C-c C-i for "interrupt" (or BREAK in the emacs-cocoa menu), and C-c C-q for "hard quit" (or QUIT in the emacs-cocoa menu).

For adapting C-c C-c in cocoa5-mode, the code would need to do the following:
  • if there is an "active" region then call comment-region and exit
  • if there is no cocoa5 buffer or that buffer has no process then do nothing (and exit)
  • send a BREAK to the process

#5 Updated by Anna Maria Bigatti about 7 years ago

John Abbott wrote:

C-c C-q for "hard quit" (or QUIT in the emacs-cocoa menu).

there is already C-c C-k "kill"

For adapting C-c C-c in cocoa5-mode, the code would need to do the following:
  • if there is an "active" region then call comment-region and exit
  • if there is no cocoa5 buffer or that buffer has no process then do nothing (and exit)
  • send a BREAK to the process

I'll have a try...

#6 Updated by Anna Maria Bigatti about 7 years ago

  • Status changed from In Progress to Feedback
  • Assignee set to Anna Maria Bigatti
  • Target version changed from CoCoA-5.2.2 to CoCoA-5.2.0 spring 2017
  • % Done changed from 10 to 90

Done it!
I've been lucky and found comint-interrupt-subjob quickly.
I had some problems in testing it (load-file in emacs doesn't update all functionalities, I never investigated why).
Then I used region-active-p (defined in cocoa5.el), as for cocoa5-send-line-or-region, which just fell under my eyes.

I also added Interrupt CoCoA-5 in the menu.

#7 Updated by John Abbott about 7 years ago

Well done! :-)

I have made a small change: call use-region-p instead of region-active-p
If I understand correctly from the emacs doc, the only difference is when an empty region is selected (in which case use-region-p says that there is no region -- this seems more "intuitive" to me).

One minor niggle: if there is no cocoa5 buffer then C-c C-c creates it. I think I would prefer that C-c C-c do nothing in those circumstances (or perhaps display a message saying that there is no cocoa5 process).

NOTE after speaking to Anna, there are more urgent matters than my "minor niggle" to sort out...

#8 Updated by John Abbott about 7 years ago

I have just checked in a new version which should use use-region-p if that fn is defined, o/w it uses region-active-p. Perhaps Anna can check that it works with her old emacs (v.22).

#9 Updated by Anna Maria Bigatti almost 7 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100
  • Estimated time set to 4.01 h

Works for John (new emacs) and for me (old emacs).
Good.
Closing.

Also available in: Atom PDF