all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#19397: incorrect handling of / in a character class in js-mode
@ 2014-12-17 15:15 Paul Pogonyshev
  2014-12-23 15:54 ` Stefan Monnier
  2014-12-23 16:16 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Pogonyshev @ 2014-12-17 15:15 UTC (permalink / raw)
  To: 19397

[-- Attachment #1: Type: text/plain, Size: 406 bytes --]

Try to type the following code in a JS buffer:

function test ()
{
    return /[/]/.test ('/')
}

This function is legal in JS and returns true. However, Emacs is badly
confused: indentation, syntax highlighting, C-M-f over the regex all don't
work correctly.

Note that while _this_ regex is silly, it is based on a real-life one that
uses a character class with a slash in it.

Recent Emacs trunk.

Paul

[-- Attachment #2: Type: text/html, Size: 563 bytes --]

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

* bug#19397: incorrect handling of / in a character class in js-mode
  2014-12-17 15:15 bug#19397: incorrect handling of / in a character class in js-mode Paul Pogonyshev
@ 2014-12-23 15:54 ` Stefan Monnier
  2014-12-23 16:16 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2014-12-23 15:54 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: 19397

> Try to type the following code in a JS buffer:
> function test ()
> {
>     return /[/]/.test ('/')
> }

Indeed, there are two problems here: js-mode treats the first / as
a division operation, and even if you change the code to avoid this
problem, you bump into the fact that js-mode doesn't know there can be
"unescaped / in character class".

I installed a fix for the first problem into emacs-24.
For the second problem, I recommend you escape the slash for now (IIUC
the syntax of regexps in ecmascript, that will DTRT).


        Stefan





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

* bug#19397: incorrect handling of / in a character class in js-mode
  2014-12-17 15:15 bug#19397: incorrect handling of / in a character class in js-mode Paul Pogonyshev
  2014-12-23 15:54 ` Stefan Monnier
@ 2014-12-23 16:16 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2014-12-23 16:16 UTC (permalink / raw)
  To: Paul Pogonyshev; +Cc: 19397-done

Version: 25.1

> function test ()
> {
>     return /[/]/.test ('/')
> }

OK, I installed a patch into master which should handle the "unescaped slash in
character classes".  Together with the previous patch installed in
emacs-24, it should handle at least the above case.


        Stefan





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

end of thread, other threads:[~2014-12-23 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-17 15:15 bug#19397: incorrect handling of / in a character class in js-mode Paul Pogonyshev
2014-12-23 15:54 ` Stefan Monnier
2014-12-23 16:16 ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.