unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64792: js-mode doesn't recognize LS and PS line endings, leading to incorrect syntax highlighting
@ 2023-07-22 16:41 Clément Pit-Claudel
  2023-07-22 16:52 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Clément Pit-Claudel @ 2023-07-22 16:41 UTC (permalink / raw)
  To: 64792

Hi all,

The following code prints "Hello," and "world!" in JavaScript:

//
console.debug("Hello,");
//
console.debug("world!");

There is a LINE SEPARATOR after the first //, and a PARAGRAPH SEPARATOR after the second //.  Both of these are valid line terminators in ECMAScript (https://262.ecma-international.org/10.0/#table-33), but since js-mode does not recognize them, it displays the whole buffer in comment face (the only indication that something fishy is going on is a thin box around each character).

Other editors handle this in various ways.  gedit treats LS and PS as line breaks, but still displays the first call to console.debug in comment face.  vscode displays both LS and PS as question marks but warns about them and highlights the code correctly.

Is there an easy way to make Emacs treat LS and PS as newlines in js-mode?  Ideally it would display the calls to console.debug on their own separate lines, like this:

//[LS]
console.debug("Hello,");
//[PS]
console.debug("world!");

… but it would already be nice to fix the syntax highlighting to not use the comment font.  For that these characters could be marked as comment enders.  There may be additional work to do to check uses of \n of "^" and "$" in regular expressions, too.

Clément.





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

* bug#64792: js-mode doesn't recognize LS and PS line endings, leading to incorrect syntax highlighting
  2023-07-22 16:41 bug#64792: js-mode doesn't recognize LS and PS line endings, leading to incorrect syntax highlighting Clément Pit-Claudel
@ 2023-07-22 16:52 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2023-07-22 16:52 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: 64792

> Date: Sat, 22 Jul 2023 18:41:42 +0200
> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
> 
> Is there an easy way to make Emacs treat LS and PS as newlines in js-mode?  Ideally it would display the calls to console.debug on their own separate lines, like this:
> 
> //[LS]
> console.debug("Hello,");
> //[PS]
> console.debug("world!");

This can be accomplished via the display-table, but I doubt that it
would satisfy you.

> … but it would already be nice to fix the syntax highlighting to not use the comment font.  For that these characters could be marked as comment enders.  There may be additional work to do to check uses of \n of "^" and "$" in regular expressions, too.

AFAIU, this requires either changes to the font-lock regexps or
low-level change to regex-emacs.c such that it considers these two
separator characters as equivalents of a newline.

(If you ask me, Unicode made a heck of a mess by introducing these
characters, witness the problems editors out there have to this day
with handling them.)





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

end of thread, other threads:[~2023-07-22 16:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-22 16:41 bug#64792: js-mode doesn't recognize LS and PS line endings, leading to incorrect syntax highlighting Clément Pit-Claudel
2023-07-22 16:52 ` Eli Zaretskii

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