all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#25465: 25.1.90; js-mode fix for regexp literal
@ 2017-01-17  4:35 Tom Tromey
  2017-01-17 22:38 ` bug#25465: done Tom Tromey
  2017-01-18  4:36 ` Tom Tromey
  0 siblings, 2 replies; 3+ messages in thread
From: Tom Tromey @ 2017-01-17  4:35 UTC (permalink / raw)
  To: 25465

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


This patch fixes one case where js-mode did not correctly recognize a
regexp literal.  This caused an indentation error in the Firefox
developer tools code.

Let me know what you think.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: P --]
[-- Type: text/x-patch, Size: 2454 bytes --]

commit f76d42b87e8531d21072a51ac86c91ffae5ee36f
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Jan 16 14:02:45 2017 -0700

    Fix JS regexp literal syntax propertization in expressions
    
    * lisp/progmodes/js.el (js-syntax-propertize): Recognize a regexp
    literal after "!", "&", and "|".
    test/lisp/progmodes/js-tests.el (js-mode-regexp-syntax): New test.

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 54df391..2e5c6ae 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1720,10 +1720,10 @@ js-syntax-propertize
     ;; Distinguish /-division from /-regexp chars (and from /-comment-starter).
     ;; FIXME: Allow regexps after infix ops like + ...
     ;; https://developer.mozilla.org/en/JavaScript/Reference/Operators
-    ;; We can probably just add +, -, !, <, >, %, ^, ~, |, &, ?, : at which
+    ;; We can probably just add +, -, <, >, %, ^, ~, ?, : at which
     ;; point I think only * and / would be missing which could also be added,
     ;; but need care to avoid affecting the // and */ comment markers.
