Project

General

Profile

Bug #1537

EmacUI: strange colours, sometimes

Added by Anna Maria Bigatti over 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
EmacsUI
Target version:
Start date:
13 Nov 2020
Due date:
% Done:

100%

Estimated time:
1.79 h
Spent time:

Description

 -1/- 2;

makes "/- 2" red (colour for comments)

There are also other similar cases. Why?


Related issues

Related to CoCoALib - Design #1538: RingElem from string (ReadExpr)Closed2020-11-13

History

#1 Updated by John Abbott over 3 years ago

  • Status changed from New to In Progress

I have tried a few tests. slash-minus seems to be recognised as a comment start; I have tried slash-char where char was all other symbols on my kbd, and none was recognized as a comment (except slash-slash and slash-star, of course).

Possibly relevant source code in cocoa5.el around line 2130.
What is the difference between comment-start (line 2125)and comment-start-skip (line 2130)?

PS as far as I can see, the code which colours the text (font-lock?) treats slash-minus the same as slash-slash.

#2 Updated by John Abbott over 3 years ago

  • % Done changed from 0 to 10

As far as I can tell the following "digraphs" are recognized as starting a comment:
slash-star, slash-slash, slash-minus,
minus-star, minus-slash, minus-minus.

It seems that slash-star and minus-star make emacs look for a matching star-slash to end the comment.

star-slash, star-star, and star-minus do not seem to start a comment.

#3 Updated by John Abbott over 3 years ago

Around line 335 in cocoa5.el there is this

  ; -- comments 
  (modify-syntax-entry ?- ". 12"    cocoa5-mode-syntax-table)
  ; // and /* */ comments 
  (modify-syntax-entry ?/  ". 124" cocoa5-mode-syntax-table)

At the moment I have no idea how to interpret this, but suspect that the problem could well be here.

#4 Updated by John Abbott over 3 years ago

Here is some doc about emacs;

http://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Flags.html

#5 Updated by John Abbott over 3 years ago

This is probably not solvable :-(

I changed the emacs syntax declaration for "minus" into just a plain "." (punctuation, without any special flags about being a marker for the start of a comment)
and the unexpected colouring went away... but of course, minus-minus was no longer recognised as a comment start.

I did also try setting the syntax description to ". 12c" which means first & second char of a comment of class "c", but that did not solve the unexpected colouring.

It seems to me that problem stems from emacs wanting to give context-independent descriptions of the syntax of single chars.
I have no idea how to solve this.

#6 Updated by John Abbott over 3 years ago

  • Related to Design #1538: RingElem from string (ReadExpr) added

#7 Updated by John Abbott over 3 years ago

A possible way to address the problem is to discourage users from typing /- by making it issue a warning.

As already stated in issue #1538 I do not much like allowing input such as 2*-3 or 2/-3 (and also 2*+3 and 2/+3),
because they look more like typos to me. A leading plus or minus would be allowed only at the very start of an expr (e.g. also inside brackets);
in other contexts we could issue a warning...

#8 Updated by Anna Maria Bigatti over 3 years ago

  • Target version changed from CoCoA-5.4.0 to CoCoA-5.4.2

#9 Updated by Anna Maria Bigatti over 3 years ago

John Abbott wrote:

A possible way to address the problem is to discourage users from typing /- by making it issue a warning.

that's a good point ;-)

#10 Updated by John Abbott about 3 years ago

  • Status changed from In Progress to Resolved
  • Assignee set to John Abbott
  • Target version changed from CoCoA-5.4.2 to CoCoA-5.4.0
  • % Done changed from 10 to 80

I have just updated issue #1538. This can probably be considered as an acceptable resolution of the problem reported in this issue.
What do you think?

#11 Updated by John Abbott over 2 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 80 to 100
  • Estimated time set to 1.79 h

I have not seen the problem of unexpected colours for some time.
Reading through the notes suggests that Emacs's way of recognising comments is rather too crude, but we are stuck with it.

I think we can close this now.

Also available in: Atom PDF