Commit graph

135854 commits

Author SHA1 Message Date
Juri Linkov
8ecce6af47 Inhibit displaying help buffer in main window in perform-replace
* lisp/replace.el (perform-replace): Use
display-buffer-overriding-action with inhibit-same-window to prevent
the help buffer from being displayed in the main window.  (Bug#34972)

Author: Michał Krzywkowski <k.michal@zoho.com>
Copyright-paperwork-exempt: yes
2019-04-10 23:48:13 +03:00
Paul Eggert
d2255c6065 Fix $(MAKE) -C for out-of-tree bootstraps
Problem reported by Andy Moreton in:
https://lists.gnu.org/r/emacs-devel/2019-04/msg00359.html
* src/Makefile.in (${charsets}, $(lispsource)/loaddefs.el):
Revert incorrect changes to $(MAKE) -C invocations when the
target is in the source tree not the build tree.
2019-04-10 10:06:53 -07:00
Glenn Morris
61cdadf5bc Merge from origin/emacs-26
5999401 (origin/emacs-26) Note that choose-completion-string-function...
8d2f1df Address name conflicts in EIEIO documentation (bug#31660)
2019-04-10 09:07:16 -07:00
Glenn Morris
fe552f69ae ; Merge from origin/emacs-26
The following commit was skipped:

00a2d57 Clarify the TESTFN argument to `alist-get'
2019-04-10 09:07:16 -07:00
Glenn Morris
7f88eecd7c Merge from origin/emacs-26
a5da653 * src/editfns.c (Fnarrow_to_region): Doc fix.  (Bug#35163)
646d33d Fix doc strings of 'vc-version-diff' and 'vc-version-ediff'
a30a6c3 Improve documentation of set-window-start
92ce2dd Improve documentation of window parameters
6dc42c5 Improve commentary in frame.el
a8cffcf Fix typo in a doc string
9e79f19 (emacs-26) ; * src/fontset.c (set-fontset-font): Use uppercas...

# Conflicts:
#	lisp/vc/vc.el
2019-04-10 09:07:16 -07:00
Stefan Monnier
0cef057b02 * test/lisp/progmodes/python-tests.el: "Fix" failing test
(python-tests--python-nav-end-of-statement--infloop): Disable.
2019-04-10 10:39:50 -04:00
Stefan Monnier
e3bd33fb1c Eshell dependencies: Fix recent regressions
* lisp/dired.el (dired-insert-directory): Tweak bug#27817's ugly hack.

* lisp/eshell/em-ls.el: Refine 'require's.

* lisp/eshell/esh-opt.el: Require esh-util on behalf of its clients.
2019-04-10 10:11:50 -04:00
Eric Abrahamsen
59994015f1 Note that choose-completion-string-functions funcs take four args
* lisp/simple.el (choose-completion-string-functions): Functions in
  this list actually need to accept four arguments, though the fourth
  should be ignored.
2019-04-09 20:13:47 -07:00
Jackson Ray Hamilton
526ffbad14
* etc/NEWS: Document js-jsx-align->-with-< 2019-04-09 19:53:37 -07:00
Jackson Ray Hamilton
f29010729f
Add new defcustom js-jsx-align->-with-<
* lisp/progmodes/js.el (js-jsx-align->-with-<): New variable for users
to control one opinionated aspect of JSX indentation.  It defaults to
the style seen in the React docs, which many users expected as the
“correct” indentation.  Still, the old SGML-style of indentation could
be desirable too, especially since it was the old default.  This
ensures users have a way of getting back the old behavior.
(js-jsx--contextual-indentation): Respect js-jsx-align->-with-<.

* test/manual/indent/jsx-align-gt-with-lt.jsx: New test for
js-jsx-align->-with-<.
2019-04-09 19:42:49 -07:00
Jackson Ray Hamilton
c0b09f42f5
* etc/NEWS: Document way to revert to old JSX indentation behavior 2019-04-09 18:50:28 -07:00
Jackson Ray Hamilton
5772971f25
Add new defcustom js-jsx-indent-level
* lisp/progmodes/js.el (js-jsx-indent-level): New variable for users
to set JSX indentation differently than JS, like before.
(js-jsx--contextual-indentation): Respect js-jsx-indent-level when
it’s set.

* test/manual/indent/jsx-indent-level.jsx: New test for
js-jsx-indent-level.
2019-04-09 18:44:36 -07:00
Gemini Lasswell
8d2f1df51a Address name conflicts in EIEIO documentation (bug#31660)
* doc/misc/eieio.texi (Quick Start): Rename the class used in the
example from 'record' to 'person'.
(Building Classes): Advise user to check for name conflicts before
naming a class.  Add a missing apostrophe.
(Making New Objects): Correct grammar.  Rename the class used in the
example from 'record' to 'my-class'.
2019-04-09 18:53:43 -04:00
Paul Eggert
d826037475 Remove the need for temacs.in
Instead of building a file temacs.in used only to compute a
fingerprint, compute the fingerprint directly from the .o and
.a files that go into temacs.in.  This speeds up the build by
avoiding the need to link temacs twice, once with a dummy
fingerprint.
* lib-src/make-fingerprint.c (main): No need to generate
a fingerprint file that includes config.h, now that fingerprint.c
depends on all the .o files.
* src/Makefile.in ($(libsrc)/make-fingerprint$(EXEEXT)):
Use the same rule as $(libsrc)/make-docfile$(EXEEXT).
* src/fingerprint-dummy.c: Remove.
* src/Makefile.in (${charsets}, $(libsrc)/make-docfile$(EXEEXT))
($(LIBEGNU_ARCHIVE), $(lwlibdir)/liblw.a, $(oldXMenudir)/libXMenu11.a)
(../config.status, ${ETAGS}, ../lisp/TAGS, $(lwlibdir)/TAGS)
($(lispsource)/loaddefs.el):
Prefer ‘$(MAKE) -C $(dir $@)’ to ‘${MAKE} -C SOMESTRING’ when
either will do, as the former is more regular and lets us
coalesce rules better.
(EMACS_DEPS_PRE, EMACS_DEPS_POST, BUILD_EMACS_PRE)
(BUILD_EMACS_POST, temacs.in$(EXEEXT)): Remove.
(FINGERPRINTED): New macro.
(fingerprint.c): Use it instead of temacs.in$(EXEEXT), to
avoid the need to build temacs.in at all.
(temacs$(EXEEXT)): No need to depend on other .o files now;
fingerprint.o is enough, since it depends on the rest.
Spell out what used to be in BUILD_EMACS_PRE and BUILD_EMACS_POST.
(mostlyclean): No need to remove temacs.in.
2019-04-09 15:43:35 -07:00
Paul Eggert
e44ff2de81 Remove assumption of uint64_t etc. in portable code
C11 doesn’t guarantee the existence of types like uint64_t,
so avoid these types in portable code, as it’s easy to do so.
There’s no need to avoid the types in w32-specific code,
since w32 is guaranteed to have them.
* lib-src/make-fingerprint.c (main):
* src/fingerprint-dummy.c:
* src/fingerprint.h:
* src/pdumper.c (dump_fingerprint, struct dump_header):
Prefer unsigned char to uint8_t in portable code, as either will do.
Put an "#include <config.h>" in fingerprint.c files, so
that the corresponding .o file is rebuilt after ./configure is run.
* lib-src/make-fingerprint.c (main):
Simplify loop.
* src/Makefile.in (fingerprint.c): Update atomically.
* src/pdumper.c: Omit unnecessary check that off_t is the same
size as int32_t or int64_t, as the code does not rely on this
assumption.
(dump_off): Use int_least32_t, not int32_t.
(struct dump_reloc): Use unsigned int, not uint32_t.
(dump_anonymous_allocate_w32, dump_anonymous_allocate_posix)
(dump_anonymous_allocate, dump_map_file_w32, dump_map_file_posix)
(dump_map_file:
Do the sanity checks at compile time, not at run-time, to avoid
usage of uint64_t etc. on non-w32 platforms.
2019-04-09 15:43:35 -07:00
Paul Eggert
44a39e3e76 Remove dmpstruct.h
The hassles of updating the dmpstruct.h-using code bit me again.
These updates are more trouble than they’re worth.  See:
https://lists.gnu.org/r/emacs-devel/2019-03/msg00122.html
As I’m the main person who’s made changes in this area since
dmpstruct.h was introduced, I’m the most motivated to clean up
the situation.
* make-dist (possibly_non_vc_files): Remove src/dmpstruct.h.
* src/Makefile.in (dmpstruct_headers, dmpstruct.h): Remove.
(pdumper.o): Do not depend on dmpstruct.h.
(mostlyclean): Do not remove dmpstruct.h.
* src/dmpstruct.awk: Remove.
* src/pdumper.c: Do not include dmpstruct.h.
(CHECK_STRUCTS): Remove.  All uses removed.
2019-04-09 15:43:34 -07:00
Stefan Monnier
85fbdf027d diff-font-lock-syntax: clarify distinction between t and hunk-also
* lisp/vc/diff-mode.el (diff-font-lock-syntax): Rework docstring.
(diff-syntax-fontify-hunk): Never use the hunk method when
diff-font-lock-syntax is just t.
2019-04-09 18:39:22 -04:00
Alex Branham
d96b672f2b
Use lexical-binding in bug-reference.el
* .dir-locals.el: Set bug-reference-url-format in all modes, not just
changelog mode. Use (eval . (bug-reference-mode)) as described
in (info "(emacs) Specifying File Variables")
* lisp/progmodes/bug-reference.el: Use lexical binding.
(bug-reference-unfontify):
(bug-reference-fontify): Mention args in docstring.

Bug#35123
2019-04-09 16:29:09 -05:00
Basil L. Contovounesios
6cb49922e6 Fix Gnus duplicate suppression guards (bug#34987)
* lisp/gnus/gnus-dup.el (gnus-dup-enter-articles)
(gnus-dup-suppress-articles): Use gnus-dup-hashtb as an indicator of
initialization instead of gnus-dup-list, which may happen to be nil.
(gnus-dup-unsuppress-article): Do nothing if gnus-dup-hashtb is
uninitialized.
2019-04-09 21:29:38 +01:00
Stefan Monnier
4f19bbb125 * lisp/printing.el: Use lexical-binding
Require easy-menu instead of adding declarations.
Remove backward compatiblity.  Remove redundant ':group' args.
(pr-region-active-p): Use use-region-p.
(pr-set-keymap-name): Delete function and callers.
(pr-set-keymap-parents): Delete function; use set-keymap-parent instead.
(pr-read-string): Delete function; use read-string instead.
(pr-menu-char-height): Delete function; use frame-char-height instead.
(pr-menu-char-width): Delete function; use frame-char-width instead.
(pr-menu-position): Merge the two definitions.
(pr-get-symbol): Delete function; use easy-menu-intern instead.
(pr-update-mode-line): Delete function; use force-mode-line-update instead.
(pr-do-update-menus): Turn local save-var into dynbound pr--save-var.
(pr-menu-alist): Use setf.  Simplify since we don't keep key-bindings
in the menus any more.
(pr-dosify-file-name): Remove interactive spec.
(pr-filename-style): Rename from pr-path-style.
(pr-unixify-file-name): Delete function.
(pr-standard-file-name): Don't turn \ into / under POSIX.
(pr-temp-dir): Don't dosify.  Use temporary-file-directory unconditionally.
(pr-save-file-modes): Delete macro.
(pr-ps-directory-using-ghostscript, pr-ps-directory-print)
(pr-ps-directory-ps-print, pr-ps-mode-using-ghostscript, pr-ps-print)
(pr-ps-mode-preview, pr-ps-mode-print, pr-printify-directory)
(pr-txt-directory, pr-ps-file-up-preview, pr-ps-directory-preview)
(pr-ps-file-up-ps-print, pr-ps-preview, pr-ps-using-ghostscript):
Use properly prefixed, declared, and
explicitly let-bound dynamically bound variables around calls to
pr-ps-utility-args and pr-set-dir-args.
(pr-ps-file-using-ghostscript): Only dosify when passing to suprocess.
(pr-expand-file-name): Delete function; use expand-file-name instead.
(pr-ps-file-print): Properly dosify.
(pr-menu-create): Use backquotes.
(pr-eval-alist, pr-eval-local-alist): Use dolist.
(pr-ps-utility-args): Don't dosify here.
(pr-ps-utility-process): Dosify here instead.
(pr-ps-file, pr-command): Don't dosify here either.
(pr-interface-map): Move initialization into declaration.
(pr-insert-section-1): Use 'push'.
(pr-insert-toggle): Use closure instead of backquoted lambda.
(pr-insert-menu): Use apply i.s.o eval.
(pr-insert-radio-button): Avoid 'eval'.
2019-04-09 16:28:42 -04:00
Stefan Monnier
8a5ecdaa2f quail.el: Use delete-and-extract-region
* lisp/international/quail.el (quail-overlay-region-events):
Use delete-and-extract-region.
(quail-activate): Use setq-local.
2019-04-09 15:11:38 -04:00
Stefan Monnier
4b39b741f1 python.el: don't syntax-propertize single/double quoted strings
* lisp/progmodes/python.el (python-syntax-propertize-function):
Only mark triple-quoted strings, let the normal syntax-table handle
the rest.
(python-syntax-stringify): Adjust accordingly.
2019-04-09 15:08:21 -04:00
Stefan Monnier
c443133275 * lisp/progmodes/js.el (js-mode): Don't set comment-start-skip globally! 2019-04-09 15:02:00 -04:00
Stefan Monnier
a017927c9f Fix up Eshell 'require's after previous dependency reshuffle.
* lisp/eshell/em-unix.el:
* lisp/eshell/em-script.el:
* lisp/eshell/em-pred.el:
* lisp/eshell/em-dirs.el:
* lisp/eshell/em-alias.el:
Fix up 'require's to silence byte-compiler.

* lisp/eshell/esh-util.el (eshell-read-hosts-file): Don't limit number
of entries per line.  Preserve the structure.
(eshell-read-hosts): Adjust accordingly.
2019-04-09 14:57:29 -04:00
Mattias Engdegård
00a2d57adf Clarify the TESTFN argument to `alist-get'
* lisp/subr.el (alist-get):
Rephrase the initial text to clarify the meaning of the TESTFN argument.
It's an equality predicate, not a look-up function (Bug#35206).

(cherry picked from commit c81465580f)
2019-04-09 19:10:47 +03:00
Stefan Monnier
1055eee692 * lisp/gnus/mm-view.el (mm-display-inline-fontify): Simplify.
Remove hacks that were needed before font-lock-ensure.
Don't use switch-to-buffer.  Don't assume point-min == 1.
2019-04-09 12:04:03 -04:00
Basil L. Contovounesios
e1a457e635 ; Warn of while/dolist pitfall in gnus-sum.el
Suggested by Andy Moreton in the following thread:
https://lists.gnu.org/archive/html/emacs-devel/2019-04/msg00294.html
* lisp/gnus/gnus-sum.el (gnus-summary-move-article): Add comment
warning of common while/dolist pitfall. (bug#33653#134)
2019-04-09 16:32:27 +01:00
Stefan Monnier
90c7e363b7 * lisp/vc/diff-mode.el: Cosmetic changes in diff-syntax-fontify-hunk
(diff-default-directory): Use defvar-local.
(diff-syntax-fontify-hunk): Use 'setq' less.  Fit within 80 columns.
Simplify some looking-at tests.
(diff-syntax-fontify-props): Don't check the buffer-local part of
find-file-hook.
2019-04-09 11:10:23 -04:00
Mattias Engdegård
c81465580f Clarify the TESTFN argument to `alist-get'
* lisp/subr.el (alist-get):
Rephrase the initial text to clarify the meaning of the TESTFN argument.
It's an equality predicate, not a look-up function (Bug#35206).
2019-04-09 16:56:37 +02:00
Eli Zaretskii
44b306d351 ; * etc/NEWS: Fix recently added entries. 2019-04-09 11:09:56 +03:00
Eli Zaretskii
1e58dc9e11 Fix "M-x eshell"
* lisp/eshell/em-dirs.el (eshell-variable-aliases-list)
(eshell-directory-name, eshell-mode): Defvar them.
(eshell-dirs-initialize): Require esh-var.  (Bug#35203)
(eshell-apply-indices): Declare.
2019-04-09 11:01:24 +03:00
Jackson Ray Hamilton
062369e3ae
* etc/NEWS: Document new and improved JSX support in js-mode 2019-04-09 00:52:43 -07:00
Jackson Ray Hamilton
cf416d96c2
Explain reasonings for JSX syntax support design decisions
* lisp/progmodes/js.el: Throughout the code, provide explanations for
why JSX support was implemented in the way that it was; in particular,
address the overlap between syntax-propertize-function, font-lock, and
indentation (as requested by Stefan).
2019-04-08 22:48:25 -07:00
Jackson Ray Hamilton
7c3ffdaf4b
Move curly functions closer to where they’re used
* lisp/progmodes/js.el (js-jsx--enclosing-curly-pos)
(js-jsx--goto-outermost-enclosing-curly): As the code evolved, these
functions’ definitions ended up being far away from the only places
where they were used.  Move them there.
2019-04-08 22:48:25 -07:00
Jackson Ray Hamilton
9545519572
Add open/close parenthesis syntax to “<” and “>” in JSX
* lisp/progmodes/js.el (js-jsx--syntax-propertize-tag): Like in
sgml-mode, treat “<” and “>” like open/close parenthesis, making the
text more navigable via forward-sexp, etc.
2019-04-08 22:48:25 -07:00
Jackson Ray Hamilton
18bbfc4c75
Permit non-ASCII identifiers in JS
* lisp/progmodes/js.el (js--name-start-re): Generally allow
identifiers to begin with non-ASCII letters.  This is of particular
importance to JSX parsing.

* test/manual/indent/jsx-unclosed-2.jsx: Add test to ensure non-ASCII
characters are parsed properly.
2019-04-08 22:48:24 -07:00
Jackson Ray Hamilton
3eadf1eff4
Identify JSX strings (for js2-mode)
* lisp/progmodes/js.el (js-jsx--syntax-propertize-tag): Derived modes
like js2-mode may use font-lock-syntactic-face-function to apply faces
to JSX strings (and only JSX strings).  Apply the js-jsx-string text
property to such strings so they can be distinctly identified.
(js-jsx--text-properties): Ensure the js-jsx-string text property gets
cleaned up, too.
2019-04-08 22:48:24 -07:00
Jackson Ray Hamilton
e48306f84f
Properly set a dynamic, syntactic mode name
Use mode-line-format constructs to properly set mode-name, rather than
use the very hacky solution that was filling-in for my lack of
knowledge of this feature.

* lisp/progmodes/js.el (js--update-mode-name)
(js--idly-update-mode-name): Remove.

(js--syntactic-mode-name-part): New helper function for mode-name.
(js-use-syntactic-mode-name): Helper to set up the dynamic mode-name.

(js-jsx-enable): Don’t need to call any extra functions now.
(js-mode): Use the new setup function rather than the old ones.

(js-jsx-mode): Use the same initial mode name as js-mode so the final
one is identical for both modes.
2019-04-08 22:48:24 -07:00
Jackson Ray Hamilton
7a9dac5c94
Improve whitespace and unary keyword parsing
* lisp/progmodes/js.el (js--name-start-chars): Remove, adding these
chars back to js--name-start-re.
(js--name-start-re): Add chars back from js--name-start-chars.

(js-jsx--tag-start-re): Improve regexp to capture the tag name (so it
can be disambiguated from a unary keyword), to match newlines (which
are common in this spot), and to require at least one whitespace
character before the attribute name.

(js-jsx--matched-tag-type): Ensure the “tag name” isn’t possibly a
unary keyword.

(js-jsx--self-closing-re, js-jsx--matching-close-tag-pos): Allow
whitespace around “<” and “>”.

* test/manual/indent/jsx-unclosed-2.jsx: Add tests for unary keyword
and whitespace parsing.
2019-04-08 22:48:24 -07:00
Jackson Ray Hamilton
98e36a3e31
Optimize js-jsx--enclosing-tag-pos
* lisp/progmodes/js.el (js-jsx--enclosing-tag-pos): Update docstring
to be more precise.  Also, remember close tag positions after they’ve
been calculated once to avoid many redundant calls to
js-jsx--matching-close-tag-pos.
(js-jsx--text-properties): Ensure js-jsx-close-tag-pos text properties
get cleaned up, too.
2019-04-08 22:48:24 -07:00
Jackson Ray Hamilton
7b2e3c60d0
Optimize js-jsx--matching-close-tag-pos
This function’s performance was having a noticeable impact when
editing large JSX structures.  Improve its performance
slightly (elapsed time will be cut in half according to ELP).

* lisp/progmodes/js.el (js-jsx--tag-re): Remove.
(js-jsx--matched-tag-type): Simplify implementation with respect to
the new implementation of js-jsx--matching-close-tag-pos.
(js-jsx--self-closing-re): Simplify regexp slightly in sync with a
generally simpler matching algorithm.
(js-jsx--matching-close-tag-pos): Optimize matching algorithm by using
multiple simple regexp searches, rather than one big complex search.

* test/manual/indent/jsx-unclosed-2.jsx: Use the term “inequality” and
add a test for a possible parsing foible.
2019-04-08 22:48:24 -07:00
Jackson Ray Hamilton
462baabed9
Add tests for miscellaneous JSX parsing feats
* test/manual/indent/jsx.jsx: Add tests for JSXMemberExpression names
and JSXOpeningFragment/JSXClosingFragment support (already supported).
2019-04-08 22:48:23 -07:00
Jackson Ray Hamilton
afec4511cf
Split JSX indentation calculation into several functions
* lisp/progmodes/js.el (js-jsx--contextual-indentation)
(js-jsx--expr-attribute-pos, js-jsx--expr-indentation): Extract logic
from js-jsx--indentation, and improve the logic’s documentation.
(js-jsx--indentation): Simplify by splitting into several
functions (see above) and improve the logic’s documentation.
2019-04-08 22:48:23 -07:00
Jackson Ray Hamilton
55c80d43a9
Indent expressions in JSXAttributes relative to the attribute’s name
* lisp/progmodes/js.el (js-jsx--syntax-propertize-tag): Refer to the
beginning of a JSXExpressionContainer’s associated JSXAttribute (so
line numbers can be calculated later).
(js-jsx--text-properties): Also clear the new text property
js-jsx-expr-attribute.

(js-jsx--indenting): Remove.
(js-jsx--indent-col, js-jsx--indent-attribute-line): New variables.
(js-jsx--indentation): Instead of alternating between two separate
column calculations, neither necessarily correct, bind the JSX column
such that the second call to js--proper-indentation can use it as a
base column.
(js--proper-indentation): Use JSX as the base column for some indents
while indenting JSX.

* test/manual/indent/jsx.jsx: Add more tests for expression indents.
2019-04-08 22:48:23 -07:00
Jackson Ray Hamilton
16669d7c5d
Fix counting of nested self-closing JSXOpeningElements
* lisp/progmodes/js.el (js-jsx--matching-close-tag-pos): Fix bug where
self-closing JSXOpeningElements might be missed if one was nested
within another.

* test/manual/indent/jsx-self-closing.jsx: Add test for bug concerning
self-closing JSXOpeningElement counting.
2019-04-08 22:48:23 -07:00
Jackson Ray Hamilton
84b1cfbc2d
Indent broken arrow function bodies as an N+1th arg
* lisp/progmodes/js.el (js--line-terminating-arrow-re): Revise regexp
for use with re-search-backward.
(js--looking-at-broken-arrow-function-p): Remove.
(js--broken-arrow-terminates-line-p): Replacement for
js--looking-at-broken-arrow-function-p.  Don’t consider whether an
arrow appears at point (in an arglist); instead, just look for an
arrow that terminates the line.
(js--proper-indentation): Use js--broken-arrow-terminates-line-p.

* test/manual/indent/js.js: Add test for a broken arrow as an N+1th
arg.
2019-04-08 22:48:23 -07:00
Jackson Ray Hamilton
d9d1bb2b07
Rename tests to use the “.jsx” file extension
* test/manual/indent/js-jsx-quote.js: Renamed to “jsx-quote.jsx”.
* test/manual/indent/js-jsx-unclosed-1.js: Renamed to
“jsx-unclosed-1.jsx”.
* test/manual/indent/js-jsx-unclosed-2.js: Renamed to
“jsx-unclosed-2.jsx”.
* test/manual/indent/js-jsx.js: Renamed to “jsx.jsx”.

* test/manual/indent/jsx-quote.jsx: Renamed from “js-jsx-quote.js”.
* test/manual/indent/jsx-unclosed-1.jsx: Renamed from
“js-jsx-unclosed-1.js”.
* test/manual/indent/jsx-unclosed-2.jsx: Renamed from
“js-jsx-unclosed-2.js”.
* test/manual/indent/jsx.jsx: Renamed from “js-jsx.js”.
2019-04-08 22:48:22 -07:00
Jackson Ray Hamilton
8b92719b6b
Improve JSX syntax propertization
* lisp/progmodes/js.el (js-jsx--attribute-name-re): New variable.
(js-jsx--syntax-propertize-tag): Allow “-” in JSXAttribute names.  Fix
“out of range” error when typing at the end of a buffer.  Fix/improve
future propertization of unfinished JSXBoundaryElements.

* test/manual/indent/js-jsx-unclosed-2.js: Add tests for allowed
characters in JSX.
2019-04-08 22:48:22 -07:00
Jackson Ray Hamilton
bf37078df2
Automatically detect JSX in JavaScript files
* lisp/files.el (auto-mode-alist): Simply enable
javascript-mode (js-mode) when opening “.jsx” files, since the “.jsx”
file extension will be used as an indicator of JSX syntax by js-mode,
and more code is likely to work in js-mode than js-jsx-mode, and we
probably want to guide users to use js-mode (with js-jsx-syntax)
instead.  Code that used to work exclusively in js-jsx-mode (if anyone
ever wrote any) ought to be updated to work in js-mode too when
js-jsx-syntax is set to t.

* lisp/progmodes/js.el (js-jsx-detect-syntax, js-jsx-regexps)
(js-jsx--detect-and-enable, js-jsx--detect-after-change): New
variables and functions for detecting and enabling JSX.

(js-jsx-syntax): Update docstring with respect to the widened scope of
the effects and use of this variable.

(js-syntactic-mode-name, js--update-mode-name)
(js--idly-update-mode-name, js-jsx-enable): New variable and functions
for indicating when JSX is enabled.

(js-mode): Detect and enable JSX.  Print all enabled syntaxes after
the mode name whenever Emacs goes idle; this ensures lately-enabled
syntaxes are evident.

(js-jsx-mode): Update mode name for consistency with the state in
which JSX is enabled in js-mode.  Update docstring to suggest
alternative means of using JSX without this mode.  Going forward, it
may be best to gently guide users away from js-jsx-mode, since a “one
mode per syntax extension” model would not scale well if more syntax
extensions were to be simultaneously supported (e.g. Facebook’s
“Flow”).
2019-04-08 22:48:22 -07:00
Jackson Ray Hamilton
339be7c007
Finish replacing SGML-based JSX detection with js-mode’s parsing
This removes the last dependency on sgml-mode for JSX-related logic.

* lisp/progmodes/js.el (js-jsx--start-tag-re)
(js-jsx--end-tag-re): Remove.
(js-jsx--looking-at-start-tag-p)
(js-jsx--looking-back-at-end-tag-p): Reimplement using text
properties, using syntax information which ought to be slightly more
accurate than regexps since it was found by complete parsing.
2019-04-08 22:48:22 -07:00