-    ("\\(?:^\\|[=([{,:;]\\|\\_<return\\_>\\)\\(?:[ \t]\\)*\\(/\\)[^/*]"
+    ("\\(?:^\\|[=([{,:;|&!]\\|\\_<return\\_>\\)\\(?:[ \t]\\)*\\(/\\)[^/*]"
      (1 (ignore
 	 (forward-char -1)
          (when (or (not (memq (char-after (match-beginning 0)) '(?\s ?\t)))
diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el
index 9bf7258..84749ef 100644
--- a/test/lisp/progmodes/js-tests.el
+++ b/test/lisp/progmodes/js-tests.el
@@ -59,6 +59,32 @@
  * Load the inspector's shared head.js for use by tests that need to
  * open the something or other"))))
 
+(ert-deftest js-mode-regexp-syntax ()
+  (with-temp-buffer
+    ;; Normally indentation tests are done in manual/indent, but in
+    ;; this case we are specifically testing a case where the bug
+    ;; caused the indenter not to do anything, and manual/indent can
+    ;; only be used for already-correct files.
+    (insert "function f(start, value) {
+if (start - 1 === 0 || /[ (:,='\"]/.test(value)) {
+--start;
+}
+if (start - 1 === 0 && /[ (:,='\"]/.test(value)) {
+--start;
+}
+if (!/[ (:,='\"]/.test(value)) {
+--start;
+}
+}
+")
+    (js-mode)
+    (indent-region (point-min) (point-max))
+    (goto-char (point-min))
+    (dolist (x '(0 4 8 4 4 8 4 4 8 4 0))
+      (back-to-indentation)
+      (should (= (current-column) x))
+      (forward-line))))
+
 (provide 'js-tests)
 
 ;;; js-tests.el ends here

[-- Attachment #3: Type: text/plain, Size: 6235 bytes --]






In GNU Emacs 25.1.90.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.20.9)
 of 2016-12-20 built on bapiya
Repository revision: 88cdf14b37a7344bb266e94512485e3cc738c23d
Windowing system distributor 'Fedora Project', version 11.0.11900000
System Description:	Fedora release 25 (Twenty Five)

Configured using:
 'configure --prefix=/home/tromey/Emacs/install/ --with-modules'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

Important settings:
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Article

Minor modes in effect:
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  which-function-mode: t
  erc-services-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-match-mode: t
  erc-netsplit-mode: t
  erc-hl-nicks-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  savehist-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Mark set [7 times]
Auto-saving...done
Mark set
Saving file /home/tromey/Emacs/trunk/test/lisp/progmodes/js-tests.el...
Wrote /home/tromey/Emacs/trunk/test/lisp/progmodes/js-tests.el
When done with a buffer, type C-x #
Saving file /home/tromey/.newsrc-dribble...
Wrote /home/tromey/.newsrc-dribble [2 times]
(Saved .newsrc-dribble)
Quit

Load-path shadows:
/home/tromey/.emacs.d/elpa/bubbles-0.5/bubbles hides /home/tromey/Emacs/install/share/emacs/25.1.90/lisp/play/bubbles

Features:
(tcl url-http url-gw url-auth eww url-queue shadow emacsbug erc-notify
gud ido cursor-sensor js2-mode etags shell goto-addr find-file
bug-reference tabify man bbdb-sc supercite regi nnir xref project
gnus-fun debug conf-mode shr-color apropos bbdb-message vc-mtn vc-hg
mailalias mail-hist find-dired idutils derived shr dom gnus-html
browse-url xml url-cache mm-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util url-parse
url-vars texinfo eieio-opt speedbar sb-image ezimage dframe qp dired-aux
term/xterm xterm log-view log-edit pcvs-util smerge-mode make-mode
copyright dabbrev js sgml-mode json map cc-mode cc-fonts cc-guess
cc-menus cc-cmds css-mode smie misearch multi-isearch add-log
org-bullets org-element org-rmail org-mhe org-irc org-info org-gnus
org-docview doc-view subr-x jka-compr image-mode org-bibtex bibtex
org-bbdb org-w3m org org-macro org-footnote org-pcomplete org-list
org-faces org-entities noutline outline org-version ob-emacs-lisp ob
ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint
ob-core ob-eval org-compat org-macs org-loaddefs find-func whitespace
vc-git diff-mode easy-mmode vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs
sort smiley gnus-cite flow-fill mm-archive gnus-bcklg gnus-async
mail-extr gnus-ml disp-table gnus-topic nndraft nnmh nnfolder utf-7
bbdb-gnus bbdb-mua bbdb-com crm network-stream nsm starttls gnus-agent
gnus-srvr gnus-score score-mode nnvirtual gnus-msg nntp gnus-cache
gnus-registry registry eieio-compat eieio-base gnus-art mm-uu mml2015
mm-view mml-smime smime dig mailcap gnus-sum gnus-group gnus-undo
smtpmail sendmail gnus-start gnus-cloud nnimap nnmail mail-source tls
gnutls utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range message
idna dired rfc822 mml mml-sec epg mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils
mailheader gnus-win gnus gnus-ems nnheader mail-utils flyspell ispell
diminish edmacro kmacro projectile grep compile ibuf-ext ibuffer dash
appt diary-lib diary-loaddefs cal-menu calendar cal-loaddefs which-func
imenu minimap autorevert filenotify cus-start cus-load status
erc-services erc-list erc-menu erc-join erc-ring erc-networks
erc-pcomplete pcomplete erc-track erc-match erc-netsplit erc-hl-nicks
color erc-button erc-fill erc-stamp wid-edit erc-goodies erc erc-backend
erc-compat format-spec auth-source eieio gnus-util mm-util help-fns
mail-prsvr password-cache thingatpt pp warnings advice vc-dir ewoc vc
vc-dispatcher cc-styles cc-align cc-engine cc-vars cc-defs bbdb
bbdb-site timezone ange-ftp comint ansi-color ring server savehist
finder-inf dwarf-mode-autoloads gdb-shell-autoloads eieio-core
lisppaste-autoloads pydoc-info-autoloads info-look cl-seq cl-macs cl
weblogger-autoloads info package epg-config seq byte-opt gv bytecomp
byte-compile cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib
bbdb-loaddefs time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 1657056 442374)
 (symbols 48 129097 40)
 (miscs 40 30003 5701)
 (strings 32 466158 177867)
 (string-bytes 1 11826531)
 (vectors 16 104828)
 (vector-slots 8 2395381 129340)
 (floats 8 1067 1552)
 (intervals 56 123534 6010)
 (buffers 976 219)
 (heap 1024 291747 52322))

Tom

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

end of thread, other threads:[~2017-01-18  4:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-17  4:35 bug#25465: 25.1.90; js-mode fix for regexp literal Tom Tromey
2017-01-17 22:38 ` bug#25465: done Tom Tromey
2017-01-18  4:36 ` Tom Tromey

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.