unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Richard Copley <rcopley@gmail.com>
Cc: 26070@debbugs.gnu.org, Tom Tromey <tom@tromey.com>,
	Dmitry Gutov <dgutov@yandex.ru>
Subject: bug#26070: 26.0.50; js-mode slash insertion bug
Date: Wed, 22 Mar 2017 16:18:22 -0600	[thread overview]
Message-ID: <87lgrx0xch.fsf@tromey.com> (raw)
In-Reply-To: <CAPM58ogiR-GH_TF7cSLrAPfDinB2ijciwXgWc7cmtYHNVEFw3w@mail.gmail.com> (Richard Copley's message of "Sun, 19 Mar 2017 11:22:32 +0000")

>>>>> "Richard" == Richard Copley <rcopley@gmail.com> writes:

Richard> Caught one!

Thank you.

Richard> Insert the text below in a JS-mode buffer, go to the beginning of the
Richard> blank first line in function h() and type "/". There is an infloop.

How did you find this?  I'm very curious.

Anyway, please try this patch on top of the previous one I sent.
Or if you'd prefer I can send a combined patch.

Tom

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index fa865db..c220353 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1722,12 +1722,13 @@ js-syntax-propertize-regexp
     (when (eq (nth 3 ppss) ?/)
       ;; A /.../ regexp.
       (goto-char (nth 8 ppss))
-      (when (and (looking-at js--syntax-propertize-regexp-regexp)
-                 ;; Don't touch text after END.
-                 (or (not (match-end 1)) (<= (match-end 1) end)))
-        (put-text-property (match-beginning 1) (or (match-end 1) (match-end 0))
+      (when (looking-at js--syntax-propertize-regexp-regexp)
+        ;; Don't touch text after END.
+        (when (> end (match-end 1))
+          (setq end (match-end 1)))
+        (put-text-property (match-beginning 1) end
                            'syntax-table (string-to-syntax "\"/"))
-        (goto-char (match-end 0))))))
+        (goto-char end)))))
 
 (defun js-syntax-propertize (start end)
   ;; JavaScript allows immediate regular expression objects, written /.../.





  reply	other threads:[~2017-03-22 22:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-12 10:23 bug#26070: 26.0.50; js-mode slash insertion bug Richard Copley
2017-03-13 13:50 ` Tom Tromey
2017-03-13 19:12   ` Richard Copley
2017-03-14  5:56   ` Dmitry Gutov
2017-03-14 11:06     ` Tom Tromey
2017-03-19 11:22       ` Richard Copley
2017-03-22 22:18         ` Tom Tromey [this message]
2017-03-23  7:00           ` Richard Copley
2017-03-24  3:53             ` Tom Tromey
2017-03-31  7:53               ` Dmitry Gutov
2017-04-01 21:15 ` bug#26070: fixed Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lgrx0xch.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=26070@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=rcopley@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).