Project

General

Profile

Bug #470

Emacs UI: cocoa5-close-block should beep when there is no block to close

Added by John Abbott about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
EmacsUI
Target version:
Start date:
12 Mar 2014
Due date:
% Done:

100%

Estimated time:
3.00 h
Spent time:

Description

When there is no block to close cocoa5-close-block behaves strangely.

If there is no code before point then it picks up the next keyword after point (or if there is none, it beeps and gives an emacs error about "match not found").

If there is no block to close, it seems to pick the last outermost keyword.

It is also confused by keywords inside end-of-line comments.

Investigate and correct!


Related issues

Related to CoCoA-5 - Bug #441: Emacs UI: C-c C-e does not ignore keywords inside stringsClosed2014-02-12

History

#1 Updated by John Abbott about 10 years ago

Here are some test cases; I use # to mark the position of the cursor.

Case 1

#
1+2;

I get emacs error Search failed... (unhelpful to a user)

Case 2

#
For I := 1 To 10 Do PrintLn I; EndFor;

Inserts EndFor (NB this is before the loop!)

Case 3

If A > B Then
  PrintLn "greater"; -- for debugging
#

Inserts Endfor (note capitalization!)

Case 4

If A > B Then
  PrintLn "greater"; -- for debugging
EndIf;
#

Inserts EndIf (because it thinks that the existing EndFor goes with for)

Case 5

If A > B Then
  PrintLn "greater";
EndIf;

While A > B Do
  A := something(A,B);
EndWhile;
#

Inserts EndIf

Case 6

Define abc(x)
  Return x+1;
EndDefine; -- abc

Define def(x)
  Return x-1;
EndDefine; -- def
#

Inserts EndDefine; --def (finds Define of abc but then I suppose does a second reverse search to find the name to add as comment)

Case 7

If A > B Then PrintLn "greater"; EndIf;

Define def(x)
  Return x-1;
EndDefine; -- def
#

Inserts EndIf (the first End-able keyword)

Case 8

If A > B Then PrintLn "while"; EndIf;

Define def(X)
  Return x-1;
EndDefine; -- def
#

Inserts EndIf (so is not confused by while inside a string)

#2 Updated by John Abbott about 10 years ago

I think it may be useful to have an emacs fn which says whether point is in a string literal, in a comment, or in code. It should be easy to implement (if we ignore multiline comments and multiline strings) -- something to do during Martelli's talk (followed by CCS! Hope my battery last long enough ;-))

#3 Updated by John Abbott about 10 years ago

I was wrong: it wasn't so easy to write the elisp function, but I think I have one which works now! :-)

Next step is to figure out how to use in the existing code... :-/

#4 Updated by John Abbott about 10 years ago

  • Status changed from New to Feedback
  • Assignee set to John Abbott
  • % Done changed from 0 to 90

I introduced the bug when "correcting" some redundant looking code (see post 1 in #441).

I've now restored the code to its working state (I hope).

#5 Updated by Anna Maria Bigatti about 10 years ago

  • Target version set to CoCoA-5.1.0 Easter14

#6 Updated by Anna Maria Bigatti about 10 years ago

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

It works. Closing.

#7 Updated by Anna Maria Bigatti about 10 years ago

  • Estimated time set to 3.00 h

Also available in: Atom PDF