pax_global_header00006660000000000000000000000064137211367770014530gustar00rootroot0000000000000052 comment=c55244faf631327344623c8b526d3793aca48c24 web-mode-17.0.2/000077500000000000000000000000001372113677700133165ustar00rootroot00000000000000web-mode-17.0.2/.github/000077500000000000000000000000001372113677700146565ustar00rootroot00000000000000web-mode-17.0.2/.github/CONTRIBUTING.md000066400000000000000000000005341372113677700171110ustar00rootroot00000000000000# Contributing to Web-Mode Things that might be useful in your report * an accurate description of the issue * an example on gist (a screenshot of the code is a bad idea because it can not be copy/paste) * the output of ```M-x web-mode-debug``` * lines in the * *Messages* * buffer related to the issue (if they exist) * a screenshot (if needed) web-mode-17.0.2/.github/FUNDING.yml000066400000000000000000000000701372113677700164700ustar00rootroot00000000000000github: fxbois custom: ["https://www.paypal.me/fxbois"] web-mode-17.0.2/.gitignore000066400000000000000000000000441372113677700153040ustar00rootroot00000000000000*~ \#*\# *.elc .#* .DS_Store _err.* web-mode-17.0.2/LICENSE000066400000000000000000000355621372113677700143360ustar00rootroot00000000000000GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS web-mode-17.0.2/README.md000066400000000000000000000014761372113677700146050ustar00rootroot00000000000000web-mode.el ========= web-mode.el is an emacs major mode for editing **web templates** aka HTML files embedding parts (CSS/JavaScript) and blocks (pre rendered by client/server side engines). web-mode.el is compatible with many template engines: PHP, JSP, ASP, Django, Twig, Jinja, Mustache, ERB, FreeMarker, Velocity, Cheetah, Smarty, CTemplate, Mustache, Blade, ErlyDTL, Go Template, Dust.js, Google Closure (soy), React/JSX, Angularjs, ejs, Nunjucks, etc. More infos on http://web-mode.org/ ![ScreenShot](http://web-mode.org/web-mode.png?v=5) [![paypal.me](http://web-mode.org/images/PayPal.svg)](https://www.paypal.me/fxbois) [![MELPA](http://melpa.org/packages/web-mode-badge.svg)](http://melpa.org/#/web-mode) [![MELPA Stable](http://stable.melpa.org/packages/web-mode-badge.svg)](http://stable.melpa.org/#/web-mode) web-mode-17.0.2/issues/000077500000000000000000000000001372113677700146315ustar00rootroot00000000000000web-mode-17.0.2/issues/0000.psp000066400000000000000000000005171372113677700157370ustar00rootroot00000000000000
test xx
web-mode-17.0.2/issues/0274.html000066400000000000000000000002221372113677700161070ustar00rootroot00000000000000 web-mode-17.0.2/issues/0397.html000066400000000000000000000000411372113677700161140ustar00rootroot00000000000000
text
web-mode-17.0.2/issues/0411-2.jsx000066400000000000000000000002451372113677700161040ustar00rootroot00000000000000var ColumnSelect = React.createClass({ propTypes: { value: React.PropTypes.any, schema: React.PropTypes.object, onChange: React.PropTypes.func } }); web-mode-17.0.2/issues/0411.jsx000066400000000000000000000006621372113677700157500ustar00rootroot00000000000000function hello() { return (
{somevar}
Column1
Column2
); } Landing = React.createClass({ render: function() { return ( ); } }); web-mode-17.0.2/issues/0412.psp000066400000000000000000000003021372113677700157360ustar00rootroot00000000000000 web-mode-17.0.2/issues/0414.djhtml000066400000000000000000000001771372113677700164320ustar00rootroot00000000000000

the open control block above is inside an html attr

xqsx web-mode-17.0.2/issues/0415.erb000066400000000000000000000001161372113677700157120ustar00rootroot00000000000000 web-mode-17.0.2/issues/0416.djhtml000066400000000000000000000001151372113677700164240ustar00rootroot00000000000000 ', '' ); } tha_header_bottom(); ?> <% inner() %> web-mode-17.0.2/issues/0486.html000066400000000000000000000002061372113677700161160ustar00rootroot00000000000000 web-mode-17.0.2/issues/0491.jsx000066400000000000000000000001411372113677700157500ustar00rootroot00000000000000function makeFoo (n) { return } web-mode-17.0.2/issues/0492.erb000066400000000000000000000003061372113677700157200ustar00rootroot00000000000000<% form_for Foo do |f| %> <%= f.text_field :bar_1 %> <%= f.text_field :bar_2 %> <% end %> <% form_for Foo do |form| %> <%= form.text_field :bar_1 %> <%= form.text_field :bar_2 %> <% end %> web-mode-17.0.2/issues/0504.jinja000066400000000000000000000003461372113677700162410ustar00rootroot00000000000000
{% set foo = 'bar' %} {% if someting %} {% trans %} {% endtrans %} {% else %} {% for x in [1, 2, 3] %} a {% else %} b {% endfor %} {% endif %}
web-mode-17.0.2/issues/0510.jsx000066400000000000000000000000721372113677700157430ustar00rootroot00000000000000@decorator1() @decorator2() @decorator3() class Name { } web-mode-17.0.2/issues/0511.jsx000066400000000000000000000000321372113677700157400ustar00rootroot00000000000000
{123} {x
web-mode-17.0.2/issues/0512.blade.php000066400000000000000000000001501372113677700167730ustar00rootroot00000000000000
This is a test. {{ URL::action('someaction', [$arg]) }}
web-mode-17.0.2/issues/0523.jsx000066400000000000000000000002311372113677700157440ustar00rootroot00000000000000return ( {this.props.children} ); web-mode-17.0.2/issues/0524.php000066400000000000000000000001001372113677700157230ustar00rootroot00000000000000 web-mode-17.0.2/issues/0530.erb000066400000000000000000000010651372113677700157140ustar00rootroot00000000000000<%= simple_form_for @post, url: post_url(@post), html: { data: { title: 'post' } } do |f| %>
<% end %> <%= simple_form_for @user do |f| %> <%= f.input :username, label_html: { class: 'my_class' } %> <%= f.input :password, hint: false, error_html: { id: 'password_error'} %> <%= f.input :password_confirmation, label: false %> <%= f.button :submit %> <% end %> <%= simple_form_for @post, url: post_url(@post), html: { data: { title: 'post' } } do |f| %> <% label_tag do %> <% end %> <% end %> web-mode-17.0.2/issues/0532.jsx000066400000000000000000000003021372113677700157430ustar00rootroot00000000000000React.createClass({ render: function() { const elem = [ {this.renderModalOnTop()} ]; return elem[0]; } }); web-mode-17.0.2/issues/0536.psp000066400000000000000000000002001372113677700157420ustar00rootroot00000000000000 web-mode-17.0.2/issues/0537.psp000066400000000000000000000002021372113677700157450ustar00rootroot00000000000000 var test; function initialize() { alert(3); } EOTHTML; web-mode-17.0.2/issues/0538.psp000066400000000000000000000000551372113677700157540ustar00rootroot00000000000000 web-mode-17.0.2/issues/0540.psp000066400000000000000000000002671372113677700157520ustar00rootroot00000000000000
web-mode-17.0.2/issues/0542.erb000066400000000000000000000001421372113677700157120ustar00rootroot00000000000000
<% a = [ [1, 2], [3, 4] ] b = 10 %>
web-mode-17.0.2/issues/0545.vtl000066400000000000000000000001071372113677700157530ustar00rootroot00000000000000
#if(true) something #end #set( $value = $foo + 1 )
web-mode-17.0.2/issues/0547.psp000066400000000000000000000006761372113677700157650ustar00rootroot00000000000000 web-mode-17.0.2/issues/0548.html000066400000000000000000000001671372113677700161230ustar00rootroot00000000000000 web-mode-17.0.2/issues/0561.js000066400000000000000000000004371372113677700155660ustar00rootroot00000000000000var test = function(){ var n = 10; switch (n){ case: console.log("test"); break; case: break; } }); AppDispatcher.register(function(action){ var n = 10; switch (n){ case 9: console.log(n); break; case 10: break; } }); web-mode-17.0.2/issues/0561.jsx000066400000000000000000000004361372113677700157550ustar00rootroot00000000000000var test = function(){ var n = 10; switch (n){ case: console.log("test"); break; case: break; } }); AppDispatcher.register(function(action){ var n = 10; switch (n){ case 9: console.log(n); break; case 10: break; } }); web-mode-17.0.2/issues/0564.js000066400000000000000000000000241372113677700155610ustar00rootroot00000000000000function test() { } web-mode-17.0.2/issues/0565.erb000066400000000000000000000001641372113677700157230ustar00rootroot00000000000000
web-mode-17.0.2/issues/0573.jsx000066400000000000000000000002541372113677700157560ustar00rootroot00000000000000function f() { var x = true ?
: ''; return x; // pressing tab doesn't indent. } function f2() { // pressing tab here indents to the opening brace. :( } web-mode-17.0.2/issues/0576.jsx000066400000000000000000000002131372113677700157540ustar00rootroot00000000000000var MyClass = react.createClass({ render: function() { var hello =
; return hello; } }); web-mode-17.0.2/issues/0577.erb000066400000000000000000000000661372113677700157270ustar00rootroot00000000000000
<%= link_to 'Back', not_return_path %>
web-mode-17.0.2/issues/0587.html000066400000000000000000000012271372113677700161240ustar00rootroot00000000000000 web-mode-17.0.2/issues/0591.jsx000066400000000000000000000005211372113677700157530ustar00rootroot00000000000000import React, { Component, PropTypes } from 'react' export default class MatchRow extends Component { render() { return ( ) } } web-mode-17.0.2/issues/0596.underscore.html000066400000000000000000000001721372113677700202720ustar00rootroot00000000000000
<% var title_text = ""; var expand_text = ""; if (1) { title_text = "foo"; expand_text = "Add Key"; } %>
web-mode-17.0.2/issues/0598.css000066400000000000000000000000001372113677700157360ustar00rootroot00000000000000web-mode-17.0.2/issues/0601.psp000066400000000000000000000002421372113677700157410ustar00rootroot00000000000000
renderNothing( "organisation_name" ); return; } ?>
web-mode-17.0.2/issues/0607.blade.php000066400000000000000000000076531372113677700170170ustar00rootroot00000000000000 @yield('title') - BoardSoc {!! Navbar::top()->withBrand('Foo') !!} {!! Navbar::top() ->withBrand('Card/BoardSoc') ->withContent( Navigation::links([ [ 'title' => 'Home', 'link' => route('home'), ], [ 'title' => 'About/Contact', 'link' => route('about'), ], [ 'title' => 'Events', 'link' => route('events.index'), ], [ 'title' => 'Library', 'link' => route('library.index'), ], [ 'title' => 'Achievements', 'link' => route('achievements.index'), ], [ 'title' => 'Admin', 'link' => route('admin.index'), 'callback' => function() { return Auth::check() && Auth::user()->is_committee; } ], ]) ) ->withContent( $loginFormOrLogoutLink ) !!} @yield('page-header') @if (Session::has('flash_notification.message'))
{{ Session::get('flash_notification.message') }}
@endif @foreach($errors->all() as $error)
{{ $error }}
@endforeach @yield('content')

About

BoardSoc is a student society of the University of Sheffield, focused on playing modern(ish) board games. Interested in more information? Then {!! link_to_route('about', 'read more here') !!}!

Social Links

Our Bunker

Sheffield Card/BoardSoc
University Of Sheffield
10-12 Brunswick Street
Sheffield, Eng S10 2FN
{!! Helpers::js() !!} web-mode-17.0.2/issues/0608.tt000066400000000000000000000001531372113677700155760ustar00rootroot00000000000000%% IF condition

Hello

%% END instead of [% IF condition -%]

Hello

[% END -%] %%# dcd web-mode-17.0.2/issues/0609.jsx000066400000000000000000000014661372113677700157640ustar00rootroot00000000000000import React from 'react'; export default React.createClass({ getPair: function () { return this.props.pair || []; }, isDisabled: function () { return !!this.props.hasVoted; }, hasVotedFor: function (entry) { return this.props.hasVoted === entry; }, render: function () { return (
{this.props.winner ?
Winner is {this.props.winner}!
: this.getPair().map(entry => )}
); } }); web-mode-17.0.2/issues/0611.jsx000066400000000000000000000014661372113677700157550ustar00rootroot00000000000000import React from 'react'; export default React.createClass({ getPair: function () { return this.props.pair || []; }, isDisabled: function () { return !!this.props.hasVoted; }, hasVotedFor: function (entry) { return this.props.hasVoted === entry; }, render: function () { return (
{this.props.winner ?
Winner is {this.props.winner}!
: this.getPair().map(entry => )}
); } }); web-mode-17.0.2/issues/0612.html000066400000000000000000000000341372113677700161040ustar00rootroot00000000000000
#aaa #aaaaaa
web-mode-17.0.2/issues/0613.jsx000066400000000000000000000002271372113677700157510ustar00rootroot00000000000000var ExampleComponent = React.createClass({ render: function () { return (
) } }) web-mode-17.0.2/issues/0614.hbs000066400000000000000000000001161372113677700157170ustar00rootroot00000000000000
{{foo-block foo1=bar1 foo2="bar2" foo3=(inner-helper "bar3")}}
web-mode-17.0.2/issues/0615.jsx000066400000000000000000000022171372113677700157540ustar00rootroot00000000000000import React from 'react'; import {Row, Col, Glyphicon, Input, Breadcrumb, BreadcrumbItem} from 'react-bootstrap'; export default React.createClass({ render: function () { const breadcrumb = ( { (this.props.scope.get('type') !== "home") ? {this.props.scope.get('scope') || this.props.scope.get('parent')} : null} { this.props.scope.get('type') === "topic" ? {this.props.scope.get('value')} : null } ); const innerGlyphicon = ; return ( {breadcrumb} ); } }); web-mode-17.0.2/issues/0619.jsx000066400000000000000000000004421372113677700157560ustar00rootroot00000000000000class Square extends React.Component { constructor(props) { super(props); this.state = { value: null, }; } render() { return ( ); } } web-mode-17.0.2/issues/0620.jsp000066400000000000000000000001341372113677700157340ustar00rootroot00000000000000
Not commented <%-- xs -- %> Commented <%-- --%> Not commented again
web-mode-17.0.2/issues/0621.jsx000066400000000000000000000005521372113677700157510ustar00rootroot00000000000000// Same results if Label and Input are not imported import { React, Component } from 'react' import { Label, Input } from 'react-bootstrap' export default class Test extends Component { render() { return ( ) } } web-mode-17.0.2/issues/0623.jsp000066400000000000000000000000651372113677700157420ustar00rootroot00000000000000
web-mode-17.0.2/issues/0626.jsp000066400000000000000000000001041372113677700157370ustar00rootroot00000000000000
<%-- Test --%> <%-- --%> Words <%-- --%>
web-mode-17.0.2/issues/0627.js000066400000000000000000000003701372113677700155650ustar00rootroot00000000000000class Test { constructor() { super(...arguments); let a = 1 // This should not indent. } } const a = {} const b = { ...a, // This should indent. ...b, ...c } newB.firstMethod('x') .secondMethod('y') .thirdMethod(1,15,'z'); web-mode-17.0.2/issues/0632.jsx000066400000000000000000000014571372113677700157600ustar00rootroot00000000000000export default class App extends Component { render() { return (
console.log('add todo', text); } /> console.log('todo clicked', index) } />
console.log('filter change', filter) } />
); } } web-mode-17.0.2/issues/0633.js000066400000000000000000000000341372113677700155570ustar00rootroot00000000000000test1() {} test2 = () => {} web-mode-17.0.2/issues/0635.html000066400000000000000000000003641372113677700161170ustar00rootroot00000000000000 web-mode-17.0.2/issues/0637.js000066400000000000000000000002751372113677700155720ustar00rootroot00000000000000function test() { switch (q) { case 'a': return a; case 'b': return b; case 'c': return c; case 'd': return d; default: return []; } } web-mode-17.0.2/issues/0638.js000066400000000000000000000000441372113677700155650ustar00rootroot00000000000000if (x && y) { return 1; } web-mode-17.0.2/issues/0644.psp000066400000000000000000000000301372113677700157430ustar00rootroot00000000000000 web-mode-17.0.2/issues/0645.js000066400000000000000000000012721372113677700155670ustar00rootroot00000000000000router.get('/alerts', (request, response) => { const query = request.query; }); router.get('/alerts', function(request, response) { const query = request.query; }); // Basic syntax: (param1, param2, paramN) => { statements } (param1, param2, paramN) => expression // equivalent to: => { return expression; } // Parentheses are optional when there's only one argument: (singleParam) => { statements } singleParam => { statements } // A function with no arguments requires parentheses: () => { statements } // Advanced: // Parenthesize the body to return an object literal expression: params => ({foo: bar}) // Rest parameters are supported (param1, param2, ...rest) => { statements } web-mode-17.0.2/issues/0648.html000066400000000000000000000001721372113677700161200ustar00rootroot00000000000000 web-mode-17.0.2/issues/0649.erb000066400000000000000000000002041372113677700157210ustar00rootroot00000000000000<% layout.columns.each do |col| %> <%= best_in_place(expense, col) %> <% end %> web-mode-17.0.2/issues/0650.xml000066400000000000000000000001051372113677700157410ustar00rootroot00000000000000 web-mode-17.0.2/issues/0651.psp000066400000000000000000000002121372113677700157430ustar00rootroot00000000000000
web-mode-17.0.2/issues/0653.css000066400000000000000000000002461372113677700157420ustar00rootroot00000000000000@import url('https://fonts.googleapis.com/css?family=Merriweather'); $red: #f00; body { margin: 0; padding: 0; background: #722; } #features { margin:0; } web-mode-17.0.2/issues/0654.html000066400000000000000000000002751372113677700161210ustar00rootroot00000000000000 web-mode-17.0.2/issues/0655.html000066400000000000000000000026021372113677700161160ustar00rootroot00000000000000 Navbar Template for Bootstrap web-mode-17.0.2/issues/0657.tpl000066400000000000000000000002551372113677700157550ustar00rootroot00000000000000
{if $condition} this aligned to { {else} so do this {/if} {foreach $items as $i} {$i} {/foreach}
web-mode-17.0.2/issues/0658.psp000066400000000000000000000000221372113677700157510ustar00rootroot00000000000000 web-mode-17.0.2/issues/0659.jsx000066400000000000000000000004071372113677700157630ustar00rootroot00000000000000function foo() { return ; } web-mode-17.0.2/issues/0660.psp000066400000000000000000000000301372113677700157410ustar00rootroot00000000000000 @foo(bar: String) = { @for(i <- 1 to 10) {
@i
} @if(bar == "bar") {
@bar
} } web-mode-17.0.2/issues/0669.djhtml000066400000000000000000000002531372113677700164410ustar00rootroot00000000000000
{% csrf_token %} {{ form.as_table }}
web-mode-17.0.2/issues/0670.erb000066400000000000000000000001411372113677700157130ustar00rootroot00000000000000 <%= render "form.html", changeset: @changeset, action: trade_path(@conn, :update, @trade) %> web-mode-17.0.2/issues/0674.jsx000066400000000000000000000013051372113677700157560ustar00rootroot00000000000000import React, { Component } from 'react'; class CheckList extends Component { myTestFunc() { if (test) { if (test2) { console.log("Broken"); } } } render() { let tasks = this.props.tasks.map( (task) => (
  • {task.name}
  • )); return (
      {tasks}
    ); } } export default CheckList; web-mode-17.0.2/issues/0679.html000066400000000000000000000000321372113677700161170ustar00rootroot00000000000000
    cd
    web-mode-17.0.2/issues/0688.psp000066400000000000000000000004741372113677700157670ustar00rootroot00000000000000 var CommentList = React.createClass({ render: function() { var comments = this.props.data.map(function(comment) { return ( {csomment.text} ); }); } }); web-mode-17.0.2/issues/0691.html000066400000000000000000000075541372113677700161310ustar00rootroot00000000000000 React Tutorial
    web-mode-17.0.2/issues/0691.jsx000066400000000000000000000056531372113677700157670ustar00rootroot00000000000000var data = [ {id: 1, author: "Pete Hunt", text: "This is one comment"}, {id: 2, author: "Jordan Walke", text: "This is *another* comment"} ]; var Comment = React.createClass({ rawMarkup: function() { var rm = marked(this.props.children.toString(), {sanitize: true}); return { __html: rm }; }, render: function() { return (

    {this.props.author}

    ); } }); var CommentList = React.createClass({ render: function() { var comments = this.props.data.map(function(comment) { return ( {comment.text} ); }); return (
    {comments}
    ); } }); var CommentForm = React.createClass({ getInitialState: function() { return { author: '', text: '' }; }, handleAuthorChange: function(e) { this.setState({author: e.target.value}); }, handleTextChange: function(e) { this.setState({text: e.target.value}); }, handleSubmit: function(e) { e.preventDefault(); var author = this.state.author.trim(); var text = this.state.text.trim(); if (!text || !author) { return; } // TODO: send request to the server this.props.onCommentSubmit({author: author, text: text}); this.setState({author: '', text: ''}); }, render: function() { return (
    ); } }); var CommentBox = React.createClass({ loadCommentsFromServer: function() { $.ajax({ url: this.props.url, dataType: 'json', cache: false, success: function(data) { this.setState({data: data}); }.bind(this), error: function(xhr, status, err) { console.error(this.props.url, status, err.toString()); }.bind(this) }); }, handleCommentSubmit: function(comment) { $.ajax({ url: this.props.url, dataType: 'json', type: 'POST', data: comment, success: function(data) { this.setState({data: data}); }.bind(this), error: function(xhr, status, err) { console.error(this.props.url, status, err.toString()); }.bind(this) }); }, getInitialState: function() { return {data: []}; }, componentDidMount: function() { this.loadCommentsFromServer(); setInterval(this.loadCommentsFromServer, this.props.pollInterval); }, render: function() { return (

    Comments

    ); } }); ReactDOM.render( , document.getElementById('content') ); web-mode-17.0.2/issues/0691bis.html000066400000000000000000000011231372113677700166110ustar00rootroot00000000000000 web-mode-17.0.2/issues/0696.js000066400000000000000000000003661372113677700156000ustar00rootroot00000000000000foo() { // cdcd bar() baz() if(true) hello(); if (true) //csdc hello(); } if ( value.length < fieldSpec.minNumberOfChar || value.length > fieldSpec.maxNumberOfChar || value.match( fieldSpec.pattern) ) return true; web-mode-17.0.2/issues/0701.jsp000066400000000000000000000001551372113677700157370ustar00rootroot00000000000000<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> ... web-mode-17.0.2/issues/0702.psp000066400000000000000000000000451372113677700157440ustar00rootroot00000000000000 <#--- -- | --> web-mode-17.0.2/issues/0705.mako000066400000000000000000000002001372113677700160650ustar00rootroot00000000000000<%block filter="collect_js"> // js content var x; and <%block filter="collect_css"> span { width:10px; } web-mode-17.0.2/issues/0708.html000066400000000000000000000002101372113677700161060ustar00rootroot00000000000000 web-mode-17.0.2/issues/0709.erb.html000066400000000000000000000005571372113677700166740ustar00rootroot00000000000000

    <% store_states.each do |state| %> <% unless state.first.blank? %> <%= state.first %>  <% if state.first == "MT" %> Yes <% end %> <% end %> <% end %>

    web-mode-17.0.2/issues/0712.html000066400000000000000000000002001372113677700161000ustar00rootroot00000000000000 web-mode-17.0.2/issues/0716.chtml000066400000000000000000000001231372113677700162530ustar00rootroot00000000000000{{foo foo-with-hyphens="bar" prop1="bar" prop2='bar' prop=(or a (and b c) d e) }} web-mode-17.0.2/issues/0717.html000066400000000000000000000002111372113677700161070ustar00rootroot00000000000000 web-mode-17.0.2/issues/0720.chtml000066400000000000000000000000611372113677700162470ustar00rootroot00000000000000
    {{foo prop=(or a (and b c) d e)}}
    web-mode-17.0.2/issues/0721.chtml000066400000000000000000000002501372113677700162500ustar00rootroot00000000000000
    {{#if foo}} {{#each bar}} foo {{else}} bar {{/each}} {{/if}}
    {{#if foo}} foo {{else}} bar {{/if}}
    web-mode-17.0.2/issues/0722.html000066400000000000000000000003571372113677700161160ustar00rootroot00000000000000 web-mode-17.0.2/issues/0725.cshtml000066400000000000000000000003301372113677700164360ustar00rootroot00000000000000 web-mode-17.0.2/issues/0728.psp000066400000000000000000000012011372113677700157470ustar00rootroot00000000000000
    ]*)?>(.*?)<\/h[123456]>/i', // h1 - h6 '/[ ]*<(p)( [^>]*)?>(.*?)<\/p>[ ]*/si', //

    with surrounding whitespace. '/<(br)[^>]*>[ ]*/i', //
    with leading whitespace after the newline. '/<(b)( [^>]*)?>(.*?)<\/b>/i', // '/<(strong)( [^>]*)?>(.*?)<\/strong>/i', // '/<(th)( [^>]*)?>(.*?)<\/th>/i', // and '/<(a) [^>]*href=("|\')([^"\']+)\2([^>]*)>(.*?)<\/a>/i' // ); ?>

    web-mode-17.0.2/issues/0731.html000066400000000000000000000002641372113677700161130ustar00rootroot00000000000000 web-mode-17.0.2/issues/0732.html000066400000000000000000000001761372113677700161160ustar00rootroot00000000000000 web-mode-17.0.2/issues/0738.jsx000066400000000000000000000001151372113677700157550ustar00rootroot00000000000000const AComponent = ({arg1, arg2, arg3}) => (

    {arg1} {arg2} {arg3}

    ) web-mode-17.0.2/issues/0739.jsx000066400000000000000000000006501372113677700157620ustar00rootroot00000000000000export default React.createClass({ getInitialState() { return { num: this.getRandomNumber() }; }, getRandomNumber(): number { return Math.ceil(Math.random() * 6); }, render(): any { return ; } }); web-mode-17.0.2/issues/0741.html000066400000000000000000000001251372113677700161100ustar00rootroot00000000000000
    • zzz
    • ccccc
    • xsdcqsdv sdqv
    • csqcd
    web-mode-17.0.2/issues/0742.html000066400000000000000000000004101372113677700161060ustar00rootroot00000000000000 web-mode-17.0.2/issues/0743.html000066400000000000000000000005071372113677700161160ustar00rootroot00000000000000 web-mode-17.0.2/issues/0745.axvw000066400000000000000000000051241372113677700161410ustar00rootroot00000000000000 Free Capacity select 'Water Usage Comparison' water_usage_label, 'Water Cost Comparison' water_cost_label, sum(case when b.time_period like '2013-%' then a.qty_volume * c.area_fraction else 0 end) base_usage_hcf from bill_line_archive a join bill_archive b on a.bill_id = b.bill_id join rsc_primary_building c on b.bl_id = c.primary_bl_id and a.meterseq = c.meterseq join bl d on c.bl_id = d.bl_id join vn e on a.vn_id = e.vn_id where b.bill_type_id = 'WATER' Water Usage Water Cost 2013 Usage (HCF)
    7 days Previous week web-mode-17.0.2/issues/0749.cshtml000066400000000000000000000000731372113677700164500ustar00rootroot00000000000000@* toto *@ @if (something) { var x; } else { var y; } web-mode-17.0.2/issues/0752.chtml000066400000000000000000000003261372113677700162600ustar00rootroot00000000000000
    {{^block}} is not highlighted, {{object.key}} - dot notation highlight is broken.
    {{#object.key}} is closing to {{/object.key}} {{#object_list}} is closing to {{/object_list}}
    web-mode-17.0.2/issues/0757.html000066400000000000000000000000761372113677700161240ustar00rootroot00000000000000 web-mode-17.0.2/issues/0759.html000066400000000000000000000001071372113677700161210ustar00rootroot00000000000000 cd web-mode-17.0.2/issues/0761.html000066400000000000000000000001101372113677700161040ustar00rootroot00000000000000 wq web-mode-17.0.2/issues/0762.html000066400000000000000000000000301372113677700161060ustar00rootroot00000000000000 web-mode-17.0.2/issues/0764.ejs000066400000000000000000000002601372113677700157320ustar00rootroot00000000000000
    <% if (1) { %> <% } else { %> <% } %> test test test web-mode-17.0.2/issues/0765.underscore.html000066400000000000000000000003061372113677700202670ustar00rootroot00000000000000
    <% _.each(images, function(value, imageid) { %> <% if (isadmin) { %>
    <% } else { %> <% } %> <% } %> web-mode-17.0.2/issues/0767.html000066400000000000000000000006371372113677700161300ustar00rootroot00000000000000 web-mode-17.0.2/issues/0775.jsx000066400000000000000000000012251372113677700157610ustar00rootroot00000000000000var React = require('react') return React.render(
    { conditional && }
    Hello
    ); React.createClass({ render() { return (
      cqsd { (this.props.scope.get('type') !== "home") ? {this.props.scope.get('scope') || this.props.scope.get('parent')} : null}
    ); } }); web-mode-17.0.2/issues/0779.jsx000066400000000000000000000006751372113677700157750ustar00rootroot00000000000000import React from 'react'; import ReactDOM from 'react-dom'; /* var React = require('react');*/ class App extends React.Component { render() { return (
    Hello World!!!
    {1 + 1} {/* Here is some kind of comment in React */}
    ); } } export default App; /* export default (props) => { * return

    Hello, World!

    ; * }*/ ReactDOM.render(, document.getElementById('example')); web-mode-17.0.2/issues/0783.jsx000066400000000000000000000003441372113677700157610ustar00rootroot00000000000000export default class Header extends Component { render() { return (
    {this.getChildren()}
    ); } } web-mode-17.0.2/issues/0786.dust000066400000000000000000000020661372113677700161420ustar00rootroot00000000000000
    Information...
    web-mode-17.0.2/issues/0787.jsx000066400000000000000000000003661372113677700157710ustar00rootroot00000000000000export default class Header extends Component { render() { return (
    {this.getChildren()}
    ); } } web-mode-17.0.2/issues/0789.html000066400000000000000000000016271372113677700161340ustar00rootroot00000000000000
    web-mode-17.0.2/issues/0791.psp000066400000000000000000000000511372113677700157510ustar00rootroot00000000000000
    web-mode-17.0.2/issues/0796.psp000066400000000000000000000002101372113677700157530ustar00rootroot00000000000000
    web-mode-17.0.2/issues/0800.js000066400000000000000000000002531372113677700155560ustar00rootroot00000000000000const hello = { [a]: (args) => { // indents correctly }, [b]: (args) => { // indents all the way up here }, [c]: (args) => { // even worse } } web-mode-17.0.2/issues/0801.jsx000066400000000000000000000003631372113677700157510ustar00rootroot00000000000000import React from 'react' class Example extends Component { render() { return (
    {this.props.condition ? ( ) : ( )}
    ) } } web-mode-17.0.2/issues/0802.js000066400000000000000000000001431372113677700155560ustar00rootroot00000000000000 import React from 'react'; import { mount, shallow } from 'enzyme'; import {expect} from 'chai'; web-mode-17.0.2/issues/0805.djhtml000066400000000000000000000002331372113677700164270ustar00rootroot00000000000000
    {% graph %} xsxs {% endgraph %} {% if block %} Content {% endif %} {% javascript %} var x = 1; {% endjavascript %}
    web-mode-17.0.2/issues/0807.js000066400000000000000000000020411372113677700155620ustar00rootroot00000000000000Relay.createContainer(Story, { initialVariables: { numCommentsToShow: 10, showComments: false, }, fragments: { story: (variables) => Relay.QL` fragment on Story { comments(first: $numCommentsToShow) @include(if: $showComments) { edges { node { author { name }, id, text, }, }, }, } `, } }); // An inline fragment - useful in small quantities, but best not to share // between modules. var userFragment = Relay.QL` fragment on User { name, } `; Relay.createContainer(Story, { fragments: { bar: () => Relay.QL` fragment on Story { author { # Fetch the same information about the story's author ... ${userFragment}, }, comments { edges { node { author { # ... and the authors of the comments. ${userFragment}, }, }, }, }, } `, } }); web-mode-17.0.2/issues/0810.jsx000066400000000000000000000002071372113677700157460ustar00rootroot00000000000000f() { const a =
    const b =
    } class C { render() { if (a) return
    A
    return
    B
    } } web-mode-17.0.2/issues/0814.html000066400000000000000000000005331372113677700161140ustar00rootroot00000000000000
    foo<%= value.creator %>
    foobar
    xx cdc
    web-mode-17.0.2/issues/0815.html000066400000000000000000000001011372113677700161040ustar00rootroot00000000000000 web-mode-17.0.2/issues/0817.html000066400000000000000000000001551372113677700161170ustar00rootroot00000000000000
    folds
    folds
    won't fold
    web-mode-17.0.2/issues/0823.html000066400000000000000000000002441372113677700161130ustar00rootroot00000000000000
    web-mode-17.0.2/issues/0824.js000066400000000000000000000002651372113677700155670ustar00rootroot00000000000000const Button = styled.button` border-radius: 3px; padding: 0.25em 1em; margin: 0 1em; background: transparent; color: palevioletred; border: 2px solid palevioletred; `; web-mode-17.0.2/issues/0827.js000066400000000000000000000000311372113677700155610ustar00rootroot00000000000000function* generator() {} web-mode-17.0.2/issues/0830.jsx000066400000000000000000000001071372113677700157470ustar00rootroot00000000000000function f() { return true && || ; } web-mode-17.0.2/issues/0831.js000066400000000000000000000005031372113677700155600ustar00rootroot00000000000000axios.get('https://some-url') .then(JSON.parse) .then(console.log) .catch(console.error); // a promise returned from a function const someFunc = () => { return somePromise() .then() .catch() } // implicit return const someFunc = () => somePromise() .then() // no indent .catch() // no indent } web-mode-17.0.2/issues/0839.html000066400000000000000000000001011372113677700161120ustar00rootroot00000000000000
    web-mode-17.0.2/issues/0840.twig000066400000000000000000000002101372113677700161110ustar00rootroot00000000000000
      {% for user in users %}
    • {{ user.username|e }}
    • {% else %}
    • no user found
    • {% endfor %}
    web-mode-17.0.2/issues/0855.jsx000066400000000000000000000003371372113677700157630ustar00rootroot00000000000000import * as React from 'react'; interface Props { name: string } class MyThing extends React.Component { render() { return hi; } } export default MyThing as React.ComponentClass; web-mode-17.0.2/issues/0856.razor000066400000000000000000000001721372113677700163120ustar00rootroot00000000000000
    @model IEnumerable @a('foo, '\b', "dwdd")
    this is a test.
    web-mode-17.0.2/issues/0857.html000066400000000000000000000000561372113677700161230ustar00rootroot00000000000000 web-mode-17.0.2/issues/0864.html000066400000000000000000000002741372113677700161230ustar00rootroot00000000000000{# -*- engine: jinja2 -*- #} {% block title %}{% endblock %} web-mode-17.0.2/issues/0866.js000066400000000000000000000005121372113677700155700ustar00rootroot00000000000000import gql from 'graphql-tag'; const query = gql` { user(id: 5) { firstName lastName } } ` new Vue({ el: '#toto', template: `
    titi toto
    toto
    ` }); web-mode-17.0.2/issues/0868.soy000066400000000000000000000000701372113677700157670ustar00rootroot00000000000000
    {namespace foo.bar requirecss="styles"}
    web-mode-17.0.2/issues/0870.jsx000066400000000000000000000006071372113677700157600ustar00rootroot00000000000000import React, {Component} from 'react'; class Confirm extends Component { render() { const project = this.props.project; return (
    {project.foo && (
    Foo
    )} {project.bar && (

    Bar

    )}
    ); } } export default Confirm; web-mode-17.0.2/issues/0872.jsx000066400000000000000000000001501372113677700157530ustar00rootroot00000000000000import React from 'react'; const Front = props => { return
    hello
    ; }; web-mode-17.0.2/issues/0876.css000066400000000000000000000001421372113677700157440ustar00rootroot00000000000000@font-face { font-family: 'Exo'; src: url('titi'), url('toto'); font-weight: 700; } web-mode-17.0.2/issues/0877.jsx000066400000000000000000000021651372113677700157700ustar00rootroot00000000000000import React, {Component} from 'react'; class Confirm extends Component { render() { const project = this.props.project; return ( ( )} /> ) } } import React, {Component} from 'react'; class Confirm extends Component { render() { const project = this.props.project; return ( ( ) } /> ) } }; class Test extends Component { render() { return ( ( )} /> ( )} /> ) } } web-mode-17.0.2/issues/0880.jsx000066400000000000000000000001631372113677700157560ustar00rootroot00000000000000const Demo = () => ( } > ); web-mode-17.0.2/issues/0882.jsx000066400000000000000000000006611372113677700157630ustar00rootroot00000000000000import React, {Component} from 'react'; class Confirm extends Component { render() { const project = this.props.project; return ( text } />
    ) } } web-mode-17.0.2/issues/0883.erb000066400000000000000000000016731372113677700157340ustar00rootroot00000000000000
    <% content_for :title, t('moderation_queue.moderation_queue') content_for :h1, t('moderation_queue.moderation_queue') content_for :body_id, 'moderation_queue-index' content_for :body_classes, 'moderation_queue index' %>
    <%# Link showing page number - available local variables page: a page object for "this" page url: url to this page current_page: a page object for the currently displayed page total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%><% attrs = {} attrs['aria-disabled'] = 'true' if page.current? attrs[:rel] = 'next' if page.next? attrs[:rel] = 'prev' if page.prev? attrs[:remote] = remote -%>
  • <%= cf_link_to page, url + @doc_fragment.to_s, attrs %>
  • <% a=x.y_for_w(1) b=css_class_x2 c=3 d=4 %>
    web-mode-17.0.2/issues/0887.html000066400000000000000000000000241372113677700161210ustar00rootroot00000000000000 web-mode-17.0.2/issues/0895.html000066400000000000000000000012371372113677700161270ustar00rootroot00000000000000 web-mode-17.0.2/issues/0903.psp000066400000000000000000000000711372113677700157460ustar00rootroot00000000000000
    web-mode-17.0.2/issues/0904.jsx000066400000000000000000000011441372113677700157530ustar00rootroot00000000000000render() { return ( { this.textInput = textInput; }} style={styles.textInput} placeholder="Enter a comment..." value={this.state.pendingTest} onChange={this.onPendingTestChanged} onChangeText={this.onPendingTestTextChanged} multiline={true} maxLength={1000} /> Post ) } web-mode-17.0.2/issues/0905.html000066400000000000000000000006371372113677700161220ustar00rootroot00000000000000 Example

    Example example example

    Example example example

    Articles

    • toto
    • csqc cdscsdv

    Page one

    Page two

    Page three web-mode-17.0.2/issues/0911.js000066400000000000000000000001341372113677700155570ustar00rootroot00000000000000class x { constructor() { this.a = 1; call(); } foo() { this.b = 2; } } web-mode-17.0.2/issues/0912.ftl000066400000000000000000000002571372113677700157370ustar00rootroot00000000000000[#include "/WEB-INF/common/header.ftl"] [#assign testVar=false] [#if object?has_content] Has content [#else] No content [/#if] web-mode-17.0.2/issues/0913.html000066400000000000000000000003431372113677700161130ustar00rootroot00000000000000

    Zero

    One

    Two

    Three

    Four

    web-mode-17.0.2/issues/0915.twig000066400000000000000000000003241372113677700161220ustar00rootroot00000000000000
    {{ form_start(form) }} {{ form_errors(form) }} {{ form_row(form.name) }} {{ form_row(form.dueDate) }} {{ form_row(form.submit, { 'label': 'Submit me' }) }} {{ form_end(form) }}
    web-mode-17.0.2/issues/0920.jsx000066400000000000000000000004211372113677700157460ustar00rootroot00000000000000function s(action) { switch(action.type) { case SUBSCRIBE: // TODO some comment here // another line here // line ending with a period. resource = action.resourceDescription.resource; return 0; case UNSUBSCRIBE: return 1; default: return 2; } } web-mode-17.0.2/issues/0923.soy000066400000000000000000000003571372113677700157670ustar00rootroot00000000000000
    {switch $numMarbles} {case 0} You have no marbles. {case 1, 2, 3} You have a normal number of marbles. {default} // 4 or more You have more marbles than you know what to do with. {/switch}
    web-mode-17.0.2/issues/0924.html000066400000000000000000000006501372113677700161160ustar00rootroot00000000000000
    web-mode-17.0.2/issues/0925.html000066400000000000000000000000441372113677700161140ustar00rootroot00000000000000
    web-mode-17.0.2/issues/0926.vue000066400000000000000000000002751372113677700157560ustar00rootroot00000000000000 web-mode-17.0.2/issues/0928.vue000066400000000000000000000004511372113677700157540ustar00rootroot00000000000000 web-mode-17.0.2/issues/0929.html000066400000000000000000000004721372113677700161250ustar00rootroot00000000000000 web-mode-17.0.2/issues/0930.twig000066400000000000000000000000441372113677700161160ustar00rootroot00000000000000
    {% if var == true %}
    web-mode-17.0.2/issues/0936.html000066400000000000000000000007641372113677700161270ustar00rootroot00000000000000 web-mode-17.0.2/issues/0938.html000066400000000000000000000005521372113677700161240ustar00rootroot00000000000000
    web-mode-17.0.2/issues/0939.psp000066400000000000000000000001001372113677700157500ustar00rootroot00000000000000
    web-mode-17.0.2/issues/0940.twig000066400000000000000000000001511372113677700161160ustar00rootroot00000000000000
    {{ form_widget(form.address.city, {'attr': {'class': 'form-control form-control-md'}}) }}
    web-mode-17.0.2/issues/0944.html000066400000000000000000000005471372113677700161250ustar00rootroot00000000000000 web-mode-17.0.2/issues/0945.html000066400000000000000000000012201372113677700161130ustar00rootroot00000000000000 web-mode-17.0.2/issues/0947.html000066400000000000000000000001621372113677700161210ustar00rootroot00000000000000 web-mode-17.0.2/issues/0949.html000066400000000000000000000001051372113677700161200ustar00rootroot00000000000000 web-mode-17.0.2/issues/0951.html000066400000000000000000000000761372113677700161200ustar00rootroot00000000000000 web-mode-17.0.2/issues/0952.jsx000066400000000000000000000012731372113677700157610ustar00rootroot00000000000000 render() { return ( <> Some text.

    A heading

    More text.

    Another heading

    Even more text. ); } render() { return ( Some text.

    A heading

    More text.

    Another heading

    Even more text.
    ); } ender() { return ( // Extraneous div element :(
    Some text.

    A heading

    More text.

    Another heading

    Even more text.
    ); } render() { return [ "Some text.",

    A heading

    , "More text.",

    Another heading

    , "Even more text." ]; } web-mode-17.0.2/issues/0954.erb000066400000000000000000000002101372113677700157150ustar00rootroot00000000000000 <%= link_to_unless current_page.last?, raw(''), url, remote: remote, class: 'item' %> web-mode-17.0.2/issues/0955.djhtml000066400000000000000000000003061372113677700164360ustar00rootroot00000000000000 {% for num in range( 1, pages) %} {% if num <= 3 %}
  • {{ num }}
  • {% else %}
  • ......
  • {% endif %} {% endfor %}
    web-mode-17.0.2/issues/0956.html000066400000000000000000000010371372113677700161230ustar00rootroot00000000000000
    hi
    web-mode-17.0.2/issues/0957.djhtml000066400000000000000000000001351372113677700164400ustar00rootroot00000000000000{% extends 'base.html' %} {{ var }} web-mode-17.0.2/issues/0959.js000066400000000000000000000001021372113677700155660ustar00rootroot00000000000000var regexp = /I'm foo/.test("I'm foo") /I'm foo/.test("I'm foo") web-mode-17.0.2/issues/0960.jsx000066400000000000000000000014511372113677700157560ustar00rootroot00000000000000render() { return (
    datalibrary
    ); } web-mode-17.0.2/issues/0961.js000066400000000000000000000001631372113677700155660ustar00rootroot00000000000000const a = ["I'm", "foo"]; switch (true) { case /I'm foo/.test(a.join(' ')): console.log(true); break; } web-mode-17.0.2/issues/0970.gohtml000066400000000000000000000014071372113677700164460ustar00rootroot00000000000000
    {{- with .Title }} {{ . }} {{ end }}
    {{ if not .Params.notoc }} {{end}}
    {{- .Title -}}

    Upcoming Events

      {{ range where .Data.Pages.ByDate "Section" "events" }} {{ if ge .Date.Unix .Now.Unix }}
    • {{ .Type | title }} — {{ .Title }} on {{ .Date.Format "2 January at 3:04pm" }} at {{ .Params.place }}
    • {{ end }} {{ end }}
    web-mode-17.0.2/issues/0976.twig000066400000000000000000000002121372113677700161250ustar00rootroot00000000000000
      {#% for user in users %#}
    • {{ user.username|e }}
    • {% else %}
    • no user found
    • {% endfor %}
    web-mode-17.0.2/issues/0978.psp000066400000000000000000000002101372113677700157550ustar00rootroot00000000000000
    True is true!

    '; else: echo '

    My grasp on reality is slipping

    '; endif; ?>
    web-mode-17.0.2/issues/0979.html000066400000000000000000000001231372113677700161230ustar00rootroot00000000000000

    hellso

    web-mode-17.0.2/issues/0983.jsx000066400000000000000000000005231372113677700157620ustar00rootroot00000000000000render() { return ( ) } web-mode-17.0.2/issues/0984.html000066400000000000000000000010161372113677700161210ustar00rootroot00000000000000 web-mode-17.0.2/issues/0987.eex000066400000000000000000000000231372113677700157360ustar00rootroot00000000000000<% # code block %> web-mode-17.0.2/issues/0988.scala.html000066400000000000000000000041461372113677700172160ustar00rootroot00000000000000@(title: String, description: String = null, js: Html = Html(""), jsAsset: String = null, css: Html = Html(""), cssAsset: String = null, showEntryBtn: Boolean = true)(content: Html) @title @css @if(cssAsset != null) { }
    @if(showEntryBtn) { 返回主界面 }
    @content
    @js web-mode-17.0.2/issues/0989.js000066400000000000000000000002651372113677700156030ustar00rootroot00000000000000let result = (2 > 1) ? "more" : "less"; let result = 2 > 1 ? "more" : "less"; let result = ( 2 > 1 ) "more": "less"; let result = (2 > 1.5) ? "more" : "less"; let number = (2 + 1); web-mode-17.0.2/issues/0992.jsx000066400000000000000000000003211372113677700157560ustar00rootroot00000000000000import React from 'react'; import { Menu } from 'semantic-ui-react'; export default function Example() { return ( ← cursor here ); } web-mode-17.0.2/issues/0995.blade.php000066400000000000000000000001771372113677700170230ustar00rootroot00000000000000@yield('content') @lang('app.name') @guest @choice('foo', 2) @endguest web-mode-17.0.2/issues/0998.html000066400000000000000000000001721372113677700161300ustar00rootroot00000000000000 web-mode-17.0.2/issues/1000.html000066400000000000000000000001111372113677700160700ustar00rootroot00000000000000 web-mode-17.0.2/issues/1002.blade.php000066400000000000000000000003321372113677700167700ustar00rootroot00000000000000
    @field([ 'label' => 'Foo', 'values' => ['bar'] ])
    @section('content') Foo @endsection
    @sectionInner(['name' => 'Foo'])

    foo

    @endsectionInner
    web-mode-17.0.2/issues/1003.html000066400000000000000000000023541372113677700161060ustar00rootroot00000000000000 web-mode-17.0.2/issues/1006.html000066400000000000000000000000771372113677700161110ustar00rootroot00000000000000 web-mode-17.0.2/issues/1009.html000066400000000000000000000000671372113677700161130ustar00rootroot00000000000000
    text
    text
    web-mode-17.0.2/issues/1013.html000066400000000000000000000003061372113677700161020ustar00rootroot00000000000000 web-mode-17.0.2/issues/1014.html000066400000000000000000000003061372113677700161030ustar00rootroot00000000000000 web-mode-17.0.2/issues/1016.js000066400000000000000000000001031372113677700155500ustar00rootroot00000000000000type T = {| x: number, titi: y, |}; var toto = { x, b }; web-mode-17.0.2/issues/1020.html000066400000000000000000000000451372113677700161000ustar00rootroot00000000000000 web-mode-17.0.2/issues/1021.js000066400000000000000000000000141372113677700155450ustar00rootroot00000000000000/* test; */ web-mode-17.0.2/issues/1022.jsx000066400000000000000000000002211372113677700157360ustar00rootroot00000000000000function hello() { return ( { this.inputFile = component; }} /> ); } web-mode-17.0.2/issues/1023.vue000066400000000000000000000000271372113677700157360ustar00rootroot00000000000000 web-mode-17.0.2/issues/1024.psp000066400000000000000000000010441372113677700157420ustar00rootroot00000000000000
    query("SELECT post.id, title, " . self::$query_vote . ", question, date, " . $this->vote_query . " FROM questions post WHERE ? in (" . self::$tags_query . " = post.id)", $tag); foreach ($questions as &$question) { $question['tags'] = $this->get_tags($question['id']); } return $questions; } ?>
    web-mode-17.0.2/issues/1027.jsx000066400000000000000000000002141372113677700157450ustar00rootroot00000000000000function hello() { return (
    {active ? (
    ) : ( )}
    ) } web-mode-17.0.2/issues/1029.blade.php000066400000000000000000000002111372113677700167750ustar00rootroot00000000000000@switch($i) @case(1) First case... @break @case(2) Second case... @break @default Default case... @endswitch web-mode-17.0.2/issues/1032.html000066400000000000000000000001001372113677700160730ustar00rootroot00000000000000
    web-mode-17.0.2/issues/1034.blade.php000066400000000000000000000001461372113677700170000ustar00rootroot00000000000000
    @row @col column 1 @endcol @col column 2 @endcol @endrow
    web-mode-17.0.2/issues/1037.html000066400000000000000000000010261372113677700161100ustar00rootroot00000000000000 web-mode-17.0.2/issues/1042.jsx000066400000000000000000000004221372113677700157430ustar00rootroot00000000000000class NS { render() { return (
    {loop.map(item => { return ( {item.name} ); })}
    ); } } web-mode-17.0.2/issues/1046.html000066400000000000000000000000421372113677700161050ustar00rootroot00000000000000
    web-mode-17.0.2/issues/1047.erb000066400000000000000000000002611372113677700157150ustar00rootroot00000000000000
    <%= render partial: 'some_partial', locals: { icon: nil, errors: [], title: 'Title' } %>
    web-mode-17.0.2/issues/1052.js000066400000000000000000000012401372113677700155530ustar00rootroot00000000000000import { html, render } from 'lit-html'; const myTemplate = (el) => html`

    My Web Component

    ` export class MyComponent extends HTMLElement { constructor() { super(); this.root = this.attachShadow({mode: 'open'}); this.color = "blue"; this.size = 12 this.titleSize = 1.2; this.render(); } render() { render(myTemplate(this), this.root) } } customElements.define('my-component', MyComponent) web-mode-17.0.2/issues/1053.html000066400000000000000000000004741372113677700161140ustar00rootroot00000000000000 web-mode-17.0.2/issues/1057-angular.component.html000066400000000000000000000047231372113677700215510ustar00rootroot00000000000000
    {{ 'general.general_info' | translate }} {{ 'general.edit' | translate }}
    {{ 'general.source' | translate }} {{ 'general.upload' | translate }} {{ 'general.email' | translate }} Scanner Zoomit Codabox Basware
    {{ 'general.upload_date' | translate }} {{ document.getDateUpload() }}
    {{ 'journal.journal' | translate }} {{ document.journal.name }}
    {{ 'modal.customer' | translate }} {{ document.invoice.third_name }}
    web-mode-17.0.2/issues/1072.js000066400000000000000000000003541372113677700155620ustar00rootroot00000000000000class Class { method() { // GOOD nodeSel .enter() .append('circle') const nodeSel = svg.selectAll('circle') // BAD nodeSel .enter() .append('circle') } } web-mode-17.0.2/issues/1073.html000066400000000000000000000001441372113677700161100ustar00rootroot00000000000000 1 web-mode-17.0.2/issues/1080.html000066400000000000000000000002551372113677700161110ustar00rootroot00000000000000 web-mode-17.0.2/issues/1085.mako000066400000000000000000000002071372113677700160760ustar00rootroot00000000000000
    <% dict = { 'value': { 'subvalue': 123 } } try: print('123') except: print('error') %>
    web-mode-17.0.2/issues/1086.html000066400000000000000000000003241372113677700161140ustar00rootroot00000000000000
    web-mode-17.0.2/issues/1089.psp000066400000000000000000000001711372113677700157550ustar00rootroot00000000000000 The number is // foo bar // baz {{ this should // still be treated as // a comment }} web-mode-17.0.2/issues/1092.ee000066400000000000000000000012251372113677700155370ustar00rootroot00000000000000{!-- This is a comment. --} {layout="site/_html-layout" title="News"} {!-- Note the nested braces here. --}
    {entry_date {my_date_formatting}}
    {!-- Iterate over a list of entries and do some tests. --} {exp:channel:entries channel="news"}

    {title}

    {if total_results == 1} {body} {layout:set name="title"}News | {title}{/layout:set} {if:ifelse x == 100}
    something else
    {if:else} {summary} {/if} {/exp:channel:entries} {!-- An expression that has its attributes wrapped. --}
      {exp:global:something attr="something" this="that" another="thing" }
    • {a_value}
    • {/exp:global:something}
    web-mode-17.0.2/issues/1093.html000066400000000000000000000000661372113677700161150ustar00rootroot00000000000000 web-mode-17.0.2/issues/1096.html000066400000000000000000000000751372113677700161200ustar00rootroot00000000000000 web-mode-17.0.2/issues/1097.jsx000066400000000000000000000011241372113677700157550ustar00rootroot00000000000000import React from 'react'; class App extends React.Component { render() { return
    }>
    ; } } web-mode-17.0.2/issues/1101.razor000066400000000000000000000001251372113677700162700ustar00rootroot00000000000000
    @{ var foo = 1; if (foo == 1) { foo = 2; } }
    web-mode-17.0.2/issues/1103.html000066400000000000000000000000411372113677700160760ustar00rootroot00000000000000
    web-mode-17.0.2/issues/1105.html000066400000000000000000000000721372113677700161040ustar00rootroot00000000000000 web-mode-17.0.2/issues/1108.vue.html000066400000000000000000000004241372113677700167060ustar00rootroot00000000000000 web-mode-17.0.2/issues/1109.blade.php000066400000000000000000000004561372113677700170070ustar00rootroot00000000000000 web-mode-17.0.2/issues/1116.blade.php000066400000000000000000000001411372113677700167740ustar00rootroot00000000000000 web-mode-17.0.2/issues/1119.djhtml000066400000000000000000000000331372113677700164240ustar00rootroot00000000000000
    {#% graph %#}
    web-mode-17.0.2/issues/1126.jsx000066400000000000000000000126671372113677700157640ustar00rootroot00000000000000import ListErrors from './ListErrors'; import React from 'react'; import agent from '../agent'; import { connect } from 'react-redux'; import { ADD_TAG, EDITOR_PAGE_LOADED, REMOVE_TAG, ARTICLE_SUBMITTED, EDITOR_PAGE_UNLOADED, UPDATE_FIELD_EDITOR } from '../constants/actionTypes'; const mapStateToProps = state => ({ ...state.editor }); const mapDispatchToProps = dispatch => ({ onAddTag: () => dispatch({ type: ADD_TAG }), onLoad: payload => dispatch({ type: EDITOR_PAGE_LOADED, payload }), onRemoveTag: tag => dispatch({ type: REMOVE_TAG, tag }), onSubmit: payload => dispatch({ type: ARTICLE_SUBMITTED, payload }), onUnload: payload => dispatch({ type: EDITOR_PAGE_UNLOADED }), onUpdateField: (key, value) => dispatch({ type: UPDATE_FIELD_EDITOR, key, value }) }); class Editor extends React.Component { constructor() { super(); const updateFieldEvent = key => ev => this.props.onUpdateField(key, ev.target.value); this.changeTitle = updateFieldEvent('title'); this.changeDescription = updateFieldEvent('description'); this.changeBody = updateFieldEvent('body'); this.changeTagInput = updateFieldEvent('tagInput'); this.watchForEnter = ev => { if (ev.keyCode === 13) { ev.preventDefault(); this.props.onAddTag(); } }; this.removeTagHandler = tag => () => { this.props.onRemoveTag(tag); }; this.submitForm = ev => { ev.preventDefault(); const article = { title: this.props.title, description: this.props.description, body: this.props.body, tagList: this.props.tagList }; const slug = { slug: this.props.articleSlug }; const promise = this.props.articleSlug ? agent.Articles.update(Object.assign(article, slug)) : agent.Articles.create(article); this.props.onSubmit(promise); }; } componentWillReceiveProps(nextProps) { if (this.props.match.params.slug !== nextProps.match.params.slug) { if (nextProps.match.params.slug) { this.props.onUnload(); return this.props.onLoad(agent.Articles.get(this.props.match.params.slug)); } this.props.onLoad(null); } } componentWillMount() { if (this.props.match.params.slug) { return this.props.onLoad(agent.Articles.get(this.props.match.params.slug)); } this.props.onLoad(null); } componentWillUnmount() { this.props.onUnload(); } render() { return (
    xsxs
    vfvdv
    { (this.props.tagList || []).map(tag => { return ( {tag} ); }) }
    ); } } export default connect(mapStateToProps, mapDispatchToProps)(Editor); web-mode-17.0.2/issues/1128.js000066400000000000000000000002261372113677700155620ustar00rootroot00000000000000const myStyle = css` font-size: ${x}px; max-width: 560px; margin: 0 auto; `; const myStyle = html`
    coucou
    `; web-mode-17.0.2/issues/1132.epl000066400000000000000000000003361372113677700157230ustar00rootroot00000000000000
    %= javascript begin $(function() { $('#select-year select').change(function() { $('#select-year').attr('action', '/' + this.value ); $('#select-year').submit(); }); }); % end
    web-mode-17.0.2/issues/1145.djhtml000066400000000000000000000006051372113677700164300ustar00rootroot00000000000000--- layout: default xsx cd ---
    {% include docs_contents_mobile.html %}

    {{ page.title }}

    {{ content }} {% include section_nav.html %}
    {% include docs_contents.html %}
    web-mode-17.0.2/issues/1147.jsx000066400000000000000000000004651372113677700157600ustar00rootroot00000000000000import * as React from 'react'; export default class Counter extends React.Component { render () { return (

    {this.state.count}

    ); } } web-mode-17.0.2/issues/1148.jsx000066400000000000000000000013401372113677700157520ustar00rootroot00000000000000import React from 'react'; import { observable } from 'mobx'; import _ from 'lodash'; const state = observable({ tasks: [], existsActiveTask: function() { const task = _(this.tasks).last(); if (!task) return false; return !!task.finishedAt; }, startTask: function(description) { if (_(tasks).last) tasks.push({description}); } }) function App() { return (

    Edit src/App.js and save to reload.

    Learn React
    ); } export default App; web-mode-17.0.2/issues/998.html000066400000000000000000000001001372113677700160370ustar00rootroot00000000000000 web-mode-17.0.2/issues/XXX.jsx000066400000000000000000000003771372113677700160550ustar00rootroot00000000000000class Confirm extends Component { render() { return ( ( )} /> ) } } web-mode-17.0.2/issues/test.component.html000066400000000000000000000004521372113677700205000ustar00rootroot00000000000000 {{ 'general.edit' | translate }}
    web-mode-17.0.2/issues/test.html000066400000000000000000000000421372113677700164720ustar00rootroot00000000000000toto toto coucou web-mode-17.0.2/issues/test.jsx000066400000000000000000000001301372113677700163300ustar00rootroot00000000000000 render() { return ( <> Sqome text.

    A heading

    ); } web-mode-17.0.2/issues/test.psp000066400000000000000000000001071372113677700163320ustar00rootroot00000000000000
    web-mode-17.0.2/issues/test.ts000066400000000000000000000002021372113677700161520ustar00rootroot00000000000000function greeter(person) { // return "Hello, " + person; } let user = "Jane User"; document.body.textContent = greeter(user); web-mode-17.0.2/run.sh000066400000000000000000000007371372113677700144650ustar00rootroot00000000000000#!/bin/bash if [ -x /Applications/Emacs.app/Contents/MacOS/Emacs ]; then EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs elif [ -x /Applications/Aquamacs.app/Contents/MacOS/Aquamacs ]; then EMACS=/Applications/Aquamacs.app/Contents/MacOS/Aquamacs else EMACS=emacs fi $EMACS -batch -no-site-file -Q --eval '(setq standard-indent 2)' --eval '(setq-default indent-tabs-mode nil)' --eval '(load-file "web-mode.el")' --eval '(web-mode)' -f web-mode-test 2> /dev/null web-mode-17.0.2/tests/000077500000000000000000000000001372113677700144605ustar00rootroot00000000000000web-mode-17.0.2/tests/test.blade.php000066400000000000000000000017251372113677700172230ustar00rootroot00000000000000
    @lang('consumption.this_month') Hello, {!! $name !!}. {{ isset($name) ? $name : 'Default' }} @{{ This will not be processed by Blade }} @component toto @endcomponent {{-- This comment will not be in the rendered HTML --}} @section('title', 'Page Title') @if (count($records) === 1) I have one record! @elseif (count($records) > 1) I have multiple records! @else I don't have any records! @endif @unless (Auth::check()) You are not signed in. @endunless Anothter example: @section('box-content')

    Item

    {!!Form::open( ['route' => ['menu.store'] , 'id' => 'form'])!!} @section('list.item.content')

    This is an item of type {{$item->type}}

    @overwrite
    @section('sidebar') This is themaster sidebar. @show
    @yield('content')
    @show
    @choice('foo', 2) web-mode-17.0.2/tests/test.chtml000066400000000000000000000005351372113677700164730ustar00rootroot00000000000000
    {{#foo attribute=bar otherAttribute=baz}} But for inline tags, ctemplates indents it like so: {{foo attribute=bar otherAttribute=baz}}
    {{#if foo}} {{#each bar}} foo {{else}} bar {{/each}} {{/if}}
    {{#if foo}} foo {{else}} bar {{/if}}
    web-mode-17.0.2/tests/test.css000066400000000000000000000033321372113677700161520ustar00rootroot00000000000000@media (min-with:900px) { div[name="btn"] { height:10px; /* comment */ } #aeetoto { width: 100%; background: #a37; } } div, #aeetoto { width: 100%; background-color: #ff4136; } body { width: 100px; } @font-face { font-family: 'Exo'; src: url('titi'), url('toto'); font-weight: 700; } .dialog INPUT[type=button]:hover, .btn { color:#0aa; width:100%; } div, #aeetoto { width: 100%; background-color: #ff4136; } @media (min-with:900px) { div[name="btn"] { height:10px; /* comment */ } #aeetoto { width: 100%; } } div:nth-of-type(5n):not(:nth-of-type(3n)):before { content: ""; } :root{ --main-bg-color: pink; } @font-face { font-family: "Bitstream Vera Serif Bold"; src: url("/static/styles/libs/font-awesome/fonts/fontawesome-webfont.fdf491ce5ff5.woff"); } @keyframes pulse { 0% { background-color: #001f3f; } 100% { background-color: #ff4136; } } @media only screen and (min-device-width: 320px) and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2) { .module { width: 100%; } } @page :first { margin: 1in; } @charset "UTF-8"; @import 'global.css'; /* Namespace for XHTML */ @namespace url(http://www.w3.org/1999/xhtml); /* Namespace for SVG embedded in XHTML */ @namespace svg url(http://www.w3.org/2000/svg); body { font-family: "Bitstream Vera Serif Bold", serif; } @media print { #ee2dd, #footer, aside { display:none; } body { font-size:120%; color:black; } } @media screen and (max-width: 640px) { .bloc { display:block; clear:both; } } /* On ajoute un paramètre de secours */ .component .header { color: var(--header-color, blue); } @viewport { zoom: 0.75; min-zoom: 0.5; max-zoom: 0.9; } web-mode-17.0.2/tests/test.css.erb000066400000000000000000000002661372113677700167240ustar00rootroot00000000000000 H1 { color:white; with:100px; } @media (min-with:900px) { div[name="btn"] { height:10px; /* comment */ } } H1 { color:white; <% if true %> height:300px; <% end %> } web-mode-17.0.2/tests/test.djhtml000066400000000000000000000025071372113677700166470ustar00rootroot00000000000000{% if something %} {% endif %} related issues: #293
    {% if something %} {% if something2 %}{% endif %} {{ }} {% endif %} {% if something %} {{ }} {% endif %} {% for book in books|dictsort:"author.age" %} * {{ book.title }} ({{ book.author.name }}) {% endfor %} {% widthratio this_value max_value max_width as width %} {% blocktrans %}The width is: {{ width }}{% endblocktrans %}
    {{ form_widget(form.address.city, {'attr': {'class': 'form-control form-control-md'}}) }}
    {% if something %} {% if something2 %}{% endif %}{{ }} {% endif %} {% block title %}{% endblock %} Indented

    the open control block above is inside an html attr

    related issues: #417 {{ athlete_list|length }} {% for_custom_tag %} Element should not be indented {% block_custom_tag %} Element should not be indented {% non_keyword_start %} Element should not be indented
    #466 {% if block %} Content {% endif %}
    {% trans "" %} Element should not be indented web-mode-17.0.2/tests/test.dtl000066400000000000000000000014521372113677700161460ustar00rootroot00000000000000 {% for o in some_list %} ...{{ value|center:"15" }} {% endfor %} {{ value|removetags:"b span"|safe }} {{ some_list|safeseq|join:", " }} {% for x, y in points %} There is a point at {{ x }},{{ y }} {% endfor %}
    • {% autoescape on %} This is escaped: {{ var1 }} {% autoescape off %} This is not escaped: {{ var1 }} This is escaped: {{ var1|escape }} {% endautoescape %} {% endautoescape %}
    • {% if 99 99 %} if: 99 and 99 are equal {% else %} else: 99 and 99 are not equal {% endif %}
    • {% ifequal 99 99 %} if: 99 and 99 are equal {% else %} else: 99 and 99 are not equal {% endifequal %}
    web-mode-17.0.2/tests/test.eex000066400000000000000000000004021372113677700161360ustar00rootroot00000000000000<%= if 1 + 1 == 2 do %> Truth <% else %> What? <% end %> <%= for i <- 1..10 do %> <%= i %> <% end %> <%= content_tag :a, href: "https://example.com" do %> Hello! <% end %> <%= form_for @changeset, @action, fn _form -> %> Hello again! <%= end %> web-mode-17.0.2/tests/test.ejs000066400000000000000000000035461372113677700161520ustar00rootroot00000000000000 <% var title = page.title; if (is_archive()){ title = 'Archives'; if (is_month()){ title += ': ' + page.year + '/' + page.month; } else if (is_year()) { title += ': ' + page.year; } } else if (is_category()){ title = 'Category: ' + page.category; } else if (is_tag()){ title = 'Tag: ' + page.tag; } %> <% if (title){ %><%= title %> | <% } %><%= config.title %> <%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %> <% if (theme.rss){ %> <% } %> <% if (theme.favicon){ %> <% } %> <%- css('css/style') %> <%- body %> web-mode-17.0.2/tests/test.epl000066400000000000000000000003331372113677700161400ustar00rootroot00000000000000
    % my $block = begin % my $name = shift; Hello <%= $name %>. % end
    % if ($a) {

    If

    % } else {

    Else

    % }
    <% if ($a) { $b = $a; } else { $b = ""; } %>web-mode-17.0.2/tests/test.erb000066400000000000000000000037371372113677700161430ustar00rootroot00000000000000<% unless @starred_stories.empty? %> <% if @starred_stories.total_pages > 1 %> <%= render_js :stories, { stories: @starred_stories } %> <% end %> <% end %>
    <%= mail_to("", "Email to a friend", :subject => @listing.display_title, body: "I found this listing online, and thought you might be interested:\n#{@listing.url}", :class => 'mail') %>
    <%= render partial: 'some_partial', locals: { icon: nil, errors: [], title: 'Title' } %>
    <% a = [ [1, 2], [3, 4] ] b = 10 %>
    <% flash.each do |key, value| -%>
    <%=h value %>
    <% end %>
    <% if request.xhr? %> <% end %>
    <% if foo puts "foo" puts "foo" puts "foo" puts "foo" end $age = 5 case $age when 0 .. 2 puts "baby" when 3 .. 6 puts "little child" when 7 .. 12 puts "child" when 13 .. 18 puts "youth" else puts "adult" end class Greeter def initialize(name = "World") @name = name end def say_hi puts "Hi #{@name}!" end def say_bye puts "Bye #{@name}, come back soon." end end x=1 if x > 2 puts "x is greater than 2" elsif x <= 2 and x!=0 puts "x is 1" else puts "I can't guess the number" end %> <% if request.xhr? %>
    <% end %>
    <% if request.xhr? %> <% else %>

    <% end %>
    <% @hash.each do |t, a| %>

    <%= t %>

    <% a.each do |q| %> <%= link_to(q.question_answers_url) %>
    <% end %> <% end %>
      <% for @item in @shopping_list %>
    • <%= @item %>
    • <% end %>
    web-mode-17.0.2/tests/test.ftl000066400000000000000000000010311372113677700161410ustar00rootroot00000000000000 Welcome! <#-- Greet the user with his/her name -->

    Welcome ${user}!

    We have these animals:
      <#list animals as animal>
    • ${animal.name} for ${animal.price} Euros
    [#include "/WEB-INF/common/header.ftl"] [#assign testVar=false] [#if object?has_content] Has content [#else] No content [/#if] web-mode-17.0.2/tests/test.gohtml000066400000000000000000000020701372113677700166520ustar00rootroot00000000000000
    {{range .}} {{/* a comment */}} {{with .Author}}

    {{.}} wrote:

    {{else}}

    An anonymous person wrote:

    {{end}}
    {{.Content}}
    {{$piOver2}} {{define "myPage"}} {{template "head" .}} {{end}}
    Name: {{.Text.Name | html}}{{index .Keys 3}}
    {{$checkinUsers := .CheckinUsers}} {{range $i, $v := .Checkins}} {{$user := index $checkinUsers $i}}
    • {{"put" | printf "%s%s" "out" | printf "%q"}} {{$user.FirstName}} {{"\"output\""}}
    {{end}} {{end}} {{range $foo := .Bar}} 123 {{end}} {{if .Bar}} true {{end}} {{rangeFn}} {{if .Bar}} true {{endTheWorld}} {{end}} {{ if .Bar }} true {{ end}}
    web-mode-17.0.2/tests/test.hero000066400000000000000000000014521372113677700163200ustar00rootroot00000000000000<%! import ( "fmt" "strings" ) var a int const b = "hello, world" func Add(a, b int) int { return a + b } type S struct { Name string } %>
    <%: func define %> <%~ "parent template" %> <%+ "sub template" %> <%! go code %>
    <%@ body { %> hello here <% } %>
    <%== "hello" %> <%==i 34 %> <%==u Add(a, b) %> <%==s user.Name %>
    <% for _, user := userList { %> <% if user != "Alice" { %> <%= user %> <% } %> <% } %>
    <% a, b := 1, 2 c := Add(a, b) %>
    <%# note %>
    web-mode-17.0.2/tests/test.html000066400000000000000000000021261372113677700163260ustar00rootroot00000000000000
    • hello
    • world

    extract / contract
    Related issues: #603

    Zero

    One

    Two

    Three

    Four

    related issues: #290

    lorem

    hello

    bonjour
    monde
    web-mode-17.0.2/tests/test.js000066400000000000000000000112171372113677700157770ustar00rootroot00000000000000 for ( var someLongVariable = 0; someLongVariable < someExtremely.long.prop; someLongVariable++ ) { doSomething(); } $("input").keypress(function() { var x = 2; }); let a; if (true) { a = 1; } else a = 2; if (1 === 1) { x = 1; } else { x = 2; } while (x) { if (true) a() b() c() } let newList = list.skipWhile(f) a() b() function Switch() { return whatever; } type T = {| x: number, titi: y |}; Relay.createContainer(Story, { initialVariables: { numCommentsToShow: 10, showComments: false, }, fragments: { story: (variables) => Relay.QL` fragment on Story { comments(first: $numCommentsToShow) @include(if: $showComments) { edges { node { author { name }, id, text, }, }, }, } `, } }); var cs = {completed: this.props.todo.completed, editing: this.props.editing}; const f = (x) => x + 1; const tptp = bar > baz ? value1 : value2; if (a) if (b) if (c) console.log("ici"); console.log("la"); var data = { password: this.password } if (true) { var Button = styled.button` border-radius: 3px; padding: 0.25em 1em; margin: 0 1em; background: transparent; color: palevioletred; border: 2px solid palevioletred; `; } VEOrganizer.prototype.unpatchVeToolbar = function() { ve.ui.Toolbar.prototype.getElementWindow = this.veUiToolbarPrototypeGetElementWindow; ve.ui.Toolbar.prototype.calculateOffset = this.veUiToolbarPrototypeCalculateOffset; }; if(!rstart.isCollapsed() || !this.ve.document.hasSlugAtOffset(rstart.to)) { groups = this.ve.document.getCoveredSiblingGroups(rstart); }; if(!this.begin(ed.isNew() ? "savenewmodule" : "savemodule", ed.getSaveData(this.state.segmentId, values))) { return false; } windowOffset.right = ( $(window).width() - this.$window.outerWidth() - windowOffset.left ); if(!rstart.isCollapsed() || this.ve.document.data.isContentOffset(rstart.to) || !this.ve.document.hasSlugAtOffset(rstart.to)) { groups = this.ve.document.getCoveredSiblingGroups(rstart); } var json = { msg: 'hello', attr: condition ? "This message" : "Some other message" } for (let type in types) doSomething(type); for (let type of types) doSomething(type); // should be indented ajax.post('/signup') .send(data); $(document.body) .append("") .attr(...); $('
    Open
    ') .attr("data-id", "foo"); $(document.body).append("") .attr(...); var str = "toto"; 'test/1'.match(/[a-z]+[0-9]+/g); 'test/1'.match(/[a-z]+\/[0-9]+/ug); return { nowShowing: Const.ALL_TODOS, editing: null }; class Person { @memoize get name() { return `${this.first} ici ${this.last}` } set name(val) { let [first, last] = val.split(' '); this.first = first; this.last = last; } } if (true) { var x; /* * Hello there. * Today is Saturday. */ var z; /* lorem ipsum */ var y; } var x = y, cd = 3; if (true) { var x = y, cd = 3; export const {x, y} = z, a = 10; } var pathData = this.barData .map(function(d) { return [{x: d.start_time_ms, vol: d.volume}, {x: d.end_time_ms, vol: d.volume}]; }) .reduce(function(a, b) { return a.concat(b); }); function toto(c) { switch(elem) { case "textarea" : return ( 1 ); break; case "text" : return ( 2 ); default : return 0; } } function hello() { if (x) console.log("lorem"); else console.log("ipsum"); } var obj = { "a": 1, "b": 2, "c": 3 }; var arr = [1, 2, 3 ]; function onYouTubePlayerAPIReady(videoid) { ytPlayer = new YT.Player('media_area', {videoId: videoid, playerVars: { 'rel': 0 } }); ytPlayer = new YT.Player('media_area', { videoId: videoid, playerVars: { 'rel': 0 } }); } var newB = new example(); newB.firstMethod('x') .secondMethod('y') .thirdMethod(1,15,'z'); var bar = 1; var foo = (bar == 1) ? "ONE" : "OTHER"; // THIS IS THE PROBLEM foo() { bar() baz() if(true) hello(); if (true) hello(); } function fieldIsValid(field, fieldSpec) { // todo: add remote possibility var value = field.value; if ( value.length < fieldSpec.minNumberOfChar || value.length > fieldSpec.maxNumberOfChar || value.match( fieldSpec.pattern) ) return true; return false; } web-mode-17.0.2/tests/test.js.erb000066400000000000000000000002551372113677700165460ustar00rootroot00000000000000function hello() { <% if true %> // @This is javascript code alert('aa'); $('#click').on('click', function() { console.log('this is works'); }); <% end %> } web-mode-17.0.2/tests/test.jsp000066400000000000000000000064461372113677700161670ustar00rootroot00000000000000 <%! public int sum(int a, int b) { return a + b; } private void doNothing(HttpServletResponse response) {} %> <% doNothing(response); %>

    <% if (x) { %> <%= x %> <% } else { %> <%= x %> <% } %>
    ${person.name}${person.age} ${ageTotal} <%@ taglib prefix="f" uri="/your-tld-uri"%> ... <%@ taglib uri="/you-taglib-uri" prefix="p" %> and use the tag: ${person.name}${person.age} <%= toto %>

    test

    <% if ( haveError ) { request.setAttribute( "error xss", //todo : erreur d'indentation errors.toString()); pageContext.forward( "GetName.jsp" ); } else { pageContext.forward( "GetName.jsp" ); pageContext.forward( "NextPage.jspx" ); } %>
    <%@ page import="business.*, data.*" /*comment*/ test="*indent attr*" %>
    cdc
    <% // This is a scriptlet. Notice that the "date" // variable we declare here is available in the // embedded expression later on. int i = 0 System.out.println( "Evaluating date now" ); java.util.Date date = new java.util.Date(); %> <%! // declare here public void add(User user, String filename) throws IOException, ServletException { PrintWriter out = new PrintWriter(new FileWriter(filename, true)); out.println("toto" + "titi" + "titi" + user.getLastName()); out.close(); } %> <%-- cdcd --%> web-mode-17.0.2/tests/test.jsx000066400000000000000000000214641372113677700161740ustar00rootroot00000000000000var s = "xs"; React.createClass({ render() { return (
      cqsd { if (true) { hello } }
    ); } }); function hello() { return (
    {active ? (
    ) : ( )}
    ) } function hello() { return ( { this.inputFile = component; }} /> ); } export default function Example() { return ( ← cursor here ); } render() { return ( <> Some text.

    A heading

    More text.

    Another heading

    Even more text. ); } return ( } /> ); return (
  • }> Invite Representative
  • ); return (
    xs
    ; ); const Demo = () => ( } > ); import React, {Component} from 'react'; class Confirm extends Component { render() { const project = this.props.project; return ( ( )} /> ) }, render() { const project = this.props.project; return ( text } /> ) } } import React, {Component} from 'react'; class Confirm extends Component { render() { const project = this.props.project; return ( ( ) } /> ) } }; class Test extends Component { render() { return ( ( )} /> ( )} /> ) } }; import React from 'react'; const Front = props => { return
    hello
    ; }; /** @jsx React.DOM **/ var React = require('react/addons'); var Component = require('./component'); function f() { return true && || ; } export default class Header extends Component { render() { return (
    {this.getChildren()}
    ); } } import * as React from 'react'; interface Props { name: string } class MyThing extends React.Component { render() { return hi; } } export default MyThing as React.ComponentClass; export default React.createClass({ getInitialState() { return { num: this.getRandomNumber() }; }, getRandomNumber(): number { return Math.ceil(Math.random() * 6); }, render(): any { return
    Your dice roll : {this.state.num}
    ; } }); function foo() { return ; } import React, {Component} from 'react'; class Confirm extends Component { render() { const project = this.props.project; return ( ( )} /> ) } } // #870 import React, {Component} from 'react'; class Confirm extends Component { render() { const project = this.props.project; return (
    {project.foo && (
    Foo
    )} {project.bar && (

    Bar

    )}
    ); } } export default Confirm; var React = require('react') return React.render(
    { conditional && }
    Hello
    ); 'use strict'; var React = require('react'), Explore = require('./components/Explore'), DocumentTitle = require('react-document-title'), { RouteHandler } = require('react-router'), { PropTypes } = React; var App = React.createClass({ propTypes: { params: PropTypes.object.isRequired, query: PropTypes.object.isRequired }, render() { return (

    ); } }); module.exports = App; module.exports = React.createClass({ render() { return (
    } footer={} attr="cqs" xs="xs" xsxs="sxx" />
    ); } }); module.exports = React.createClass({ render() { return ( bla { { } } bla ); } }); module.exports = React.createClass({ render() { return (
      { this.props.list.map(function(element) { return
    • {element}
    • ; }) }
    ); } }); Landing = React.createClass({ render: function() { return (
      { for(e in list){ console.log("not aligned"); }}
    ); } }); var Component = React.createClass({ render : function() { var stuff = this.props.formElements.map(function(elem) { switch(elem) { case "textarea" : return ( ") ("2/" . "

    |

    ") ("3/" . "

    |

    ") ("?/" . ""))) (defvar web-mode-engines-auto-pairs '(("angular" . (("{{ " . " }}"))) ("artanis" . (("<% " . " %>") ("<%=" . " | %>") ("<@css" . " | %>") ("<@icon" . " | %>") ("<@include" . " | %>") ("<@js" . " | %>"))) ("asp" . (("<% " . " %>"))) ("aspx" . (("<% " . " %>") ("<%=" . "%>") ("<%#" . "%>") ("<%$" . "%>") ("<%@" . "%>") ("<%:" . "%>") ("<%-" . "- | --%>"))) ("blade" . (("{{{" . " | }}}") ("{{ " . " }}") ("{!!" . " | !!}") ("@{{" . " | }}") ("{{-" . "- | --}}"))) ("cl-emb" . (("<% " . " %>") ("<%=" . " | %>") ("<%#" . " | %>"))) ("ctemplate" . (("{{ " . "| }}") ("{{{" . " | }}}") ("{~{" . " | }}") ("{{~" . "{ | }}}") ("{{!" . "-- | --}}") ("{{^" . "}}") ("{{/" . "}}") ("{{#" . "}}"))) ("django" . (("{{ " . " }}") ("{% " . " %}") ("{%-" . " | %}") ("{# " . " #}"))) ("elixir" . (("<% " . " %>") ("<%=" . " | %>") ("<%%" . " | %>") ("<%#" . " | %>"))) ("ejs" . (("<% " . " %>") ("<%=" . "%>") ("<%#" . "%>") ("<%-" . "%>"))) ("erb" . (("<% " . " %>") ("<%=" . " %>") ("<%#" . "%>") ("<%-" . " %>"))) ("freemarker" . (("<% " . " %>") ("<#-" . "- | -->") ("${ " . " }") ("[% " . " %]") ("[# " . " #]") ("[#-" . "- | --]"))) ("go" . (("{{ " . " }}") ("{{-" . " | -}}"))) ("hero" . (("<% " . " %>") ("<%=" . " | %>") ("<%!" . " | %>") ("<%:" . " | %>") ("<%#" . " | %>") ("<%@" . " | %>") ("<%~" . " | %>") ("<%+" . " | %>"))) ("jsp" . (("<% " . " %>") ("<%-" . "- | --%>") ("<%=" . "%>") ("<%!" . "%>") ("<%@" . "%>") ("${ " . " }"))) ("lsp" . (("<% " . " %>") ("<%%" . " | %>") ("<%#" . " | %>"))) ("mako" . (("<% " . " %>") ("<%!" . " | %>") ("${ " . " }"))) ("marko" . (("${ " . " }"))) ("mason" . (("<% " . " %>") ("<& " . " &>"))) ("mojolicious" . (("<% " . " %>") ("<%=" . " | %>") ("<%%" . " | %>") ("<%#" . " | %>"))) ("php" . (("") ("") (""))) ("template-toolkit" . (("[% " . " %]") ("[%-" . " | %]") ("[%#" . " | %]"))) ("riot" . (("={ " . " }"))) ("underscore" . (("<% " . " %>"))) ("vue" . (("{{ " . " }}"))) ("web2py" . (("{{ " . " }}") ("{{=" . "}}"))) (nil . ((""))) )) (defvar web-mode-engines-snippets '(("artanis" . (("if" . "<% (if (|) %>\n\n<% ) %>") ("when" . "<% (when (|) %>\n\n<% ) %>") ("unless" . "<% (unless (|) %>\n\n<% ) %>") ("cond" . "<% (cond %>\n<% [(|) %>\n\n<% ] %>\n<% [else %>\n\n<% ] %>\n<% ) %>") ("let" . "<% (let ([|]) %>\n\n<% ) %>") ("let*" . "<% (let* ([|]) %>\n\n<% ) %>") ("do" . "<% (do ([|]) %>\n<% [()] %>\n\n<% ) %>") ("for-each" . "<% (for-each %>\n|\n\n<% ) %>") ("case" . "<% (case | %>\n<% [() %>\n\n<% ] %>\n<% [() %>\n\n<% ] %>\n<% ) %>"))) ("ejs" . (("for" . "<% for (|) { %>\n\n<% } %>") ("if" . "<% if (|) { %>\n\n<% } %>"))) ("erb" . (("each" . "<% |.each do %>\n\n<% end %>") ("if" . "<% if | %>\n\n<% end %>") ("when" . "<% when | %>\n\n<% end %>") ("unless" . "<% unless | %>\n\n<% end %>"))) ("php" . (("if" . "\n\n") ("while" . "\n\n") ("for" . "\n\n") ("foreach" . "\n\n") ("each" . "\n\n") ("switch" . "\n\n\n\n\n\n\n"))) ("django" . (("block" . "{% block | %}\n\n{% endblock %}") ("comment" . "{% comment | %}\n\n{% endcomment %}") ("css" . "{% stylesheet %}\n\n{% endstylesheet %}") ("cycle" . "{% cycle | as %}\n\n{% endcycle %}") ("filter" . "{% filter | %}\n\n{% endfilter %}") ("for" . "{% for | in %}\n\n{% endfor %}") ("if" . "{% if | %}\n\n{% endif %}") ("ifequal" . "{% ifequal | %}\n\n{% endifequal %}") ("ifnotequal" . "{% ifnotequal | %}\n\n{% endifnotequal %}") ("js" . "{% javascript | %}\n\n{% endjavascript %}") ("schema" . "{% javascript | %}\n\n{% endschema %}") ("safe" . "{% safe | %}\n\n{% endsafe %}"))) ("mako" . (("if" . "% if |:\n% endif") ("for" . "% for | in :\n% endfor") ("doc" . "<%doc>\n|\n") ("inherit" . "<%inherit file=\"|\" />") ("namespace" . "<%namespace name=\"|\" file=\"\" import=\"\"/>") ("block" . "<%block name=\"|\">\n"))) ("template-toolkit" . (("if" . "[% IF | %]\n\n[% END %]"))) (nil . (("html5" . "\n\n\n\n\n\n\n|\n\n") ("table" . "\n\n\n\n\n
    |
    ") ("ul" . "
      \n
    • |
    • \n
    • \n
    "))) )) (defvar web-mode-engine-token-regexps (list '("artanis" . "\"\\|#|\\|;") '("asp" . "//\\|/\\*\\|\"\\|'") '("ejs" . "//\\|/\\*\\|\"\\|'") '("erb" . "\"\\|'\\|#\\|<<[-]?['\"]?\\([[:alnum:]_]+\\)['\"]?") '("lsp" . "\"\\|#|\\|;") '("mako" . "\"\\|'\\|#") '("mason" . "\"\\|'\\|#") '("mojolicious" . "\"\\|'") '("php" . "//\\|/\\*\\|#\\|\"\\|'\\|<<<['\"]?\\([[:alnum:]]+\\)['\"]?") '("python" . "\"\\|'\\|#") '("web2py" . "\"\\|'")) "Engine regexps used to identify tokens (strings / comments) in blocks.") (defvar web-mode-engine-open-delimiter-regexps (list '("angular" . "{{") '("artanis" . "<%\\|<@\\(css\\|icon\\|include\\|js\\)") '("asp" . "<%\\|" nil 4) ("\\.svg$" "" nil 0) ("\\.js$" "" t 0) ("\\.css$" "" t 0) ("\\.html?$" "" nil 4)) "List of elements and extensions for `web-mode-file-link'. It consists of a string that contains the regular expression that matches the appropriate files, a format string with element that contains the link (%s should be put where the path goes,) a bool that tells if the element belongs in the element, and number of characters to move back if needed (or 0 if point shouldn't be moved back.)") (defvar web-mode-sql-queries (regexp-opt '("SELECT" "INSERT" "UPDATE" "DELETE" "select" "insert" "update" "delete"))) (defvar web-mode-sql-keywords (regexp-opt (append (cdr (assoc "sql" web-mode-extra-keywords)) '("SELECT" "INSERT" "UPDATE" "DELETE" "FROM" "WHERE" "GROUP BY" "LIKE" "LIMIT" "HAVING" "JOIN" "LEFT" "INNER" "FULL" "OUTER" "VALUES" "ORDER BY" "SEPARATOR" "ASC" "DESC" "AND" "OR" "ON" "WHEN" "ELSE" "END" "THEN")))) (defvar web-mode-python-constants (regexp-opt (append (cdr (assoc "python" web-mode-extra-constants)) '("True" "False" "None" "__debug__" "NotImplemented" "Ellipsis")))) (defvar web-mode-elixir-keywords (regexp-opt (append (cdr (assoc "elixir" web-mode-extra-keywords)) '("do" "end" "case" "bc" "lc" "for" "if" "cond" "with" "unless" "try" "receive" "fn" "defmodule" "defprotocol" "defimpl" "defrecord" "defrecordp" "defstruct" "defdelegate" "defcallback" "defexception" "defoverridable" "defguard" "defgaurdp" "exit" "after" "rescue" "catch" "else" "raise" "throw" "quote" "unquote" "super" "when" "and" "or" "not" "in")))) (defvar web-mode-elixir-constants (regexp-opt (append (cdr (assoc "elixir" web-mode-extra-constants)) '("nil" "true" "false")))) (defvar web-mode-erlang-constants (regexp-opt (append (cdr (assoc "erlang" web-mode-extra-constants)) '("true" "false")))) (defvar web-mode-erlang-keywords (regexp-opt (append (cdr (assoc "erlang" web-mode-extra-keywords)) '("else" "if" "do" "end")))) (defvar web-mode-cl-emb-constants (regexp-opt '("nil" "t" "raw" "escape"))) (defvar web-mode-cl-emb-keywords (regexp-opt '("if" "else" "endif" "unless" "endunless" "var" "repeat" "endrepeat" "loop" "endloop" "include" "call" "with" "endwith" "set" "genloop" "endgenloop" "insert"))) (defvar web-mode-artanis-constants (regexp-opt '("#f" "#t"))) (defvar web-mode-artanis-keywords (regexp-opt (append (cdr (assoc "artanis" web-mode-extra-keywords)) '("begin" "cut" "cute" "if" "when" "unless" "cond" "case" "do" "quote" "syntax" "lambda" "lambda*" "and" "and-let*" "or" "else" "delay" "receive" "use-modules" "match" "match-lambda" "match-lambda*" "match-let" "match-let*" "match-letrec" "let" "let*" "letrec" "letrec*" "and-let*" "let-syntax" "letrec-syntax" "syntax-rules" "syntax-case" "define" "define-syntax" "define-macro" "define-condition-type" "define-immutable-record-type" "define-record-type" "define-values" "parameterize" "for-each" "require-extension" "set!" "test-approximate" "test-assert" "test-begin" "test-end" "test-eq" "test-equal" "test-eqv" "test-error" "test-group" "test-group-with-cleanup" "test-with-runner")))) (defvar web-mode-lsp-constants (regexp-opt '("nil" "t"))) (defvar web-mode-lsp-keywords (regexp-opt '("dolist" "let" "while" "cond" "when" "progn" "if" "dotimes" "unless" "lambda" "loop" "for" "and" "or" "in" "do" "defun"))) (defvar web-mode-php-constants (regexp-opt (append (cdr (assoc "php" web-mode-extra-constants)) '("TRUE" "FALSE" "NULL" "true" "false" "null" "STR_PAD_LEFT" "STR_PAD_RIGHT" "ENT_COMPAT" "ENT_QUOTES" "ENT_NOQUOTES" "ENT_IGNORE" "ENT_SUBSTITUTE" "ENT_DISALLOWED" "ENT_HTML401" "ENT_XML1" "ENT_XHTML" "ENT_HTML5" "JSON_PRETTY_PRINT" "LIBXML_NOBLANKS")))) (defvar web-mode-php-keywords (regexp-opt (append (cdr (assoc "php" web-mode-extra-keywords)) '("abstract" "and" "array" "as" "break" "case" "catch" "class" "clone" "const" "continue" "declare" "default" "die" "do" "echo" "else" "elseif" "empty" "enddeclare" "endfor" "endforeach" "endif" "endswitch" "endwhile" "eval" "exit" "extends" "final" "finally" "fn" "for" "foreach" "function" "global" "goto" "if" "implements" "include" "include_once" "instanceof" "insteadof" "interface" "isset" "list" "namespace" "new" "or" "parent" "print" "private" "protected" "public" "require" "require_once" "return" "self" "static" "switch" "trait" "try" "throw" "unset" "use" "var" "while" "xor" "yield" "yield from")))) (defvar web-mode-php-types (eval-when-compile (regexp-opt '("array" "bool" "boolean" "callable" "float" "int" "integer" "iterable" "mixed" "object" "resource" "string" "void")))) (defvar web-mode-css-at-rules (eval-when-compile (regexp-opt '("charset" "import" "media" "page" "font-face" "namespace" "supports" "document" "keyframes" "-moz-keyframes" "-webkit-keyframes" "mixin" "viewport")))) (defvar web-mode-css-pseudo-classes (eval-when-compile (regexp-opt '("active" "after" "before" "checked" "disabled" "empty" "enabled" "first" "first-child" "first-letter" "first-line" "first-of-type" "focus" "hover" "lang" "last-child" "last-of-type" "left" "link" "not" "nth-child" "nth-last-child" "nth-last-of-type" "nth-of-type" "only-child" "only-of-type" "right" "root" "selection" "target" "visited")))) (defvar web-mode-python-keywords (regexp-opt (append (cdr (assoc "python" web-mode-extra-keywords)) '("and" "as" "assert" "break" "class" "continue" "def" "del" "elif" "else" "except" "finally" "for" "from" "global" "if" "import" "in" "is" "lambda" "nonlocal" "not" "or" "pass" "raise" "return" "try" "while" "with" "yield")))) (defvar web-mode-jsp-keywords (regexp-opt (append (cdr (assoc "jsp" web-mode-extra-keywords)) '("case" "catch" "do" "else" "end" "false" "for" "function" "if" "in" "include" "new" "package" "page" "private" "protected" "public" "return" "tag" "taglib" "throw" "throws" "true" "try" "void" "while")))) (defvar web-mode-erb-keywords (regexp-opt (append (cdr (assoc "erb" web-mode-extra-keywords)) '("alias" "and" "begin" "break" "case" "class" "def" "defined?" "do" "elsif" "else" "end" "ensure" "fail" "for" "if" "in" "module" "next" "not" "or" "redo" "rescue" "retry" "return" "then" "super" "unless" "undef" "until" "when" "while" "yield" "__ENCODING__" "__FILE__" "__LINE__")))) (defvar web-mode-mason-keywords (regexp-opt (append (cdr (assoc "mason" web-mode-extra-keywords)) '("and" "base" "close" "die" "each" "else" "elsif" "eval" "exists" "foreach" "grep" "if" "length" "local" "my" "next" "open" "or" "package" "pop" "ref" "return" "stat" "sub" "tie" "undef" "unless" "use" "while")))) (defvar web-mode-erb-builtins (regexp-opt (append (cdr (assoc "erb" web-mode-extra-builtins)) '("__callee__" "__dir__" "__method__" "abort" "at_exit" "autoload" "autoload?" "binding" "block_given?" "caller" "catch" "eval" "exec" "exit" "exit!" "fail" "fork" "format" "lambda" "load" "loop" "open" "p" "print" "printf" "proc" "putc" "puts" "raise" "rand" "readline" "readlines" "require" "require_relative" "sleep" "spawn" "sprintf" "srand" "syscall" "system" "throw" "trap" "warn" "alias_method" "attr" "attr_accessor" "attr_reader" "attr_writer" "define_method" "extend" "include" "module_function" "prepend" "private" "protected" "public" "refine" "using" "error_message_on" "error_messages_for" "form" "input" "auto_discovery_link_tag" "image_tag" "javascript_include_tag" "stylesheet_link_tag" "image_path" "path_to_image"" " "javascript_path" "path_to_javascript" "register_javascript_expansion" "register_javascript_include_default" "register_stylesheet_expansion" "stylesheet_path" "path_to_stylesheet" "atom_feed" "entry" "updated" "benchmark" "cache" "capture" "content_for" "distance_of_time_in_words" "distance_of_time_in_words_to_now" "time_ago_in_words" "date_select" "datetime_select" "time_select" "select_date" "select_datetime" "select_day" "select_hour" "select_minute" "select_month" "select_second" "select_time" "select_year" "debug" "check_box" "fields_for" "file_field" "form_for" "hidden_field" "label" "password_field" "radio_button" "text_area" "text_field" "check_box_tag" "field_set_tag" "file_field_tag" "form_tag" "hidden_field_tag" "image_submit_tag" "label_tag" "password_field_tag" "radio_button_tag" "select_tag" "submit_tag" "text_area_tag" "text_field_tag" "collection_select" "country_options_for_select" "country_select" "option_groups_from_collection_for_select" "options_for_select" "options_from_collection_for_select" "select" "time_zone_options_for_select" "time_zone_select" "button_to_function" "define_javascript_functions" "escape_javascript" "javascript_tag" "link_to_function"" " "number_to_currency" "number_to_human_size" "number_to_percentage" "number_to_phone" "number_with_delimiter" "number_with_precision" "evaluate_remote_response" "form_remote_for" "form_remote_tag" "link_to_remote" "observe_field" "observe_field" "periodically_call_remote" "remote_form_for" "remote_function" "submit_to_remote" "update_page" "update_page_tag" "dom_class" "dom_id" "partial_path" "sanitize" "sanitize_css" "strip_links" "strip_tags" "cdata_section" "content_tag" "escape_once" "tag" "auto_link" "concat" "cycle" "excerpt" "highlight" "markdown" "pluralize" "reset_cycle" "simple_format" "textilize" "textilize_without_paragraph" "truncate" "word_wrap" "button_to" "current_page?" "link_to" "link_to_if" "link_to_unless" "link_to_unless_current" "mail_to" "url_for" "action_name" "atom_feed" "audio_path" "audio_tag" "content_tag_for" "controller" "controller_name" "action_name" "controller_path" "convert_to_model" "cookies" "csrf_meta_tag" "csrf_meta_tags" "headers" "current_cycle" "div_for" "email_field" "email_field_tag" "favicon_link_tag" "flash" "l" "button_tag" "grouped_collection_select" "grouped_options_for_select" "image_alt" "j" "javascript_cdata_section" "localize" "logger" "number_field" "number_field_tag" "number_to_human" "params" "path_to_audio" "path_to_video" "phone_field" "phone_field_tag" "provide" "range_field" "range_field_tag" "raw" "render" "request" "request_forgery_protection_token" "response" "safe_concat" "safe_join" "search_field" "search_field_tag" "session" "t" "telephone_field" "telephone_field_tag" "time_tag" "translate" "url_field" "url_field_tag" "url_options" "video_path" "video_tag" "simple_form_for" "javascript_pack_tag" "stylesheet_pack_tag" "csp_meta_tag" )))) (defvar web-mode-asp-constants (regexp-opt (append (cdr (assoc "asp" web-mode-extra-constants)) '("adAsyncExecute" "adAsyncFetch" "adAsyncFetchNonBlocking" "adCmdFile" "adCmdStoredProc" "adCmdTable" "adCmdTableDirect" "adCmdText" "adCmdUnknown" "adCmdUnspecified" "adExecuteNoRecords" "adExecuteRecord" "adExecuteStream" "adLockBatchOptimistic" "adLockOptimistic" "adLockPessimistic" "adLockReadOnly" "adLockUnspecified" "adOpenDynamic" "adOpenForwardOnly" "adOpenKeyset" "adOpenStatic" "adOpenUnspecified" "adOptionUnspecified" "Empty" "Nothing" "Null" "True" "False" "vbBack" "vbCr" "vbCrLf" "vbFormFeed" "vbLf" "vbNewLine" "vbNullChar" "vbNullString" "vbObjectError" "vbScript" "vbTab" "vbVerticalTab")))) (defvar web-mode-asp-keywords (regexp-opt (append (cdr (assoc "asp" web-mode-extra-keywords)) '("Abs" "And" "Array" "Asc" "Atn" "CBool" "CByte" "CCur" "CDate" "CDbl" "CInt" "CLng" "CSng" "CStr" "Call" "Case" "Chr" "Class" "Const" "Cos" "CreateObject" "Date" "DateAdd" "DateDiff" "DatePart" "DateSerial" "DateValue" "Day" "Dim" "Do" "Each" "Else" "ElseIf" "End" "Erase" "Err" "Eval" "Exit" "Exp" "Explicit" "Filter" "Fix" "For" "FormatCurrency" "FormatDateTime" "FormatNumber" "FormatPercent" "Function" "GetLocale" "GetObject" "GetRef" "Hex" "Hour" "If" "In" "InStr" "InStrRev" "InputBox" "Int" "IsArray" "IsDate" "IsEmpty" "IsNull" "IsNumeric" "IsObject" "Join" "LBound" "LCase" "LTrim" "Language" "Left" "Len" "Let" "LoadPicture" "Log" "Loop" "Mid" "Minute" "Month" "MonthName" "MsgBox" "New" "Next" "Not" "Now" "Oct" "On" "Option" "Or" "Preserve" "Private" "Public" "RGB" "RTrim" "Redim" "Rem" "Replace" "Right" "Rnd" "Round" "ScriptEngine" "ScriptEngineBuildVersion" "ScriptEngineMajorVersion" "ScriptEngineMinorVersion" "Second" "Select" "Set" "SetLocale" "Sgn" "Sin" "Space" "Split" "Sqr" "StrComp" "StrReverse" "String" "Sub" "Tan" "Then" "Time" "TimeSerial" "TimeValue" "Timer" "To" "Trim" "TypeName" "UBound" "UCase" "Until" "VarType" "Weekday" "WeekdayName" "Wend" "With" "While" "Year")))) (defvar web-mode-asp-types (regexp-opt (append (cdr (assoc "asp" web-mode-extra-types)) '("Application" "ASPError" "Request" "Response" "Server" "Session")))) (defvar web-mode-aspx-keywords (regexp-opt (append (cdr (assoc "aspx" web-mode-extra-keywords)) '("case" "catch" "do" "else" "end" "for" "foreach" "function" "if" "in" "include" "new" "package" "page" "return" "tag" "throw" "throws" "try" "while")))) (defvar web-mode-smarty-keywords (regexp-opt '("as"))) (defvar web-mode-velocity-keywords (eval-when-compile (regexp-opt '("in" "true" "false")))) (defvar web-mode-freemarker-keywords (eval-when-compile (regexp-opt '("as" "list")))) (defvar web-mode-go-keywords (eval-when-compile (regexp-opt '("const" "define" "else" "end" "for" "func" "if" "import" "pipeline" "range" "return" "struct" "template" "type" "var" "with")))) (defvar web-mode-go-functions (eval-when-compile (regexp-opt '("and" "call" "ge" "html" "index" "js" "len" "not" "or" "print" "printf" "println" "urlquery" "where")))) (defvar web-mode-go-types (regexp-opt (append (cdr (assoc "go" web-mode-extra-types)) '("int" "string")))) (defvar web-mode-closure-keywords (eval-when-compile (regexp-opt '("in" "and" "not" "or")))) (defvar web-mode-svelte-keywords (regexp-opt '("as"))) (defvar web-mode-django-control-blocks (append (cdr (assoc "django" web-mode-extra-control-blocks)) '( "assets" "autoescape" "block" "blocktrans" "cache" "call" "capture" "comment" "draw" "embed" "filter" "for" "foreach" "form" "if" "ifchanged" "ifequal" "ifnotequal" "macro" "random" "raw" "safe" "sandbox" "spaceless" "tablerow" "unless" "verbatim" "with" "endassets" "endautoescape" "endblock" "endblocktrans" "endcache" "endcall" "endcapture" "endcomment" "draw" "endembed" "endfilter" "endfor" "endforeach" "endform" "endif" "endifchanged" "endifequal" "endifnotequal" "endmacro" "endrandom" "endraw" "endsafe" "endsandbox" "endspaceless" "endtablerow" "endunless" "endverbatim" "endwith" ;; "set" "endset" ;#504 "csrf_token" "cycle" "debug" "elif" "else" "elseif" "elsif" "empty" "extends" "firstof" "include" "load" "lorem" "now" "regroup" "ssi" "trans" "templatetag" "url" "widthratio" ;; #805 "graph" "endgraph" "javascript" "endjavascript" "schema" "endschema" "stylesheet" "endstylesheet" ))) (defvar web-mode-django-control-blocks-regexp (regexp-opt web-mode-django-control-blocks t)) (defvar web-mode-django-keywords (eval-when-compile (regexp-opt '("and" "as" "assign" "break" "cache" "call" "case" "context" "continue" "do" "flush" "from" "ignore" "import" "in" "is" "layout" "load" "missing" "none" "not" "or" "pluralize" "random" "set" ;#504 "unless" "use" "var" )))) (defvar web-mode-django-types (eval-when-compile (regexp-opt '("null" "false" "true")))) (defvar web-mode-blade-control-blocks (append (cdr (assoc "blade" web-mode-extra-control-blocks)) '("component" "foreach" "forelse" "for" "if" "section" "slot" "switch" "unless" "while") )) (defvar web-mode-blade-control-blocks-regexp (regexp-opt web-mode-blade-control-blocks t)) (defvar web-mode-directives (eval-when-compile (regexp-opt '("include" "page" "taglib" "Assembly" "Control" "Implements" "Import" "Master" "OutputCache" "Page" "Reference" "Register")))) (defvar web-mode-template-toolkit-keywords (regexp-opt '("block" "call" "case" "catch" "clear" "default" "do" "else" "elsif" "end" "filter" "final" "for" "foreach" "get" "if" "in" "include" "insert" "is" "last" "macro" "meta" "or" "perl" "process" "rawperl" "return" "set" "stop" "switch" "tags" "throw" "try" "unless" "use" "while" "wrapper"))) (defvar web-mode-perl-keywords (regexp-opt '("__DATA__" "__END__" "__FILE__" "__LINE__" "__PACKAGE__" "and" "cmp" "continue" "CORE" "do" "else" "elsif" "eq" "exp" "for" "foreach" "ge" "gt" "if" "le" "lock" "lt" "m" "ne" "no" "or" "package" "q" "qq" "qr" "qw" "qx" "s" "sub" "tr" "unless" "until" "while" "xor" "y" "my" "use" "print" "say"))) (defvar web-mode-javascript-keywords (regexp-opt (append (cdr (assoc "javascript" web-mode-extra-keywords)) '("as" "async" "await" "break" "case" "catch" "class" "const" "continue" "debugger" "default" "delete" "do" "else" "enum" "eval" "export" "extends" "finally" "for" "from" "function" "get" "if" "implements" "import" "in" "instanceof" "interface" "let" "new" "of" "package" "private" "protected" "public" "return" "set" "static" "super" "switch" "throw" "try" "type" "typeof" "var" "void" "while" "with" "yield")))) (defvar web-mode-javascript-constants (regexp-opt '("false" "null" "undefined" "Infinity" "NaN" "true" "arguments" "this"))) (defvar web-mode-razor-keywords (regexp-opt (append (cdr (assoc "razor" web-mode-extra-keywords)) '("false" "true" "foreach" "if" "else" "in" "var" "for" "display" "match" "case" "to" "Html")))) (defvar web-mode-selector-font-lock-keywords (list '("$[[:alnum:]-]+" 0 'web-mode-css-variable-face) (cons (concat "@\\(" web-mode-css-at-rules "\\)\\_>") '(0 'web-mode-css-at-rule-face)) '("\\_<\\(all\|braille\\|embossed\\|handheld\\|print\\|projection\\|screen\\|speech\\|tty\\|tv\\|and\\|or\\)\\_>" 1 'web-mode-keyword-face) '("[^,]+" 0 'web-mode-css-selector-face) (cons (concat ":\\([ ]*[[:alpha:]][^,{]*\\)") '(0 'web-mode-css-pseudo-class-face t t)) )) (defvar web-mode-declaration-font-lock-keywords (list '("--[[:alnum:]-]+" 0 'web-mode-css-variable-face) '("$[[:alnum:]-]+" 0 'web-mode-css-variable-face) (cons (concat "@\\(" web-mode-css-at-rules "\\)\\_>") '(1 'web-mode-css-at-rule-face)) '("\\([[:alpha:]-]+\\)[ ]?:" 0 'web-mode-css-property-name-face) '("\\([[:alpha:]-]+\\)[ ]?(" 1 'web-mode-css-function-face) '("#[[:alnum:]]\\{1,6\\}" 0 'web-mode-css-color-face t t) '("![ ]?important" 0 'web-mode-css-priority-face t t) '("\\([^,]+\\)[ ]+{" 1 'web-mode-css-selector-face) '("'[^']*'\\|\"[^\"]*\"" 0 'web-mode-string-face t t) )) (defvar web-mode-html-font-lock-keywords (list '("]\\|>" 0 'web-mode-html-tag-face t) '(" \\([[:alnum:]-]+=\\)\\(\"[^\"]+\"\\)" (1 'web-mode-html-attr-name-face) (2 'web-mode-html-attr-value-face)) )) ;; voir https://www.gnu.org/software/emacs/manual/html_node/elisp/Search_002dbased-Fontification.html (defvar web-mode-javascript-font-lock-keywords (list '("@\\([[:alnum:]_]+\\)\\_>" 0 'web-mode-keyword-face) '("\\([[:alnum:]]+\\)[`]" 0 'web-mode-preprocessor-face) (cons (concat "\\_<\\(function\\*\\)\\_>") '(1 'web-mode-keyword-face)) (cons (concat "\\([ \t}{(]\\|^\\)\\(" web-mode-javascript-keywords "\\)\\_>") '(2 'web-mode-keyword-face)) (cons (concat "\\_<\\(" web-mode-javascript-constants "\\)\\_>") '(0 'web-mode-constant-face)) '("\\_<\\([$]\\)(" 1 'web-mode-type-face) '("\\_<\\(new\\|instanceof\\|class\\|extends\\) \\([[:alnum:]_.]+\\)\\_>" 2 'web-mode-type-face) '("\\_<\\([[:alnum:]_]+\\):[ ]*function[ ]*(" 1 'web-mode-function-name-face) '("\\_<\\(function\\|get\\|set\\)[ ]+\\([[:alnum:]_]+\\)" (1 'web-mode-keyword-face) (2 'web-mode-function-name-face)) '("\\([[:alnum:]_]+\\)[ ]*([^)]*)[ \n]*{" 1 'web-mode-function-name-face) '("([ ]*\\([[:alnum:]_]+\\)[ ]*=>" 1 'web-mode-function-name-face) '("[ ]*\\([[:alnum:]_]+\\)[ ]*=[ ]*([^)]*)[ ]*=>[ ]*{" 1 'web-mode-function-name-face) '("\\_<\\(var\\|let\\|const\\)[ ]+\\([[:alnum:]_]+\\)" 2 'web-mode-variable-name-face) '("({" "\\([[:alnum:]_]+\\)[, }]+" nil nil (1 'web-mode-variable-name-face)) ;#738 '("\\([[:alnum:]_]+\\)[ ]*=> [{(]" 1 'web-mode-variable-name-face) ;; #989 ;; '("\\(function\\|[,=]\\|^\\)[ ]*(" ;; ("\\([[:alnum:]_]+\\)\\([ ]*=[^,)]*\\)?[,)]" nil nil (1 'web-mode-variable-name-face))) '("\\([[:alnum:]_]+\\):" 1 'web-mode-variable-name-face) '("\\_<\\([[:alnum:]_-]+\\)[ ]?(" 1 'web-mode-function-call-face) '("[a-zA-Z]<\\([a-zA-Z]+\\)[,>]" 1 'web-mode-type-face) )) (defvar web-mode-stylus-font-lock-keywords (list '("^[ \t]*\\([[:alnum:]().-]+\\)$" 1 'web-mode-css-selector-face) '("^[ \t]*\\([[:alnum:]-]+[ ]*:\\)" 1 'web-mode-css-property-name-face) )) (defvar web-mode-sass-font-lock-keywords (list '("^[ \t]*\\([[:alnum:]().-]+\\|&:\\(before\\|after\\)\\)$" 1 'web-mode-css-selector-face) '("^[ \t]*\\([[:alnum:]-]+[ ]*:\\)" 1 'web-mode-css-property-name-face) )) (defvar web-mode-pug-font-lock-keywords (list '("#[[:alnum:]-]+" 0 'web-mode-css-selector-face) '(" \\([@:]?\\sw+[ ]?=\\)" 1 'web-mode-param-name-face) )) (defvar web-mode-sql-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-sql-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) '("\\_<\\([[:alnum:]_-]+\\)[ ]?(" 1 'web-mode-function-call-face) )) (defvar web-mode-markdown-font-lock-keywords (list '("^[ ]*[*].*$" 0 'web-mode-variable-name-face) '("^[ ]*#.*$" 0 'web-mode-comment-face) )) (defvar web-mode-html-tag-font-lock-keywords (list '("\\(" 0 'web-mode-html-tag-bracket-face) )) (defvar web-mode-dust-font-lock-keywords (list '("{[#:/?@><+^]\\([[:alpha:]_.]+\\)" 1 'web-mode-block-control-face) '(":\\([[:alpha:]]+\\)" 1 'web-mode-keyword-face) '("\\_<\\([[:alnum:]_]+=\\)\\(\"[^\"]*\"\\|[[:alnum:]_]*\\)" (1 'web-mode-block-attr-name-face) (2 'web-mode-block-attr-value-face)) '("\\\([[:alnum:]_.]+\\)" 0 'web-mode-variable-name-face) )) (defvar web-mode-expressionengine-font-lock-keywords (list '("{/?\\([[:alpha:]_]+:[[:alpha:]_:]+\\|if\\)" 1 'web-mode-block-control-face) '(":\\([[:alpha:]_]+\\)" 1 'web-mode-keyword-face) '(" {\\([[:alpha:]_]+\\)}" 1 'web-mode-keyword-face t) '("\\_<\\([[:alnum:]_]+=\\)\\(\"[^\"]*\"\\|[[:alnum:]_]*\\)" (1 'web-mode-block-attr-name-face) (2 'web-mode-block-attr-value-face)) '("\\\([[:alnum:]_.]+\\)" 0 'web-mode-variable-name-face) )) (defvar web-mode-svelte-font-lock-keywords (list (cons (concat "[ ]\\(" web-mode-svelte-keywords "\\)[ ]") '(1 'web-mode-keyword-face)) '("{[#:/@]\\([[:alpha:]_.]+\\)" 1 'web-mode-block-control-face) '("\\_<\\([[:alnum:]_]+=\\)\\(\"[^\"]*\"\\|[[:alnum:]_]*\\)" (1 'web-mode-block-attr-name-face) (2 'web-mode-block-attr-value-face)) '("\\\([[:alnum:]_.]+\\)" 0 'web-mode-variable-name-face) '("\\_<\\([$]\\)\\([[:alnum:]_]+\\)" (1 'web-mode-constant-face) (2 'web-mode-variable-name-face)) )) (defvar web-mode-template-toolkit-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-template-toolkit-keywords "\\)\\_>") '(1 'web-mode-keyword-face)) '("\\\([[:alpha:]][[:alnum:]_]+\\)[ ]?(" 1 'web-mode-function-call-face) '("\\\([[:alpha:]][[:alnum:]_]+\\)" 0 'web-mode-variable-name-face) )) (defvar web-mode-smarty-font-lock-keywords (list (cons (concat "[ ]\\(" web-mode-smarty-keywords "\\)[ ]") '(1 'web-mode-keyword-face)) '("{/?\\([[:alpha:]_]+\\)" 1 'web-mode-block-control-face) '("\\([}{]\\)" 0 'web-mode-block-delimiter-face) '("\\_<\\([$]\\)\\([[:alnum:]_]+\\)" (1 nil) (2 'web-mode-variable-name-face)) '("\\_<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-call-face) '(" \\(\\sw+[ ]?=\\)" 1 'web-mode-param-name-face) '(" \\(\\sw+\\)[ }]" 1 'web-mode-param-name-face) '("|\\([[:alnum:]_]+\\)" 1 'web-mode-function-call-face) '("\\(->\\)\\(\\sw+\\)" (1 nil) (2 'web-mode-variable-name-face)) '("[.]\\([[:alnum:]_-]+\\)[ ]?(" 1 'web-mode-function-call-face) '("[.]\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face) '("#\\([[:alnum:]_]+\\)#" 1 'web-mode-variable-name-face) )) (defvar web-mode-velocity-font-lock-keywords (list '("#{?\\([[:alpha:]_]+\\)\\_>" (1 'web-mode-block-control-face)) (cons (concat "\\_<\\(" web-mode-velocity-keywords "\\)\\_>") '(1 'web-mode-keyword-face t t)) '("#macro([ ]*\\([[:alpha:]]+\\)[ ]+" 1 'web-mode-function-name-face) '("\\(def\\|define\\) \\([[:alnum:]_-]+\\)(" 2 'web-mode-function-name-face) '("[.]\\([[:alnum:]_-]+\\)" 1 'web-mode-variable-name-face) '("\\_<\\($[!]?[{]?\\)\\([[:alnum:]_-]+\\)[}]?" (1 nil) (2 'web-mode-variable-name-face)) )) (defvar web-mode-mako-tag-font-lock-keywords (list '("") '(1 'web-mode-constant-face)) (cons (concat "\\_<\\(" web-mode-python-keywords "\\)\\_>") '(1 'web-mode-keyword-face)) (cons (concat "\\_<\\(endfor\\|endif\\|endwhile\\)\\_>") '(1 'web-mode-keyword-face)) )) (defvar web-mode-web2py-font-lock-keywords (list '("\\_<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-call-face) (cons (concat "\\_<\\(" web-mode-python-constants "\\)\\_>") '(1 'web-mode-constant-face)) (cons (concat "\\_<\\(" web-mode-python-keywords "\\)\\_>") '(1 'web-mode-keyword-face)) (cons (concat "\\_<\\(block\\|extend\\|super\\|end\\|include\\)\\_>") '(1 'web-mode-keyword-face)) )) (defvar web-mode-django-expr-font-lock-keywords (list '("|[ ]?\\([[:alpha:]_]+\\)\\_>" 1 'web-mode-filter-face) (cons (concat "\\_<\\(" web-mode-django-types "\\)\\_>") '(1 'web-mode-type-face)) '("\\_<\\([[:alpha:]_]+\\)[ ]?(" 1 'web-mode-function-call-face) '("[[:alnum:]_]+" 0 'web-mode-variable-name-face) )) (defvar web-mode-django-code-font-lock-keywords (list (cons (concat "{%[ ]*\\(" web-mode-django-control-blocks-regexp "\\)[ %]") '(1 'web-mode-block-control-face)) '("{%[ ]*\\(end[[:alpha:]]+\\)\\_>" 1 'web-mode-block-control-face) ;#504 (cons (concat "\\_<\\(" web-mode-django-keywords "\\)\\_>") '(1 'web-mode-keyword-face)) (cons (concat "\\_<\\(" web-mode-django-types "\\)\\_>") '(1 'web-mode-type-face)) '("|[ ]?\\([[:alpha:]_]+\\)\\_>" 1 'web-mode-function-call-face) '("\\_<\\([[:alpha:]_]+\\)[ ]?(" 1 'web-mode-function-call-face) '("[[:alnum:]_.]+" 0 'web-mode-variable-name-face) '("[[:alnum:]_]+\\([.][[:alnum:]_]+\\)+" 0 'web-mode-variable-name-face t t) )) (defvar web-mode-ctemplate-font-lock-keywords (list '("{[~]?{[#/>^]?[ ]*\\([[:alnum:]_.-]+\\)" 1 'web-mode-block-control-face) '("[ \t]+\\([[:alnum:]_-]+\\)=" (1 'web-mode-block-attr-name-face)) '("\"[^\"]+\"" 0 'web-mode-block-string-face) )) (defvar web-mode-razor-font-lock-keywords (list '("@\\([[:alnum:]_.]+\\)[ ]*[({]" 1 'web-mode-block-control-face) (cons (concat "\\_<\\(" web-mode-razor-keywords "\\)\\_>") '(1 'web-mode-keyword-face)) '("\\_<\\(String\\)\\_>" 1 'web-mode-type-face) '("\\([[:alnum:]]+:\\)" 1 'web-mode-symbol-face) '("\\(@[[:alnum:]_.]+\\)" 1 'web-mode-variable-name-face) )) (defvar web-mode-riot-font-lock-keywords (list '("\\(parent\\|opts\\|tags\\|this\\)\\.\\([[:alnum:]_.]+\\)" (1 'web-mode-constant-face) (2 'web-mode-variable-name-face)) '("\\([[:alnum:]_.]+\\)" 0 'web-mode-variable-name-face) )) (defvar web-mode-closure-font-lock-keywords (list '("{\\([@/]?[[:alpha:]]+[?]?\\)" 1 'web-mode-block-control-face) '("{[@]?param[?]?[ ]+\\([[:alnum:]]+[:]?\\)" 1 'web-mode-symbol-face) '("\\_<\\(true\\|false\\|null\\)\\_>" 1 'web-mode-type-face) '("\\\_<[[:alpha:]]+:[ ]+\\([[:alpha:]]+\\)" 1 'web-mode-type-face) (cons (concat "\\_<\\(" web-mode-closure-keywords "\\)\\_>") '(1 'web-mode-keyword-face)) '("{\\(alias\\|call\\|delcall\\|delpackage\\|deltemplate\\|namespace\\|template\\)[ ]+\\([[:alnum:].]+\\)" 2 'web-mode-constant-face) '("\\(allowemptydefault\\|data\\|desc\\|meaning\\|autoescape\\|private\\|variant\\)=" 0 'web-mode-block-attr-name-face) '("|\\([[:alpha:]]+\\)" 1 'web-mode-function-call-face) '("\\_<\\([[:alnum:]]+\\)[ ]?(" 1 'web-mode-function-call-face) '("$\\([[:alnum:]._]+\\)" 1 'web-mode-variable-name-face) )) (defvar web-mode-go-font-lock-keywords (list '("{{[-]?[ ]*\\([[:alpha:]]+\\)" 1 'web-mode-block-control-face) '("\\_") '(0 'web-mode-type-face)) (cons (concat "\\_<\\(" web-mode-go-keywords "\\)\\_>") '(1 'web-mode-keyword-face)) (cons (concat "\\_<\\(" web-mode-go-functions "\\)\\_>") '(1 'web-mode-function-call-face)) '("[$.]\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face t t) '("|[ ]?\\([[:alpha:]_]+\\)\\_>" 1 'web-mode-filter-face) )) (defvar web-mode-expression-font-lock-keywords (list '("[[:alpha:]_]" 0 'web-mode-variable-name-face) )) (defvar web-mode-angular-font-lock-keywords (list '("[[:alpha:]_]" 0 'web-mode-variable-name-face) )) (defvar web-mode-underscore-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-javascript-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) '("\\_<\\(_\.[[:alpha:]]+\\)(" 1 'web-mode-function-call-face) '("\\_" 1 'web-mode-type-face) '("\\_<\\([[:alnum:]_]+\\):[ ]*function[ ]*(" 1 'web-mode-function-name-face) '("\\_<\\(var\\)\\_>[ ]+\\([[:alnum:]_]+\\)" (1 'web-mode-keyword-face) (2 'web-mode-variable-name-face)) )) (defvar web-mode-vue-font-lock-keywords (list '("\\_<\\([[:alnum:]_-]+\\)[ ]?(" 1 'web-mode-function-call-face) '("[[:alpha:]_]" 0 'web-mode-variable-name-face) )) (defvar web-mode-engine-tag-font-lock-keywords (list '("") '(0 'web-mode-keyword-face)) '("\\(public\\|private\\)[ ]+\\([[:alpha:]]+\\)[ ]+\\([[:alnum:]._]+\\)[ ]?(" (2 'web-mode-type-face) (3 'web-mode-function-name-face)) '("\\_<\\([[:alnum:]._]+\\)[ ]?(" 1 'web-mode-function-call-face) '("@\\(\\sw*\\)" 1 'web-mode-variable-name-face) '("\\_<\\([[:alnum:].]+\\)[ ]+[{[:alpha:]]+" 1 'web-mode-type-face) )) (defvar web-mode-asp-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-asp-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) (cons (concat "\\_<\\(" web-mode-asp-types "\\)\\_>") '(0 'web-mode-type-face)) (cons (concat "\\_<\\(" web-mode-asp-constants "\\)\\_>") '(0 'web-mode-constant-face)) '("\\(Class\\|new\\) \\([[:alnum:]_]+\\)" 2 'web-mode-type-face) '("Const \\([[:alnum:]_]+\\)" 1 'web-mode-constant-face) '("\\_" (0 'web-mode-keyword-face) ("[[:alnum:]_]+" nil nil (0 'web-mode-variable-name-face))) '("\\_<\\(public\\|private\\|sub\\|function\\)\\_> \\([[:alnum:]_]+\\)[ ]*(" 2 'web-mode-function-name-face) '("\\_<\\(public\\|private\\|dim\\)\\_> \\([[:alnum:]_]+\\)" 2 'web-mode-variable-name-face) )) (defvar web-mode-aspx-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-aspx-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) '("\\_<\\([[:alnum:].]+\\)[ ]+[[:alpha:]]+" 1 'web-mode-type-face) )) (defvar web-mode-uel-font-lock-keywords (list '("[$#{]{\\|}" 0 'web-mode-preprocessor-face) '("\\([[:alpha:]_]+\\)[ ]?(" 1 'web-mode-function-call-face) '("|[ ]*\\(trim\\|x\\|u\\)" 1 'web-mode-function-call-face) '("[[:alpha:]_]" 0 'web-mode-variable-name-face) )) (defvar web-mode-php-var-interpolation-font-lock-keywords (list '("[[:alpha:]_]" 0 'web-mode-variable-name-face) '("\".+\"\\|'.*'" 0 'web-mode-string-face) )) (defvar web-mode-marko-font-lock-keywords (list '("[[:alnum:]_]+" 0 'web-mode-variable-name-face) )) (defvar web-mode-freemarker-square-font-lock-keywords (list '("\\[/?[#@]\\([[:alpha:]_.]*\\)" 1 'web-mode-block-control-face) '("#\\(macro\\|function\\) \\([[:alpha:]]+\\)" 2 'web-mode-function-name-face) (cons (concat "\\_<\\(" web-mode-freemarker-keywords "\\)\\_>") '(1 'web-mode-keyword-face)) '("\\_<\\([[:alnum:]._]+\\)[ ]?(" 1 'web-mode-function-call-face) '("[[:alpha:]]\\([[:alnum:]_]+\\)?" 0 'web-mode-variable-name-face) )) (defvar web-mode-freemarker-font-lock-keywords (list '("") '(1 'web-mode-keyword-face)) '("\\_<\\([[:alnum:]._]+\\)[ ]?(" 1 'web-mode-function-call-face) '("[[:alpha:]]\\([[:alnum:]_]+\\)?" 0 'web-mode-variable-name-face) )) (defvar web-mode-directive-font-lock-keywords (list '("<%@[ ]*\\([[:alpha:]]+\\)[ ]+" 1 'web-mode-block-control-face) '("\\_<\\([[:alpha:]]+=\\)\\(\"[^\"]*\"\\)" (1 'web-mode-block-attr-name-face t t) (2 'web-mode-block-attr-value-face t t)) )) (defvar web-mode-erb-font-lock-keywords (list '("[^:]\\(:[[:alnum:]_]+\\)" 1 'web-mode-symbol-face) '("\\([[:alnum:]_]+:\\)[ ]+" 1 'web-mode-symbol-face) (cons (concat "\\_<\\(" web-mode-erb-builtins "\\)\\_>") '(0 'web-mode-builtin-face)) (cons (concat "\\_<\\(" web-mode-erb-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) '("\\_<\\(self\\|true\\|false\\|nil\\)\\_>" 0 'web-mode-variable-name-face) '("[@$]@?\\([[:alnum:]_]+\\)" 0 'web-mode-variable-name-face) '("class[ ]+\\([[:alnum:]_]+\\)" 1 'web-mode-type-face) '("def[ ]+\\([[:alnum:]_]+\\)" 1 'web-mode-function-name-face) '("\\(?:\\_<\\|::\\)\\([A-Z]+[[:alnum:]_]+\\)" 1 (unless (eq (char-after) ?\() 'web-mode-type-face)) '("/[^/]+/" 0 'web-mode-string-face) )) (defvar web-mode-ejs-font-lock-keywords web-mode-javascript-font-lock-keywords) (defvar web-mode-python-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-python-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) )) (defvar web-mode-elixir-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-elixir-keywords "\\)\\_>") '(0 'web-mode-builtin-face)) (cons (concat "\\_<\\(" web-mode-elixir-constants "\\)\\_>") '(0 'web-mode-constant-face)) '("def[ ]+\\([[:alnum:]_]+\\)" 1 'web-mode-function-name-face) '("@\\([[:alnum:]_]+\\)" 0 'web-mode-variable-name-face) '("[ ]\\(:[[:alnum:]-_]+\\)" 1 'web-mode-symbol-face) )) (defvar web-mode-erlang-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-erlang-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) (cons (concat "\\_<\\(" web-mode-erlang-constants "\\)\\_>") '(0 'web-mode-constant-face)) '("@\\([[:alnum:]_]+\\)" 0 'web-mode-variable-name-face) '("[ ]\\(:[[:alnum:]-_]+\\)" 1 'web-mode-symbol-face) )) (defvar web-mode-mason-code-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-mason-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) '("sub[ ]+\\([[:alnum:]_]+\\)" 1 'web-mode-function-name-face) '("\\_<\\([[:alnum:]_]+\\)[ ]?::" 1 'web-mode-type-face) '("\\([@]\\)\\([[:alnum:]#_]*\\)" (1 nil) (2 'web-mode-variable-name-face)) '("\\_<\\([$%]\\)\\([[:alnum:]@#_]*\\)" (1 nil) (2 'web-mode-variable-name-face)) '("{\\([[:alnum:]_]+\\)}" 1 'web-mode-variable-name-face) '("\\_<\\(\\sw+\\)[ ]?(" 1 'web-mode-function-call-face) '("[[:alnum:]_][ ]?::[ ]?\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face) '("->[ ]?\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face) '("\\(?:method\\|def\\) \\([[:alnum:]._]+\\)" 1 'web-mode-function-name-face) '("|[ ]*\\([[:alnum:],]+\\)[ ]*%>" 1 'web-mode-filter-face) )) (defvar web-mode-mason-block-font-lock-keywords (list '("<[/]?%\\([[:alpha:]]+\\)" 1 'web-mode-block-control-face) '("[[:alpha:]]" 0 'web-mode-block-attr-value-face) )) (defvar web-mode-mojolicious-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-perl-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) '("\\_<\\(begin\\|end\\)\\_>" 1 'web-mode-constant-face) '("\\_<\\([$]\\)\\([[:alnum:]_]*\\)" (1 nil) (2 'web-mode-variable-name-face)) )) (defvar web-mode-lsp-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-lsp-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) (cons (concat "\\_<\\(" web-mode-lsp-constants "\\)\\_>") '(1 'web-mode-constant-face)) '("[ ]\\(:[[:alnum:]-_]+\\)" 1 'web-mode-symbol-face) '("(defun \\([[:alnum:]-:]+\\)" 1 'web-mode-function-name-face) '("(defvar \\([[:alnum:]-:]+\\)" 1 'web-mode-variable-name-face) )) (defvar web-mode-cl-emb-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-cl-emb-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) (cons (concat "\\_<\\(" web-mode-cl-emb-constants "\\)\\_>") '(0 'web-mode-constant-face)) '("\\(@\\)" 1 'web-mode-function-call-face) (list (concat "\\(@" web-mode-cl-emb-keywords "\\)[ ]+\\([[:alnum:]_]+\\)") '(1 'web-mode-keyword-face) '(2 'web-mode-variable-name-face)) )) (defvar web-mode-artanis-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-artanis-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) (cons (concat "\\_<\\(" web-mode-artanis-constants "\\)\\_>") '(0 'web-mode-constant-face)) '("(define[*]? (\\([[:alnum:]-:_!#$%^&*=+/?<>.]+\\)" 1 'web-mode-function-name-face) '("\\(#:[[:alnum:]-:_!#$%^&*=+/?<>.]+\\)" 1 'web-mode-builtin-face) )) (defvar web-mode-php-font-lock-keywords (list (cons (concat "\\_<\\(" web-mode-php-keywords "\\)\\_>") '(0 'web-mode-keyword-face)) (cons (concat "(\\_<\\(" web-mode-php-types "\\)\\_>") '(1 'web-mode-type-face)) (cons (concat "\\_<\\(" web-mode-php-constants "\\)\\_>") '(0 'web-mode-constant-face)) '("function[ ]+\\([[:alnum:]_]+\\)" 1 'web-mode-function-name-face) '("\\_<\\([[:alnum:]_]+\\)[ ]?(" 1 'web-mode-function-call-face) '("[[:alnum:]_][ ]?::[ ]?\\([[:alnum:]_]+\\)" 1 'web-mode-constant-face) '("->[ ]?\\([[:alnum:]_]+\\)" 1 'web-mode-variable-name-face) '("\\_<\\([[:alnum:]_]+\\)[ ]?::" 1 'web-mode-type-face) '("\\_<\\(instanceof\\|class\\|extends\\|new\\)[ ]+\\([[:alnum:]_]+\\)" 2 'web-mode-type-face) '("\\(\\_<\\|[+-]\\)\\([$]\\)\\([[:alnum:]_]*\\)" (2 nil) (3 'web-mode-variable-name-face)) )) (defvar web-mode-spip-font-lock-keywords (list '("<:.+:>" 0 'web-mode-block-string-face) '("#[A-Z0-9_]+" 0 'web-mode-variable-name-face) '("|[a-z0-9_=!?<>]+" 0 'web-mode-function-call-face) '("(\\([[:alnum:]_ ]+\\))" 1 'web-mode-constant-face) )) (defvar web-mode-latex-font-lock-keywords (list '("[[:alnum:]_]+" 0 'web-mode-function-name-face t t) )) (defvar web-mode-blade-font-lock-keywords (append (list '("@\\([[:alpha:]_]+\\)" (1 'web-mode-block-control-face))) web-mode-php-font-lock-keywords)) (defvar web-mode-engines-font-lock-keywords '(("angular" . web-mode-angular-font-lock-keywords) ("artanis" . web-mode-artanis-font-lock-keywords) ("blade" . web-mode-blade-font-lock-keywords) ("cl-emb" . web-mode-cl-emb-font-lock-keywords) ("closure" . web-mode-closure-font-lock-keywords) ("ctemplate" . web-mode-ctemplate-font-lock-keywords) ("dust" . web-mode-dust-font-lock-keywords) ("elixir" . web-mode-elixir-font-lock-keywords) ("ejs" . web-mode-ejs-font-lock-keywords) ("erb" . web-mode-erb-font-lock-keywords) ("expressionengine" . web-mode-expressionengine-font-lock-keywords) ("go" . web-mode-go-font-lock-keywords) ("hero" . web-mode-go-font-lock-keywords) ("lsp" . web-mode-lsp-font-lock-keywords) ("marko" . web-mode-marko-font-lock-keywords) ("mojolicious" . web-mode-mojolicious-font-lock-keywords) ("php" . web-mode-php-font-lock-keywords) ("python" . web-mode-python-font-lock-keywords) ("razor" . web-mode-razor-font-lock-keywords) ("riot" . web-mode-riot-font-lock-keywords) ("smarty" . web-mode-smarty-font-lock-keywords) ("spip" . web-mode-spip-font-lock-keywords) ("template-toolkit" . web-mode-template-toolkit-font-lock-keywords) ("underscore" . web-mode-underscore-font-lock-keywords) ("web2py" . web-mode-web2py-font-lock-keywords) ("velocity" . web-mode-velocity-font-lock-keywords) ("vue" . web-mode-vue-font-lock-keywords) ("xoops" . web-mode-smarty-font-lock-keywords) ("svelte" . web-mode-svelte-font-lock-keywords) ) "Engines font-lock keywords") (defvar web-mode-prettify-symbols-alist '(("=>" . 8658) (">=" . 8805) ("<=" . 8804))) (defvar web-mode-before-auto-complete-hooks nil "List of functions to run before triggering the auto-complete library. Auto-complete sources will sometimes need some tweaking to work nicely with web-mode. This hook gives users the chance to adjust the environment as needed for ac-sources, right before they're used.") (defvar web-mode-ignore-ac-start-advice nil "If not nil 'defadvice' for 'ac-start' will be ignored. Can be set inside a hook in 'web-mode-before-auto-complete-hooks' to non nil to ignore the defadvice which sets ac-sources according to current language. This is needed if the corresponding auto-completion triggers another auto-completion with different ac-sources (e.g. ac-php)") (defvar web-mode-ac-sources-alist nil "alist mapping language names to ac-sources for that language.") (defvar web-mode-trace nil "Activate debug tracing.") (defvar web-mode-syntax-table (let ((table (make-syntax-table))) (modify-syntax-entry ?- "_" table) (modify-syntax-entry ?_ "_" table) ;#563 (modify-syntax-entry ?< "." table) (modify-syntax-entry ?> "." table) (modify-syntax-entry ?& "." table) (modify-syntax-entry ?/ "." table) (modify-syntax-entry ?= "." table) (modify-syntax-entry ?% "." table) table) "Syntax table used to reveal whitespaces.") (defvar web-mode-map (let ((map (make-sparse-keymap))) (define-key map [menu-bar wm] (cons "Web-Mode" (make-sparse-keymap))) (define-key map [menu-bar wm dom] (cons "Dom" (make-sparse-keymap))) (define-key map [menu-bar wm blk] (cons "Block" (make-sparse-keymap))) (define-key map [menu-bar wm attr] (cons "Html Attr" (make-sparse-keymap))) (define-key map [menu-bar wm tag] (cons "Html Tag" (make-sparse-keymap))) (define-key map [menu-bar wm elt] (cons "Html Element" (make-sparse-keymap))) (define-key map [menu-bar wm sep-1] '(menu-item "--")) (define-key map [menu-bar wm dom dom-xpa] '(menu-item "XPath" web-mode-dom-xpath)) (define-key map [menu-bar wm dom dom-tra] '(menu-item "Traverse" web-mode-dom-traverse)) (define-key map [menu-bar wm dom dom-err] '(menu-item "Show error(s)" web-mode-dom-errors-show)) (define-key map [menu-bar wm dom dom-ent] '(menu-item "Replace html entities" web-mode-dom-entities-replace)) (define-key map [menu-bar wm dom dom-quo] '(menu-item "Replace dumb quotes" web-mode-dom-quotes-replace)) (define-key map [menu-bar wm dom dom-apo] '(menu-item "Replace apostrophes" web-mode-dom-apostrophes-replace)) (define-key map [menu-bar wm dom dom-nor] '(menu-item "Normalize" web-mode-dom-normalize)) (define-key map [menu-bar wm blk blk-sel] '(menu-item "Select" web-mode-block-select)) (define-key map [menu-bar wm blk blk-pre] '(menu-item "Previous" web-mode-block-previous)) (define-key map [menu-bar wm blk blk-nex] '(menu-item "Next" web-mode-block-next)) (define-key map [menu-bar wm blk blk-kil] '(menu-item "Kill" web-mode-block-kill)) (define-key map [menu-bar wm blk blk-end] '(menu-item "End" web-mode-block-end)) (define-key map [menu-bar wm blk blk-clo] '(menu-item "Close" web-mode-block-close)) (define-key map [menu-bar wm blk blk-beg] '(menu-item "Beginning" web-mode-block-beginning)) (define-key map [menu-bar wm attr attr-ins] '(menu-item "Insert" web-mode-attribute-insert)) (define-key map [menu-bar wm attr attr-end] '(menu-item "End" web-mode-attribute-end)) (define-key map [menu-bar wm attr attr-beg] '(menu-item "Beginning" web-mode-attribute-beginning)) (define-key map [menu-bar wm attr attr-sel] '(menu-item "Select" web-mode-attribute-select)) (define-key map [menu-bar wm attr attr-kil] '(menu-item "Kill" web-mode-attribute-kill)) (define-key map [menu-bar wm attr attr-nex] '(menu-item "Next" web-mode-attribute-next)) (define-key map [menu-bar wm attr attr-pre] '(menu-item "Previous" web-mode-attribute-previous)) (define-key map [menu-bar wm attr attr-tra] '(menu-item "Transpose" web-mode-attribute-transpose)) (define-key map [menu-bar wm tag tag-beg] '(menu-item "Sort Attributes" web-mode-tag-attributes-sort)) (define-key map [menu-bar wm tag tag-sel] '(menu-item "Select" web-mode-tag-select)) (define-key map [menu-bar wm tag tag-pre] '(menu-item "Previous" web-mode-tag-previous)) (define-key map [menu-bar wm tag tag-nex] '(menu-item "Next" web-mode-tag-next)) (define-key map [menu-bar wm tag tag-end] '(menu-item "End" web-mode-tag-end)) (define-key map [menu-bar wm tag tag-beg] '(menu-item "Beginning" web-mode-tag-beginning)) (define-key map [menu-bar wm elt elt-con] '(menu-item "Contract" web-mode-element-contract)) (define-key map [menu-bar wm elt elt-ext] '(menu-item "Extract" web-mode-element-extract)) (define-key map [menu-bar wm elt elt-van] '(menu-item "Vanish" web-mode-element-vanish)) (define-key map [menu-bar wm elt elt-exc] '(menu-item "Transpose" web-mode-element-transpose)) (define-key map [menu-bar wm elt elt-sel] '(menu-item "Select" web-mode-element-select)) (define-key map [menu-bar wm elt elt-ren] '(menu-item "Rename" web-mode-element-rename)) (define-key map [menu-bar wm elt elt-pre] '(menu-item "Previous" web-mode-element-previous)) (define-key map [menu-bar wm elt elt-par] '(menu-item "Parent" web-mode-element-parent)) (define-key map [menu-bar wm elt elt-nex] '(menu-item "Next" web-mode-element-next)) (define-key map [menu-bar wm elt elt-mut] '(menu-item "Mute blanks" web-mode-element-mute-blanks)) (define-key map [menu-bar wm elt elt-del] '(menu-item "Kill" web-mode-element-kill)) (define-key map [menu-bar wm elt elt-end] '(menu-item "End" web-mode-element-end)) (define-key map [menu-bar wm elt elt-inn] '(menu-item "Content (select)" web-mode-element-content-select)) (define-key map [menu-bar wm elt elt-clo] '(menu-item "Close" web-mode-element-close)) (define-key map [menu-bar wm elt elt-ins] '(menu-item "Insert" web-mode-element-insert)) (define-key map [menu-bar wm elt elt-ins] '(menu-item "Word to tag" web-mode-element-insert-at-point)) (define-key map [menu-bar wm elt elt-dup] '(menu-item "Clone" web-mode-element-clone)) (define-key map [menu-bar wm elt elt-cfo] '(menu-item "Children fold" web-mode-element-children-fold-or-unfold)) (define-key map [menu-bar wm elt elt-chi] '(menu-item "Child" web-mode-element-child)) (define-key map [menu-bar wm elt elt-beg] '(menu-item "Beginning" web-mode-element-beginning)) (define-key map [menu-bar wm fol] '(menu-item "Fold/Unfold" web-mode-fold-or-unfold)) (define-key map [menu-bar wm hig] '(menu-item "Fontify buffer" web-mode-buffer-fontify)) (define-key map [menu-bar wm ind] '(menu-item "Indent buffer" web-mode-buffer-indent)) (define-key map [menu-bar wm nav] '(menu-item "Tag/Block navigation" web-mode-navigate)) (define-key map [menu-bar wm exp] '(menu-item "Mark and Expand" web-mode-mark-and-expand)) (define-key map [menu-bar wm spa] '(menu-item "Toggle whitespaces" web-mode-whitespaces-show)) (define-key map [menu-bar wm sni] '(menu-item "Insert snippet" web-mode-snippet-insert)) ;;-------------------------------------------------------------------------- ;; "C-c " are reserved for users (define-key map (kbd "C-c C-a b") 'web-mode-attribute-beginning) (define-key map (kbd "C-c C-a e") 'web-mode-attribute-end) (define-key map (kbd "C-c C-a i") 'web-mode-attribute-insert) (define-key map (kbd "C-c C-a n") 'web-mode-attribute-next) (define-key map (kbd "C-c C-a s") 'web-mode-attribute-select) (define-key map (kbd "C-c C-a k") 'web-mode-attribute-kill) (define-key map (kbd "C-c C-a p") 'web-mode-attribute-previous) (define-key map (kbd "C-c C-a t") 'web-mode-attribute-transpose) (define-key map (kbd "C-c C-b b") 'web-mode-block-beginning) (define-key map (kbd "C-c C-b c") 'web-mode-block-close) (define-key map (kbd "C-c C-b e") 'web-mode-block-end) (define-key map (kbd "C-c C-b k") 'web-mode-block-kill) (define-key map (kbd "C-c C-b n") 'web-mode-block-next) (define-key map (kbd "C-c C-b p") 'web-mode-block-previous) (define-key map (kbd "C-c C-b s") 'web-mode-block-select) (define-key map (kbd "C-c C-d a") 'web-mode-dom-apostrophes-replace) (define-key map (kbd "C-c C-d d") 'web-mode-dom-errors-show) (define-key map (kbd "C-c C-d e") 'web-mode-dom-entities-replace) (define-key map (kbd "C-c C-d n") 'web-mode-dom-normalize) (define-key map (kbd "C-c C-d q") 'web-mode-dom-quotes-replace) (define-key map (kbd "C-c C-d t") 'web-mode-dom-traverse) (define-key map (kbd "C-c C-d x") 'web-mode-dom-xpath) (define-key map (kbd "C-c C-e /") 'web-mode-element-close) (define-key map (kbd "C-c C-e a") 'web-mode-element-content-select) (define-key map (kbd "C-c C-e b") 'web-mode-element-beginning) (define-key map (kbd "C-c C-e c") 'web-mode-element-clone) (define-key map (kbd "C-c C-e d") 'web-mode-element-child) (define-key map (kbd "C-c C-e e") 'web-mode-element-end) (define-key map (kbd "C-c C-e f") 'web-mode-element-children-fold-or-unfold) (define-key map (kbd "C-c C-e i") 'web-mode-element-insert) (define-key map (kbd "C-c C-e I") 'web-mode-element-insert-at-point) (define-key map (kbd "C-c C-e k") 'web-mode-element-kill) (define-key map (kbd "C-c C-e m") 'web-mode-element-mute-blanks) (define-key map (kbd "C-c C-e n") 'web-mode-element-next) (define-key map (kbd "C-c C-e p") 'web-mode-element-previous) (define-key map (kbd "C-c C-e r") 'web-mode-element-rename) (define-key map (kbd "C-c C-e s") 'web-mode-element-select) (define-key map (kbd "C-c C-e t") 'web-mode-element-transpose) (define-key map (kbd "C-c C-e u") 'web-mode-element-parent) (define-key map (kbd "C-c C-e v") 'web-mode-element-vanish) (define-key map (kbd "C-c C-e w") 'web-mode-element-wrap) (define-key map (kbd "C-c C-e +") 'web-mode-element-extract) (define-key map (kbd "C-c C-e -") 'web-mode-element-contract) (define-key map (kbd "C-c C-t a") 'web-mode-tag-attributes-sort) (define-key map (kbd "C-c C-t b") 'web-mode-tag-beginning) (define-key map (kbd "C-c C-t e") 'web-mode-tag-end) (define-key map (kbd "C-c C-t m") 'web-mode-tag-match) (define-key map (kbd "C-c C-t n") 'web-mode-tag-next) (define-key map (kbd "C-c C-t p") 'web-mode-tag-previous) (define-key map (kbd "C-c C-t s") 'web-mode-tag-select) ;;-------------------------------------------------------------------------- ;;(define-key map (kbd "M-q") 'fill-paragraph) (define-key map (kbd "M-;") 'web-mode-comment-or-uncomment) ;;C-c C-a : attribute ;;C-c C-b : block ;;C-c C-d : dom ;;C-c C-e : element (define-key map (kbd "C-c C-f") 'web-mode-fold-or-unfold) (define-key map (kbd "C-c C-h") 'web-mode-buffer-fontify) (define-key map (kbd "C-c C-i") 'web-mode-buffer-indent) (define-key map (kbd "C-c C-j") 'web-mode-jshint) (define-key map (kbd "C-c C-l") 'web-mode-file-link) (define-key map (kbd "C-c C-m") 'web-mode-mark-and-expand) (define-key map (kbd "C-c C-n") 'web-mode-navigate) (define-key map (kbd "C-c C-r") 'web-mode-reload) (define-key map (kbd "C-c C-s") 'web-mode-snippet-insert) ;;C-c C-t : tag (define-key map (kbd "C-c C-w") 'web-mode-whitespaces-show) map) "Keymap for `web-mode'.") ;;---- COMPATIBILITY ----------------------------------------------------------- (eval-and-compile ;; compatibility with emacs < 23 (defun web-mode-string-match-p (regexp string &optional start) "Same as `string-match' except it does not change the match data." (let ((inhibit-changing-match-data t)) (string-match regexp string start))) (unless (fboundp 'string-match-p) (fset 'string-match-p (symbol-function 'web-mode-string-match-p))) ;; compatibility with emacs < 23.3 (if (fboundp 'with-silent-modifications) (defalias 'web-mode-with-silent-modifications 'with-silent-modifications) (defmacro web-mode-with-silent-modifications (&rest body) `(let ((old-modified-p (buffer-modified-p)) (inhibit-modification-hooks t) (buffer-undo-list t)) (unwind-protect ,@body (set-buffer-modified-p old-modified-p))))) ;; compatibility with emacs < 24.3 (defun web-mode-buffer-narrowed-p () (if (fboundp 'buffer-narrowed-p) (buffer-narrowed-p) (/= (- (point-max) (point-min)) (buffer-size)))) ;; compatibility with emacs < 24 (defalias 'web-mode-prog-mode (if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode)) ;; compatibility with emacs < 24.3 (unless (fboundp 'setq-local) (defmacro setq-local (var val) `(set (make-local-variable ',var) ,val))) ;; compatability with emacs < 24.4 (defun web-mode-string-suffix-p (suffix string) "Return t if STRING ends with SUFFIX." (and (string-match (rx-to-string `(: ,suffix eos) t) string) t)) (unless (fboundp 'string-suffix-p) (fset 'string-suffix-p (symbol-function 'web-mode-string-suffix-p))) (unless (fboundp 'seq-some) (defun seq-some (pred seq) (unless (null seq) (or (funcall pred (car seq)) (seq-some pred (cdr seq)))))) ) ;eval-and-compile ;;---- MAJOR MODE -------------------------------------------------------------- ;;;###autoload (define-derived-mode web-mode web-mode-prog-mode "Web" "Major mode for editing web templates." (make-local-variable 'web-mode-attr-indent-offset) (make-local-variable 'web-mode-attr-value-indent-offset) (make-local-variable 'web-mode-auto-pairs) (make-local-variable 'web-mode-block-regexp) (make-local-variable 'web-mode-change-beg) (make-local-variable 'web-mode-change-end) (make-local-variable 'web-mode-code-indent-offset) (make-local-variable 'web-mode-column-overlays) (make-local-variable 'web-mode-comment-formats) (make-local-variable 'web-mode-comment-style) (make-local-variable 'web-mode-content-type) (make-local-variable 'web-mode-css-indent-offset) (make-local-variable 'web-mode-display-table) (make-local-variable 'web-mode-django-control-blocks) (make-local-variable 'web-mode-django-control-blocks-regexp) (make-local-variable 'web-mode-enable-block-face) (make-local-variable 'web-mode-enable-inlays) (make-local-variable 'web-mode-enable-part-face) (make-local-variable 'web-mode-enable-sexp-functions) (make-local-variable 'web-mode-engine) (make-local-variable 'web-mode-engine-attr-regexp) (make-local-variable 'web-mode-engine-file-regexps) (make-local-variable 'web-mode-engine-open-delimiter-regexps) (make-local-variable 'web-mode-engine-token-regexp) (make-local-variable 'web-mode-expand-initial-pos) (make-local-variable 'web-mode-expand-initial-scroll) (make-local-variable 'web-mode-expand-previous-state) (make-local-variable 'web-mode-indent-style) (make-local-variable 'web-mode-indentless-attributes) (make-local-variable 'web-mode-indentless-elements) (make-local-variable 'web-mode-is-scratch) (make-local-variable 'web-mode-skip-fontification) (make-local-variable 'web-mode-jshint-errors) (make-local-variable 'web-mode-last-enabled-feature) (make-local-variable 'web-mode-markup-indent-offset) (make-local-variable 'web-mode-minor-engine) (make-local-variable 'web-mode-overlay-tag-end) (make-local-variable 'web-mode-overlay-tag-start) (make-local-variable 'web-mode-part-beg) (make-local-variable 'web-mode-scan-beg) (make-local-variable 'web-mode-scan-end) (make-local-variable 'web-mode-sql-indent-offset) (make-local-variable 'web-mode-time) (make-local-variable 'web-mode-trace) (make-local-variable 'font-lock-beg) (make-local-variable 'font-lock-end) (make-local-variable 'comment-end) (make-local-variable 'comment-region-function) (make-local-variable 'comment-start) (make-local-variable 'fill-paragraph-function) (make-local-variable 'font-lock-defaults) (make-local-variable 'font-lock-extend-region-functions) (make-local-variable 'font-lock-support-mode) (make-local-variable 'font-lock-unfontify-region-function) (make-local-variable 'imenu-case-fold-search) (make-local-variable 'imenu-create-index-function) (make-local-variable 'imenu-generic-expression) (make-local-variable 'indent-line-function) (make-local-variable 'parse-sexp-lookup-properties) (make-local-variable 'uncomment-region-function) (make-local-variable 'yank-excluded-properties) (setq web-mode-time (current-time)) (setq comment-end "-->" comment-region-function 'web-mode-comment-or-uncomment-region comment-start "")) ((string= sub1 "<") (setq closing-string ">" delim-open "")) ((string= sub1 "[") (setq closing-string "]" delim-open "\\[/?[#@]" delim-close "/?\\]")) (t (setq closing-string "}" delim-open "${" delim-close "}")) ) ) ;freemarker ((string= web-mode-engine "velocity") (cond ((string= sub2 "##") (setq closing-string "EOL")) ((string= sub2 "#*") (setq closing-string "*#")) (t (setq closing-string "EOV" delim-open "#")) ) ) ;velocity ((string= web-mode-engine "razor") (cond ((string= sub2 "@@") (forward-char 2) (setq closing-string nil)) ((string= sub2 "@*") (setq closing-string "*@")) ((string= sub1 "@") (setq closing-string "EOR" delim-open "@")) ((and (string= sub1 "}") (looking-at-p "[ ]*\n")) ;;(setq closing-string "EOC") (save-excursion (let (paren-pos) (setq paren-pos (web-mode-part-opening-paren-position (1- (point)))) (if (and paren-pos (get-text-property paren-pos 'block-side)) (setq closing-string "EOC") (setq closing-string nil) ) ;if ) ;let ) ;save-excursion ;;(message "%s %S %S" sub2 (point) (get-text-property (point) 'part-side)) ) ((string= sub1 "}") ;;(message "%s: %s" (point) sub1) (save-excursion (let (paren-pos) (setq paren-pos (web-mode-part-opening-paren-position (1- (point)))) (if (and paren-pos (get-text-property paren-pos 'block-side)) (setq closing-string "EOR") (setq closing-string nil) ) ;if ) ;let ) ;save-excursion ) ;case } ) ;cond ) ;razor ((and (string= web-mode-engine "riot") (not (get-text-property open 'part-side))) (setq closing-string (if (string= tagopen "{") "}" "/// end script") delim-open "{" delim-close "}") ) ;riot ((string= web-mode-engine "spip") (cond ((and (string= sub1 "#") (looking-at "[A-Z0-9_]+")) (setq closing-string (match-string-no-properties 0))) ((string= sub1 "(") (setq closing-string '("(" . ")"))) ((string= sub1 "{") (setq closing-string '("{" . "}"))) ((string= sub2 "<:") (setq closing-string ":>")) (t (setq closing-string "]")) )) ((string= web-mode-engine "marko") (setq closing-string "}" delim-open "${" delim-close "}") ) ;marko ) ;cond (when closing-string (cond ((listp closing-string) (cond ((web-mode-rsf-balanced (car closing-string) (cdr closing-string) reg-end t) (setq close (match-end 0) pos (point)) ) ((and (string= web-mode-engine "php") (string= " (point) reg-end) reg-end (point)) pos (if (> (point) reg-end) reg-end (point))) (goto-char pos)) ((string= closing-string "EOV") (web-mode-velocity-skip open) (setq close (point) pos (point))) ((and (member web-mode-engine '("ctemplate")) (re-search-forward closing-string reg-end t)) (setq close (match-end 0) pos (point))) ((search-forward closing-string reg-end t) (setq close (match-end 0) pos (point))) ) ;cond (when (and close (>= reg-end pos)) ;;(message "pos(%S) : open(%S) close(%S)" pos open close) (put-text-property open (1+ open) 'block-beg 0) (put-text-property open (1+ open) 'block-controls 0) (put-text-property open close 'block-side t) (put-text-property (1- close) close 'block-end t) (when delim-open (web-mode-block-delimiters-set open close delim-open delim-close)) (web-mode-block-scan open close) (cond ((and (string= web-mode-engine "erb") (looking-at-p "<%= javascript_tag do %>")) (setq tagopen "<%= javascript_tag do %>")) ((and (string= web-mode-engine "mojolicious") (looking-at-p "%= javascript begin")) (setq tagopen "%= javascript begin")) ((and (string= web-mode-engine "mako") (looking-at-p "<%block filter=\"collect_js\">")) (setq tagopen "<%block filter=\"collect_js\">")) ((and (string= web-mode-engine "mako") (looking-at-p "<%block filter=\"collect_css\">")) (setq tagopen "<%block filter=\"collect_css\">")) ((and (string= web-mode-engine "django") (looking-at-p "{% javascript %}")) (setq tagopen "{% javascript %}")) ((and (string= web-mode-engine "django") (looking-at-p "{% schema %}")) (setq tagopen "{% schema %}")) ((and (string= web-mode-engine "django") (looking-at-p "{% stylesheet %}")) (setq tagopen "{% stylesheet %}")) ) ;;(message "%S %s" (point) tagopen) (when (and (member tagopen '("" "<%block filter=\"collect_js\">" "<%block filter=\"collect_css\">" "{% javascript %}" "{% schema %}" "{% stylesheet %}" "%= javascript begin")) (setq part-beg close) (setq tagclose (cond ((string= tagopen "") "<% end %>") ((member tagopen '("<%block filter=\"collect_js\">" "<%block filter=\"collect_css\">")) " part-end part-beg)) ;;(message "end=%S" (point)) (put-text-property part-beg part-end 'part-side (cond ((member tagopen '("" "{% stylesheet %}")) 'css) (t 'javascript))) (setq pos part-beg part-beg nil part-end nil) ) ;when ) ;when close (if pos (goto-char pos)) ) ;when closing-string ) ;while (cond ((>= i 2000) (message "scan-blocks ** warning (%S) **" i)) ((string= web-mode-engine "razor") (web-mode-block-foreach reg-beg reg-end 'web-mode-block-scan)) ((string= web-mode-engine "django") (web-mode-scan-engine-comments reg-beg reg-end "{% comment %}" "{% endcomment %}")) ((string= web-mode-engine "mako") (web-mode-scan-engine-comments reg-beg reg-end "<%doc>" "")) ((string= web-mode-engine "mason") (web-mode-scan-engine-comments reg-beg reg-end "<%doc>" "")) ) ;cond ))) (defun web-mode-scan-engine-comments (reg-beg reg-end tag-start tag-end) "Scan engine comments (mako, django)." (save-excursion (let (beg end (continue t)) (goto-char reg-beg) (while (and continue (< (point) reg-end) (re-search-forward tag-start reg-end t)) (goto-char (match-beginning 0)) (setq beg (point)) (if (not (re-search-forward tag-end reg-end t)) (setq continue nil) (setq end (point)) (remove-list-of-text-properties beg end web-mode-scan-properties) (add-text-properties beg end '(block-side t block-token comment)) (put-text-property beg (1+ beg) 'block-beg 0) (put-text-property (1- end) end 'block-end t) ) ;if ) ;while ))) (defun web-mode-closure-skip (reg-beg reg-end) (let (regexp char pos inc continue found) (setq regexp "[\"'{}]" inc 0) (while (and (not found) (re-search-forward regexp reg-end t)) (setq char (char-before)) (cond ((get-text-property (point) 'block-side) (setq found t)) ((eq char ?\{) (setq inc (1+ inc))) ((eq char ?\}) (cond ((and (not (eobp)) (< inc 1)) (setq found t pos (point))) ((> inc 0) (setq inc (1- inc))) ) ) ((eq char ?\') (setq continue t) (while (and continue (search-forward "'" reg-end t)) (setq continue (web-mode-string-continue-p reg-beg)) ) ) ((eq char ?\") (setq continue t) (while (and continue (search-forward "\"" reg-end t)) (setq continue (web-mode-string-continue-p reg-beg)) ) ) ) ;cond ) ;while pos)) (defun web-mode-django-skip (reg-beg reg-end) (let (regexp char pos inc continue found) (setq regexp "[\"'{}]" inc 0) (while (and (not found) (re-search-forward regexp reg-end t)) (setq char (char-before)) (cond ((get-text-property (point) 'block-side) (setq found t)) ((eq char ?\{) (setq inc (1+ inc))) ((eq char ?\}) (cond ((and (not (eobp)) (eq (char-after) ?\}) (< inc 2)) (forward-char) (setq found t pos (1+ (point)))) ((> inc 0) (setq inc (1- inc))) ) ) ((eq char ?\') (setq continue t) (while (and continue (search-forward "'" reg-end t)) (setq continue (web-mode-string-continue-p reg-beg)) ) ) ((eq char ?\") (setq continue t) (while (and continue (search-forward "\"" reg-end t)) (setq continue (web-mode-string-continue-p reg-beg)) ) ) ) ;cond ) ;while pos)) (defun web-mode-blade-skip (pos) (goto-char pos) (forward-char) (skip-chars-forward "a-zA-Z0-9_-")) (defun web-mode-velocity-skip (pos) (goto-char pos) (let ((continue t) (i 0)) (when (eq ?\# (char-after)) (forward-char)) (when (member (char-after) '(?\$ ?\@)) (forward-char)) (when (member (char-after) '(?\!)) (forward-char)) (cond ((member (char-after) '(?\{)) (search-forward "}" nil t)) ((looking-at-p "def \\|define ") (search-forward ")" (line-end-position) t)) (t (setq continue t) (while continue (skip-chars-forward "a-zA-Z0-9_-") (when (> (setq i (1+ i)) 500) (message "velocity-skip ** warning (%S) **" pos) (setq continue nil)) (when (member (char-after) '(?\()) (search-forward ")" nil t)) (if (member (char-after) '(?\.)) (forward-char) (setq continue nil)) ) ;while ) ;t ) ;cond )) (defun web-mode-razor-skip (pos) (goto-char pos) (let ((continue t) (i 0)) (while continue (skip-chars-forward " =@a-zA-Z0-9_-") (cond ((> (setq i (1+ i)) 500) (message "razor-skip ** warning **") (setq continue nil)) ((and (eq (char-after) ?\*) (eq (char-before) ?@)) (when (not (search-forward "*@" nil t)) (setq continue nil)) ) ((looking-at-p "@[({]") (forward-char) (when (setq pos (web-mode-closing-paren-position (point))) (goto-char pos)) (forward-char) ) ((and (not (eobp)) (eq ?\( (char-after))) (cond ((looking-at-p "[ \n]*[<@]") (setq continue nil)) ((setq pos (web-mode-closing-paren-position)) (goto-char pos) (forward-char)) (t (forward-char)) ) ;cond ) ((and (not (eobp)) (eq ?\< (char-after)) (looking-back "[a-z]" (point-min))) (setq pos (point)) (cond ;; #988 ((search-forward ">" (line-end-position) t) (goto-char pos) (setq continue nil) ) (t (setq continue nil)) ) ;cond ) ((and (not (eobp)) (eq ?\. (char-after))) (forward-char)) ((and (not (eobp)) (looking-at-p "[ \n]*else")) (re-search-forward "[ \t]*else") ) ((looking-at-p "[ \n]*{") (search-forward "{") (search-forward "=>" (point-at-eol) 't) (if (looking-at-p "[ \n]*[<@]") (setq continue nil) (backward-char) (when (setq pos (web-mode-closing-paren-position)) (goto-char pos)) (forward-char) ) ;if ) ((looking-at-p "}") (forward-char)) (t (setq continue nil)) ) ;cond ) ;while )) (defun web-mode-block-delimiters-set (reg-beg reg-end delim-open delim-close) "Set text-property 'block-token to 'delimiter-(beg|end) on block delimiters (e.g. )" ;;(message "reg-beg(%S) reg-end(%S) delim-open(%S) delim-close(%S)" reg-beg reg-end delim-open delim-close) (when (member web-mode-engine '("artanis" "asp" "aspx" "cl-emb" "clip" "closure" "ctemplate" "django" "dust" "elixir" "ejs" "erb" "expressionengine" "freemarker" "go" "hero" "jsp" "lsp" "mako" "mason" "mojolicious" "smarty" "template-toolkit" "web2py" "xoops" "svelte")) (save-excursion (when delim-open (goto-char reg-beg) (looking-at delim-open) (setq delim-open (match-string-no-properties 0))) (when delim-close (goto-char reg-end) (looking-back delim-close reg-beg t) (setq delim-close (match-string-no-properties 0))) )) (when delim-open (put-text-property reg-beg (+ reg-beg (length delim-open)) 'block-token 'delimiter-beg)) (when delim-close (put-text-property (- reg-end (length delim-close)) reg-end 'block-token 'delimiter-end)) ) (defun web-mode-block-foreach (reg-beg reg-end func) (let ((i 0) (continue t) (block-beg reg-beg) (block-end nil)) (while continue (setq block-end nil) (unless (get-text-property block-beg 'block-beg) (setq block-beg (web-mode-block-next-position block-beg))) (when (and block-beg (< block-beg reg-end)) (setq block-end (web-mode-block-end-position block-beg))) (cond ((> (setq i (1+ i)) 2000) (message "process-blocks ** warning (%S) **" (point)) (setq continue nil)) ((or (null block-end) (> block-end reg-end)) (setq continue nil)) (t (setq block-end (1+ block-end)) (funcall func block-beg block-end) (setq block-beg block-end) ) ;t ) ;cond ) ;while )) (defun web-mode-block-scan (block-beg block-end) (let (sub1 sub2 sub3 regexp token-type) ;;(message "block-beg=%S block-end=%S" block-beg block-end) ;;(remove-text-properties block-beg block-end web-mode-scan-properties) (goto-char block-beg) (cond ((>= (point-max) (+ block-beg 3)) (setq sub3 (buffer-substring-no-properties block-beg (+ block-beg 3)) sub2 (buffer-substring-no-properties block-beg (+ block-beg 2)) sub1 (buffer-substring-no-properties block-beg (+ block-beg 1))) ) ((>= (point-max) (+ block-beg 2)) (setq sub3 (buffer-substring-no-properties block-beg (+ block-beg 2)) sub2 (buffer-substring-no-properties block-beg (+ block-beg 2)) sub1 (buffer-substring-no-properties block-beg (+ block-beg 1))) ) (t (setq sub1 (buffer-substring-no-properties block-beg (+ block-beg 1))) (setq sub2 sub1 sub3 sub1) ) ) (cond ((member web-mode-engine '("php" "lsp" "python" "web2py" "mason")) (setq regexp web-mode-engine-token-regexp)) ((string= web-mode-engine "mako") (cond ((string= sub2 "##") (setq token-type 'comment) ) (t (setq regexp web-mode-engine-token-regexp)) ) ) ;mako ((string= web-mode-engine "django") (cond ((member sub2 '("{{" "{%")) (setq regexp "\"\\|'")) ((string= sub2 "{#") (setq token-type 'comment)) ) ) ;django ((string= web-mode-engine "ctemplate") (cond ((string= sub3 "{{!") (setq token-type 'comment)) ((member sub2 '("{{")) ) ) ) ;ctemplate ((string= web-mode-engine "go") (cond ((string= sub3 "{{/") (setq token-type 'comment)) ((string= sub2 "{{") (setq regexp "\"\\|'")) ) ) ;go ((string= web-mode-engine "hero") (cond ((string= sub3 "<%#") (setq token-type 'comment)) (t (setq regexp "\"\\|'")) ) ) ;hero ((string= web-mode-engine "razor") (cond ((string= sub2 "@*") (setq token-type 'comment)) (t (setq regexp "//\\|@\\*\\|\"\\|'")) ) ) ;razor ((string= web-mode-engine "blade") (cond ((string= sub3 "{{-") (setq token-type 'comment)) (t (setq regexp "\"\\|'")) ) ) ;blade ((string= web-mode-engine "cl-emb") (cond ((string= sub3 "<%#") (setq token-type 'comment)) (t (setq regexp "\"\\|'")) ) ) ;cl-emb ((string= web-mode-engine "artanis") (cond ((string= sub3 "<%;") (setq token-type 'comment)) ((string= sub3 "<%#|") (setq token-type 'comment)) (t (setq regexp "\"")) ) ) ;artanis ((string= web-mode-engine "elixir") (cond ((string= sub3 "<%#") (setq token-type 'comment)) (t (setq regexp "\"\\|'")) ) ) ;elixir ((string= web-mode-engine "mojolicious") (cond ((or (string= sub2 "%#") (string= sub3 "<%#")) (setq token-type 'comment)) (t (setq regexp "\"\\|'")) ) ) ;mojolicious ((string= web-mode-engine "velocity") (cond ((member sub2 '("##" "#*")) (setq token-type 'comment)) ((member sub1 '("$" "#")) (setq regexp "\"\\|'")) ) ) ;velocity ((string= web-mode-engine "jsp") (cond ((string= sub3 "<%-") (setq token-type 'comment)) ((string= sub3 "<%@") (setq regexp "/\\*")) ((member sub2 '("${" "#{")) (setq regexp "\"\\|'")) ((string= sub2 "<%") (setq regexp "//\\|/\\*\\|\"\\|'")) ) ) ;jsp ((string= web-mode-engine "clip") (setq regexp nil) ) ;clip ((and (string= web-mode-engine "asp") (string= sub2 "<%")) (setq regexp "//\\|/\\*\\|\"\\|'") ) ;asp ((string= web-mode-engine "aspx") (cond ((string= sub3 "<%-") (setq token-type 'comment)) ((string= sub3 "<%@") (setq regexp "/\\*")) ((string= sub3 "<%$") (setq regexp "\"\\|'")) (t (setq regexp "//\\|/\\*\\|\"\\|'")) ) ) ;aspx ((string= web-mode-engine "freemarker") (cond ((member sub3 '("<#-" "[#-")) (setq token-type 'comment)) ((member sub2 '("${" "#{")) (setq regexp "\"\\|'")) ((or (member sub2 '("<@" "[@" "<#" "[#")) (member sub3 '(" (- block-end block-beg) 6)) (web-mode-block-tokenize (web-mode-block-code-beginning-position block-beg) (web-mode-block-code-end-position block-beg) regexp) ) ) ;cond )) (defun web-mode-block-tokenize (reg-beg reg-end &optional regexp) (unless regexp (setq regexp web-mode-engine-token-regexp)) ;;(message "tokenize: reg-beg(%S) reg-end(%S) regexp(%S)" reg-beg reg-end regexp) ;;(message "tokenize: reg-beg(%S) reg-end(%S) command(%S)" reg-beg reg-end this-command) ;;(message "%S>%S : %S" reg-beg reg-end (buffer-substring-no-properties reg-beg reg-end)) (save-excursion (let ((pos reg-beg) beg end char match continue (flags 0) token-type token-end) (remove-list-of-text-properties reg-beg reg-end '(block-token)) ;; TODO : vérifier la cohérence (put-text-property reg-beg reg-end 'block-side t) (goto-char reg-beg) (when (> (point) reg-end) (message "block-tokenize ** reg-beg(%S) > reg-end(%S) **" reg-beg reg-end)) (while (and (< (point) reg-end) (re-search-forward regexp reg-end t)) (setq beg (match-beginning 0) match (match-string 0) continue t token-type 'comment token-end (if (< reg-end (line-end-position)) reg-end (line-end-position)) char (aref match 0)) (cond ((and (string= web-mode-engine "asp") (eq char ?\')) (goto-char token-end)) ((and (string= web-mode-engine "razor") (eq char ?\')) (cond ((looking-at-p "\\(.\\|[\\][bfntr]\\|[\\]u....\\)'") (search-forward "'" reg-end t) (setq token-type 'string) ) (t (re-search-forward "[[:alnum:]_-]+") (setq token-type 'symbol) ))) ((eq char ?\') (setq token-type 'string) (while (and continue (search-forward "'" reg-end t)) (setq continue (web-mode-string-continue-p reg-beg)) )) ((eq char ?\") (setq token-type 'string) (while (and continue (search-forward "\"" reg-end t)) (setq continue (web-mode-string-continue-p reg-beg)) )) ((string= match "//") (goto-char token-end)) ((eq char ?\;) (goto-char token-end)) ((string= match "#|") (unless (search-forward "|#" reg-end t) (goto-char token-end))) ((eq char ?\#) (goto-char token-end)) ((string= match "/*") (unless (search-forward "*/" reg-end t) (goto-char token-end)) ) ((string= match "@*") (unless (search-forward "*@" reg-end t) (goto-char token-end))) ((eq char ?\<) (setq token-type 'string) (re-search-forward (concat "^[ ]*" (match-string 1)) reg-end t)) (t (message "block-tokenize ** token end (%S) **" beg) (setq token-type nil)) ) ;cond (put-text-property beg (point) 'block-token token-type) (when (eq token-type 'comment) (put-text-property beg (1+ beg) 'syntax-table (string-to-syntax "<")) (if (or (< (point) (line-end-position)) (= (point) (point-max))) (put-text-property (1- (point)) (point) 'syntax-table (string-to-syntax ">")) ;#445 #480 (put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax ">")) ;#377 ) ) ) ;while (web-mode-block-controls-unset pos) ))) (defun web-mode-set-php-controls (reg-beg reg-end) (goto-char reg-beg) (let (match controls (continue t) (regexp "endif\\|endforeach\\|endfor\\|endwhile\\|elseif\\|else\\|if\\|foreach\\|for\\|while")) (while continue (if (not (web-mode-block-rsf regexp reg-end)) (setq continue nil) (setq match (match-string-no-properties 0)) ;; (message "%S %S" match (point)) (cond ((and (member match '("else" "elseif")) (looking-at-p "[ ]*[:(]")) (setq controls (append controls (list (cons 'inside "if")))) ) ((and (>= (length match) 3) (string= (substring match 0 3) "end")) (setq controls (append controls (list (cons 'close (substring match 3))))) ) ((and (progn (skip-chars-forward "[ ]") t) (eq (char-after) ?\() (web-mode-closing-paren reg-end) ;;(progn (message "ixi%S" (point))) (looking-at-p ")[ ]*:")) (setq controls (append controls (list (cons 'open match)))) ) ) ;cond ) ;if ) ;while ;;(message "%S-%S %S" reg-beg reg-end controls) (when (and controls (> (length controls) 1)) (setq controls (web-mode-block-controls-reduce controls))) controls)) (defun web-mode-block-controls-reduce (controls) (when (and (eq (car (car controls)) 'open) (member (cons 'close (cdr (car controls))) controls)) (setq controls nil)) controls) (defun web-mode-block-controls-unset (pos) (cond ((null (get-text-property pos 'block-side)) (message "block-controls-unset ** invalid value (%S) **" pos)) ((or (get-text-property pos 'block-beg) (setq pos (web-mode-block-beginning-position pos))) (put-text-property pos (1+ pos) 'block-controls 0)) (t (message "block-controls-unset ** failure (%S) **" (point))) )) (defun web-mode-block-controls-get (pos) (web-mode-with-silent-modifications (let ((controls nil)) (cond ((null (get-text-property pos 'block-side)) (message "block-controls-get ** invalid value (%S) **" pos)) ((or (get-text-property pos 'block-beg) (setq pos (web-mode-block-beginning-position pos))) (setq controls (get-text-property pos 'block-controls)) (when (integerp controls) (web-mode-block-controls-set pos (web-mode-block-end-position pos)) (setq controls (get-text-property pos 'block-controls)) ) ) (t (message "block-controls-get ** failure (%S) **" (point))) ) ;cond controls))) (defun web-mode-block-controls-set (reg-beg reg-end) (save-excursion (goto-char reg-beg) (let (controls pos type control) (cond ((null web-mode-engine) (message "block-controls-set ** unknown engine (%S) **" web-mode-engine) ) ((string= web-mode-engine "php") (setq controls (web-mode-set-php-controls reg-beg reg-end)) (when (web-mode-block-starts-with "}" reg-beg) (setq controls (append controls (list (cons 'close "{"))))) (when (web-mode-block-ends-with (cons "{" "}") reg-beg) (setq controls (append controls (list (cons 'open "{"))))) ) ;php ((string= web-mode-engine "ejs") (cond ((web-mode-block-ends-with "}[ ]*else[ ]*{" reg-beg) (setq controls (append controls (list (cons 'inside "{"))))) ((web-mode-block-starts-with "}" reg-beg) (setq controls (append controls (list (cons 'close "{"))))) ((web-mode-block-ends-with "{" reg-beg) (setq controls (append controls (list (cons 'open "{"))))) ) ) ;ejs ((string= web-mode-engine "erb") (cond ((web-mode-block-starts-with "else\\|elsif\\|when" reg-beg) (setq controls (append controls (list (cons 'inside "ctrl"))))) ((web-mode-block-starts-with "end" reg-beg) (setq controls (append controls (list (cons 'close "ctrl"))))) ((web-mode-block-ends-with " do\\( |.*|\\)?" reg-beg) (setq controls (append controls (list (cons 'open "ctrl"))))) ((and (web-mode-block-starts-with "\\(for\\|if\\|unless\\|case\\)\\_>" reg-beg) (not (web-mode-block-ends-with "end" reg-end))) (setq controls (append controls (list (cons 'open "ctrl"))))) ) ) ;erb ((string= web-mode-engine "django") (cond ((and (string= web-mode-minor-engine "jinja") ;#504 (web-mode-block-starts-with "else\\_>" reg-beg)) (let ((continue t) (pos reg-beg) (ctrl nil)) (while continue (cond ((null (setq pos (web-mode-block-control-previous-position 'open pos))) (setq continue nil)) ((member (setq ctrl (cdr (car (get-text-property pos 'block-controls)))) '("if" "ifequal" "ifnotequal" "for")) (setq continue nil) ) ) ;cond ) (setq controls (append controls (list (cons 'inside (or ctrl "if"))))) ) ) ((web-mode-block-starts-with "form_start[ ]*(" reg-beg) (setq controls (append controls (list (cons 'open "form_start"))))) ((web-mode-block-starts-with "form_end[ ]*(" reg-beg) (setq controls (append controls (list (cons 'close "form_start"))))) ((not (eq (char-after (1+ reg-beg)) ?\%)) ) ((web-mode-block-starts-with "\\(else\\|els?if\\)" reg-beg) (let ((continue t) (pos reg-beg) (ctrl nil)) (while continue (cond ((null (setq pos (web-mode-block-control-previous-position 'open pos))) (setq continue nil)) ((member (setq ctrl (cdr (car (get-text-property pos 'block-controls)))) '("if" "ifequal" "ifnotequal")) (setq continue nil) ) ) ;cond ) ;while (setq controls (append controls (list (cons 'inside (or ctrl "if"))))) ) ;let ) ;case else ((web-mode-block-starts-with "\\(empty\\)" reg-beg) (setq controls (append controls (list (cons 'inside "for"))))) ((web-mode-block-starts-with "end\\([[:alpha:]]+\\)" reg-beg) (setq controls (append controls (list (cons 'close (match-string-no-properties 1)))))) ((web-mode-block-starts-with (concat web-mode-django-control-blocks-regexp "[ %]") reg-beg) (let (control) (setq control (match-string-no-properties 1)) ;;(message "%S %S %S" control (concat "end" control) web-mode-django-control-blocks) (when (member (concat "end" control) web-mode-django-control-blocks) (setq controls (append controls (list (cons 'open control)))) ) ;when ) ;let ) ;case ) ;cond ) ;django ((string= web-mode-engine "smarty") (cond ((and (eq (char-after (1+ reg-beg)) ?\/) (web-mode-block-starts-with "\\([[:alpha:]]+\\)" reg-beg)) (setq controls (append controls (list (cons 'close (match-string-no-properties 1)))))) ((web-mode-block-starts-with "\\(else\\|elseif\\)" reg-beg) (setq controls (append controls (list (cons 'inside "if"))))) ((web-mode-block-starts-with "\\(block\\|foreach\\|for\\|if\\|section\\|while\\)") (setq controls (append controls (list (cons 'open (match-string-no-properties 1)))))) ) ) ;smarty ((string= web-mode-engine "expressionengine") (cond ((and (eq (char-after (1+ reg-beg)) ?\/) (web-mode-block-starts-with "\\(if\\)" reg-beg)) (setq controls (append controls (list (cons 'close (match-string-no-properties 1)))))) ((web-mode-block-starts-with "\\(if:else\\|if:ifelse\\)" reg-beg) (setq controls (append controls (list (cons 'inside "if"))))) ((web-mode-block-starts-with "\\(if\\)") (setq controls (append controls (list (cons 'open (match-string-no-properties 1)))))) ) ) ;expressionengine ((string= web-mode-engine "xoops") (cond ((and (eq (char-after (+ reg-beg 2)) ?\/) (web-mode-block-starts-with "\\([[:alpha:]]+\\)" reg-beg)) (setq controls (append controls (list (cons 'close (match-string-no-properties 1)))))) ((web-mode-block-starts-with "\\(else\\|elseif\\)" reg-beg) (setq controls (append controls (list (cons 'inside "if"))))) ((web-mode-block-starts-with "\\(block\\|foreach\\|for\\|if\\|section\\|while\\)") (setq controls (append controls (list (cons 'open (match-string-no-properties 1)))))) ) ) ;xoops ((string= web-mode-engine "web2py") (cond ((web-mode-block-starts-with "def" reg-beg) (setq controls (append controls (list (cons 'open "def"))))) ((web-mode-block-starts-with "return" reg-beg) (setq controls (append controls (list (cons 'close "def"))))) ((web-mode-block-starts-with "block" reg-beg) (setq controls (append controls (list (cons 'open "block"))))) ((web-mode-block-starts-with "end" reg-beg) (setq controls (append controls (list (cons 'close "block"))))) ((web-mode-block-starts-with "pass" reg-beg) (setq controls (append controls (list (cons 'close "ctrl"))))) ((web-mode-block-starts-with "\\(except\\|finally\\|els\\)" reg-beg) (setq controls (append controls (list (cons 'inside "ctrl"))))) ((web-mode-block-starts-with "\\(if\\|for\\|try\\|while\\)") (setq controls (append controls (list (cons 'open "ctrl"))))) ) ) ;web2py ((string= web-mode-engine "dust") (cond ((eq (char-after (1- reg-end)) ?\/) ) ((eq (char-after (1+ reg-beg)) ?\:) (setq pos (web-mode-block-control-previous-position 'open reg-beg)) (when pos (setq controls (append controls (list (cons 'inside (cdr (car (web-mode-block-controls-get pos)))))))) ) ((looking-at "{/\\([[:alpha:].]+\\)") (setq controls (append controls (list (cons 'close (match-string-no-properties 1)))))) ((looking-at "{[#?@><+^]\\([[:alpha:].]+\\)") (setq controls (append controls (list (cons 'open (match-string-no-properties 1)))))) ) ) ;dust ((member web-mode-engine '("mojolicious")) (cond ((web-mode-block-ends-with "begin" reg-beg) (setq controls (append controls (list (cons 'open "begin"))))) ((web-mode-block-starts-with "end" reg-beg) (setq controls (append controls (list (cons 'close "begin"))))) ((web-mode-block-starts-with "}[ ]*else[ ]*{" reg-beg) (setq controls (append controls (list (cons 'inside "{"))))) ((web-mode-block-starts-with "}" reg-beg) (setq controls (append controls (list (cons 'close "{"))))) ((web-mode-block-ends-with "{" reg-beg) (setq controls (append controls (list (cons 'open "{"))))) ) ) ;mojolicious ((member web-mode-engine '("aspx" "underscore")) (cond ((and (web-mode-block-starts-with "}" reg-beg) (web-mode-block-ends-with "{" reg-beg)) (setq controls (append controls (list (cons 'inside "{"))))) ((web-mode-block-starts-with "}" reg-beg) (setq controls (append controls (list (cons 'close "{"))))) ((web-mode-block-ends-with "{" reg-beg) (setq controls (append controls (list (cons 'open "{"))))) ) ) ;aspx underscore ((member web-mode-engine '("jsp" "asp" "clip")) (cond ((eq (char-after (1- reg-end)) ?\/) ) ((looking-at "" reg-beg) (setq controls (append controls (list (cons 'close "ctrl"))))) ((web-mode-block-starts-with "else\\_>" reg-beg) (setq controls (append controls (list (cons 'inside "ctrl"))))) ((web-mode-block-starts-with "\\(range\\|with\\|if\\|define\\|block\\)\\_>" reg-beg) (setq controls (append controls (list (cons 'open "ctrl"))))) ) ) ;go ((string= web-mode-engine "template-toolkit") (cond ((web-mode-block-starts-with "end" reg-beg) (setq controls (append controls (list (cons 'close "ctrl"))))) ((web-mode-block-starts-with "els\\|catch\\|final" reg-beg) (setq controls (append controls (list (cons 'inside "ctrl"))))) ((web-mode-block-starts-with "filter\\|foreach\\|if\\|last\\|next\\|perl\\|rawperl\\|try\\|unless\\|while" reg-beg) (setq controls (append controls (list (cons 'open "ctrl"))))) ) ) ;template-toolkit ((string= web-mode-engine "cl-emb") (cond ((web-mode-block-starts-with "@else" reg-beg) (setq controls (append controls (list (cons 'inside "if"))))) ((web-mode-block-starts-with "@\\(?:end\\)?\\(if\\|unless\\|repeat\\|loop\\|with\\|genloop\\)" reg-beg) (setq control (match-string-no-properties 1) type (if (eq (aref (match-string-no-properties 0) 1) ?e) 'close 'open)) (setq controls (append controls (list (cons type control))))) ) ) ;cl-emb ((string= web-mode-engine "elixir") (cond ((web-mode-block-starts-with "end" reg-beg) (setq controls (append controls (list (cons 'close "ctrl"))))) ((web-mode-block-starts-with "else" reg-beg) (setq controls (append controls (list (cons 'inside "ctrl"))))) ((web-mode-block-ends-with " do" reg-beg) (setq controls (append controls (list (cons 'open "ctrl"))))) ((web-mode-block-ends-with " ->" reg-beg) (setq controls (append controls (list (cons 'open "ctrl"))))) ) ) ;elixir ((string= web-mode-engine "velocity") (cond ((web-mode-block-starts-with "{?end" reg-beg) (setq controls (append controls (list (cons 'close "ctrl"))))) ((web-mode-block-starts-with "{?els" reg-beg) (setq controls (append controls (list (cons 'inside "ctrl"))))) ((web-mode-block-starts-with "{?\\(def\\|if\\|for\\|foreach\\|macro\\)" reg-beg) ;;((web-mode-block-starts-with "{?\\(define\\|\\|if\\|for\\|foreach\\|macro\\)" reg-beg) (setq controls (append controls (list (cons 'open "ctrl"))))) ) ) ;velocity ((string= web-mode-engine "freemarker") (cond ((looking-at "[<[]#\\(import\\|include\\|assign\\|return\\|local\\)") ) ((eq (char-after (1- reg-end)) ?\/) ) ((looking-at "[<[]#\\(break\\|case\\|default\\)") (setq controls (append controls (list (cons 'inside "switch")))) ) ((looking-at "[<[]#els") (setq controls (append controls (list (cons 'inside "if")))) ) ((looking-at "<+^]\\([[:alpha:].]+\\)") (setq controls (append controls (list (cons 'open (match-string-no-properties 1)))))) ) ) ;svelte ) ;cond engine (put-text-property reg-beg (1+ reg-beg) 'block-controls controls) ;;(message "(%S) controls=%S" reg-beg controls) ))) (defun web-mode-block-is-opened-sexp (reg-beg reg-end) (let ((n 0)) (save-excursion (goto-char reg-beg) (while (web-mode-block-rsf "[()]" reg-end) (if (eq (char-before) ?\() (setq n (1+ n)) (setq n (1- n))))) (> n 0))) ;;---- LEXER PARTS ------------------------------------------------------------- ;; FLAGS: tag ;; (1)attrs (2)custom (4)slash-beg (8)slash-end (16)bracket-end ;; (32)namespaced (defun web-mode-scan-elements (reg-beg reg-end) (save-excursion (let (part-beg part-end flags limit close-expr props tname tbeg tend element-content-type (regexp web-mode-dom-regexp) part-close-tag char) ;;(message "scan-elements: reg-beg(%S) reg-end(%S)" reg-beg reg-end) (goto-char reg-beg) (while (web-mode-dom-rsf regexp reg-end) ;;(message "%S: %S (%S %S)" (point) (match-string-no-properties 0) reg-beg reg-end) (setq flags 0 tname (downcase (match-string-no-properties 1)) char (aref tname 0) tbeg (match-beginning 0) tend nil element-content-type nil limit reg-end part-beg nil part-end nil props nil close-expr nil part-close-tag nil) ;;(message "tname[%S] tbeg(%S) point(%S)" tname tbeg (point)) (cond ((member tname '("/>" ">")) ;;jsx fragment #952 (setq tname "_fragment_" tend (point)) (if (eq char ?\/) (setq props (list 'tag-name tname 'tag-type 'end) flags (logior flags 20)) ;; 16 + 4 (setq props (list 'tag-name tname 'tag-type 'start) flags (logior flags 16)) ) ;if ) ((not (member char '(?\! ?\?))) (cond ((string-match-p "-" tname) (setq flags (logior flags 2))) ((string-match-p ":" tname) (setq flags (logior flags 32))) ) (cond ((eq char ?\/) (setq props (list 'tag-name (substring tname 1) 'tag-type 'end) flags (logior flags 4) limit (if (> reg-end (line-end-position)) (line-end-position) reg-end)) ) ((web-mode-element-is-void tname) ;;(message "void: tag=%S" tname) (setq props (list 'tag-name tname 'tag-type 'void))) (t (setq props (list 'tag-name tname 'tag-type 'start))) ) ;cond ) ; not " props '(tag-type comment))) ((string= tname "?xml") (setq ;;regexp web-mode-tag-regexp2 close-expr "?>" props '(tag-type declaration))) ((string= tname "![cdata[") (setq close-expr "]]>" props '(tag-type cdata))) ((string= tname "!doctype") (setq ;;regexp web-mode-tag-regexp2 props '(tag-type doctype))) ) ;cond - special tags (cond (tend ) ((and (null close-expr) (eq (char-after) ?\>)) (setq flags (logior flags 16) tend (1+ (point))) ;;(message "end=%S" tend) ) ((and (null close-expr) (looking-at "[ ]\\(class\\|id\\|href\\|style\\)=\"[[:alnum:]_=:/?;#. -]*\">")) (let ((beg (1+ (point))) (end (+ (point) (length (match-string-no-properties 0))))) (setq flags (logior flags 17) tend end) (put-text-property beg (1+ beg) 'tag-attr-beg 0) (put-text-property beg (1- end) 'tag-attr t) (put-text-property (- end 2) (1- end) 'tag-attr-end (length (match-string-no-properties 1))) ) ;let ) ((null close-expr) (setq flags (logior flags (web-mode-attr-skip reg-end))) (when (> (logand flags 8) 0) (setq props (plist-put props 'tag-type 'void))) (setq tend (point))) ((web-mode-dom-sf close-expr limit t) (setq tend (point))) (t (setq tend (line-end-position))) ) ;cond (cond ((string= tname "style") (let (style) (setq style (buffer-substring-no-properties tbeg tend) part-close-tag "") (cond ((string-match-p " lang[ ]*=[ ]*[\"']stylus" style) (setq element-content-type "stylus")) ((string-match-p " lang[ ]*=[ ]*[\"']sass" style) (setq element-content-type "sass")) (t (setq element-content-type "css")) ) ;cond ) ;let ) ;style ((string= tname "script") (let (script) (setq script (buffer-substring-no-properties tbeg tend) part-close-tag "") (cond ((string-match-p " type[ ]*=[ ]*[\"']text/\\(jsx\\|babel\\)" script) (setq element-content-type "jsx")) ((string-match-p " type[ ]*=[ ]*[\"']text/\\(markdown\\|template\\)" script) (setq element-content-type "markdown")) ((string-match-p " type[ ]*=[ ]*[\"']text/ruby" script) (setq element-content-type "ruby")) ((seq-some (lambda (x) (string-match-p (concat "type[ ]*=[ ]*[\"']" x) script)) web-mode-script-template-types) (setq element-content-type "html" part-close-tag nil)) ((string-match-p " type[ ]*=[ ]*[\"']application/\\(ld\\+json\\|json\\)" script) (setq element-content-type "json")) ((string-match-p " lang[ ]*=[ ]*[\"']\\(typescript\\|ts\\)" script) (setq element-content-type "typescript")) (t (setq element-content-type "javascript")) ) ;cond ) ;let ) ;script ((and (string= tname "template") (string-match-p " lang" (buffer-substring-no-properties tbeg tend))) (let (template) (setq template (buffer-substring-no-properties tbeg tend) part-close-tag "") (cond ((string-match-p " lang[ ]*=[ ]*[\"']pug" template) (setq element-content-type "pug")) (t (setq element-content-type "html")) ) ;cond ) ;let ) ;style ((and (string= web-mode-engine "archibus") (string= tname "sql")) (setq element-content-type "sql" part-close-tag "")) ) (add-text-properties tbeg tend props) (put-text-property tbeg (1+ tbeg) 'tag-beg flags) (put-text-property (1- tend) tend 'tag-end t) (when (and part-close-tag (web-mode-dom-sf part-close-tag reg-end t) (setq part-beg tend) (setq part-end (match-beginning 0)) (> part-end part-beg)) (put-text-property part-beg part-end 'part-side (intern element-content-type web-mode-obarray)) (setq tend part-end) ) ;when (goto-char tend) ) ;while ))) ;; FLAGS: attr ;; (1)custom-attr (2)engine-attr (4)spread-attr[jsx] (8)code-value ;; STATES: attr ;; (0)nil (1)space (2)name (3)space-before (4)equal (5)space-after ;; (6)value-uq (7)value-sq (8)value-dq (9)value-bq : jsx attr={} (defun web-mode-attr-skip (limit) (let ((tag-flags 0) (attr-flags 0) (continue t) (attrs 0) (counter 0) (brace-depth 0) (pos-ori (point)) (state 0) (equal-offset 0) (go-back nil) (is-jsx (or (string= web-mode-content-type "jsx") (eq (get-text-property (point) 'part-type) 'jsx))) attr name-beg name-end val-beg char pos escaped spaced quoted) (while continue (setq pos (point) char (char-after) ;;spaced (eq char ?\s) spaced (member char '(?\s ?\n)) ) (when quoted (setq quoted (1+ quoted))) (cond ((>= pos limit) (setq continue nil) (setq go-back t) (setq attrs (+ attrs (web-mode-attr-scan state char name-beg name-end val-beg attr-flags equal-offset))) ) ((or (and (= state 8) (not (member char '(?\" ?\\)))) (and (= state 7) (not (member char '(?\' ?\\)))) (and (= state 9) (not (member char '(?} ?\\)))) ) (when (and (= state 9) (eq char ?\{)) (setq brace-depth (1+ brace-depth))) ) ((and (= state 9) (eq char ?\}) (> brace-depth 1)) (setq brace-depth (1- brace-depth))) ((get-text-property pos 'block-side) (when (= state 2) (setq name-end pos)) ) ((and (= state 2) is-jsx (eq char ?\}) (eq attr-flags 4)) (setq name-end pos) (setq attrs (+ attrs (web-mode-attr-scan state char name-beg name-end val-beg attr-flags equal-offset))) (setq state 0 attr-flags 0 equal-offset 0 name-beg nil name-end nil val-beg nil) ) ((or (and (= state 8) (eq ?\" char) (not escaped)) (and (= state 7) (eq ?\' char) (not escaped)) (and (= state 9) (eq ?\} char) (= brace-depth 1)) ) ;;(message "%S %S" (point) attr-flags) (setq attrs (+ attrs (web-mode-attr-scan state char name-beg name-end val-beg attr-flags equal-offset))) (setq state 0 attr-flags 0 equal-offset 0 name-beg nil name-end nil val-beg nil) ) ((and (member state '(4 5)) (member char '(?\' ?\" ?\{))) (setq val-beg pos) (setq quoted 1) (setq state (cond ((eq ?\' char) 7) ((eq ?\" char) 8) (t 9))) (when (= state 9) (setq brace-depth 1)) ) ((and (eq ?\= char) (member state '(2 3))) (setq equal-offset (- pos name-beg) name-end (1- pos)) (setq state 4) (setq attr (buffer-substring-no-properties name-beg (1+ name-end))) (when (and web-mode-indentless-attributes (member (downcase attr) web-mode-indentless-attributes)) ;;(message "onclick") (setq attr-flags (logior attr-flags 8))) ) ((and spaced (= state 0)) (setq state 1) ) ((and (eq char ?\<) (not (member state '(7 8 9)))) (setq continue nil) (setq go-back t) (setq attrs (+ attrs (web-mode-attr-scan state char name-beg name-end val-beg attr-flags equal-offset))) ) ((and (eq char ?\>) (not (member state '(7 8 9)))) (setq tag-flags (logior tag-flags 16)) (when (eq (char-before) ?\/) (setq tag-flags (logior tag-flags 8)) ) (setq continue nil) (when name-beg (setq attrs (+ attrs (web-mode-attr-scan state char name-beg name-end val-beg attr-flags equal-offset)))) ) ((and spaced (member state '(1 3 5))) ) ((and spaced (= state 2)) (setq state 3) ) ((and (eq char ?\/) (member state '(4 5))) (setq attrs (+ attrs (web-mode-attr-scan state char name-beg name-end val-beg attr-flags equal-offset))) (setq state 1 attr-flags 0 equal-offset 0 name-beg nil name-end nil val-beg nil) ) ((and (eq char ?\/) (member state '(0 1))) ) ((and spaced (= state 4)) (setq state 5) ) ((and (= state 3) (or (and (>= char 97) (<= char 122)) ;a - z (and (>= char 65) (<= char 90)) ;A - Z (eq char ?\-))) (setq attrs (+ attrs (web-mode-attr-scan state char name-beg name-end val-beg attr-flags equal-offset))) (setq state 2 attr-flags 0 equal-offset 0 name-beg pos name-end pos val-beg nil) ) ((and (eq char ?\n) (not (member state '(7 8 9)))) (setq attrs (+ attrs (web-mode-attr-scan state char name-beg name-end val-beg attr-flags equal-offset))) (setq state 1 attr-flags 0 equal-offset 0 name-beg nil name-end nil val-beg nil) ) ((and (= state 6) (member char '(?\s ?\n ?\/))) (setq attrs (+ attrs (web-mode-attr-scan state char name-beg name-end val-beg attr-flags equal-offset))) (setq state 1 attr-flags 0 equal-offset 0 name-beg nil name-end nil val-beg nil) ) ((and quoted (= quoted 2) (member char '(?\s ?\n ?\>))) (when (eq char ?\>) (setq tag-flags (logior tag-flags 16)) (setq continue nil)) (setq state 6) (setq attrs (+ attrs (web-mode-attr-scan state char name-beg name-end val-beg attr-flags equal-offset))) (setq state 1 attr-flags 0 equal-offset 0 name-beg nil name-end nil val-beg nil) ) ((and (not spaced) (= state 1)) (when (and is-jsx (eq char ?\{)) (setq attr-flags 4)) (setq state 2) (setq name-beg pos name-end pos) ) ((member state '(4 5)) (setq val-beg pos) (setq state 6) ) ((= state 1) (setq state 2) ) ((= state 2) (setq name-end pos) (when (and nil (= attr-flags 0) (member char '(?\- ?\:))) (let (attr) (setq attr (buffer-substring-no-properties name-beg (1+ name-end))) (cond ((member attr '("http-equiv")) (setq attr-flags (1- attr-flags)) ) ;;((and web-mode-engine-attr-regexp ;; (string-match-p web-mode-engine-attr-regexp attr)) ;; (setq attr-flags (logior attr-flags 2)) ;; ) ((and (eq char ?\-) (not (string= attr "http-"))) (setq attr-flags (logior attr-flags 1))) ) ;cond ) ;let ) ;when attr-flags = 1 ) ;state=2 ) ;cond ;;(message "point(%S) end(%S) state(%S) c(%S) name-beg(%S) name-end(%S) val-beg(%S) attr-flags(%S) equal-offset(%S)" pos end state char name-beg name-end val-beg attr-flags equal-offset) (when (and quoted (>= quoted 2)) (setq quoted nil)) (setq escaped (eq ?\\ char)) (when (null go-back) (forward-char)) ) ;while (when (> attrs 0) (setq tag-flags (logior tag-flags 1))) tag-flags)) (defun web-mode-attr-scan (state char name-beg name-end val-beg flags equal-offset) ;;(message "point(%S) state(%S) c(%c) name-beg(%S) name-end(%S) val-beg(%S) flags(%S) equal-offset(%S)" ;; (point) state char name-beg name-end val-beg flags equal-offset) (when (null flags) (setq flags 0)) (when (and name-beg name-end web-mode-engine-attr-regexp) (let (name) (setq name (buffer-substring-no-properties name-beg (1+ name-end))) ;;(message "%S" name) (cond ((string-match-p "^data[-]" name) (setq flags (logior flags 1)) ) ((string-match-p web-mode-engine-attr-regexp name) (setq flags (logior flags 2)) ) ) ) ;name ) ;;(message "%S" name) (cond ((null name-beg) ;; (message "name-beg is null (%S)" (point)) 0) ((or (and (= state 8) (not (eq ?\" char))) (and (= state 7) (not (eq ?\' char)))) (put-text-property name-beg (1+ name-beg) 'tag-attr-beg flags) (put-text-property name-beg val-beg 'tag-attr t) (put-text-property (1- val-beg) val-beg 'tag-attr-end equal-offset) 1) ((and (member state '(4 5)) (null val-beg)) (put-text-property name-beg (1+ name-beg) 'tag-attr-beg flags) (put-text-property name-beg (+ name-beg equal-offset 1) 'tag-attr t) (put-text-property (+ name-beg equal-offset) (+ name-beg equal-offset 1) 'tag-attr-end equal-offset) 1) (t (let (val-end) (if (null val-beg) (setq val-end name-end) (setq val-end (point)) (when (or (null char) (member char '(?\s ?\n ?\> ?\/))) (setq val-end (1- val-end)) ) ) ;if (put-text-property name-beg (1+ name-beg) 'tag-attr-beg flags) (put-text-property name-beg (1+ val-end) 'tag-attr t) (put-text-property val-end (1+ val-end) 'tag-attr-end equal-offset) ) ;let 1) ;t ) ;cond ) (defun web-mode-part-foreach (reg-beg reg-end func) (let ((i 0) (continue t) (part-beg reg-beg) (part-end nil)) (while continue (setq part-end nil) (unless (get-text-property part-beg 'part-side) (setq part-beg (web-mode-part-next-position part-beg))) (when (and part-beg (< part-beg reg-end)) (setq part-end (web-mode-part-end-position part-beg))) (cond ((> (setq i (1+ i)) 100) (message "process-parts ** warning (%S) **" (point)) (setq continue nil)) ((or (null part-end) (> part-end reg-end)) (setq continue nil)) (t (setq part-end (1+ part-end)) (funcall func part-beg part-end) (setq part-beg part-end)) ) ;cond ) ;while )) (defun web-mode-part-scan (reg-beg reg-end &optional content-type depth) (save-excursion (let (token-re ch-before ch-at ch-next token-type beg continue) ;;(message "%S %S" reg-beg reg-end) (cond (content-type ) ((member web-mode-content-type web-mode-part-content-types) (setq content-type web-mode-content-type)) (t (setq content-type (symbol-name (get-text-property reg-beg 'part-side)))) ) ;cond (goto-char reg-beg) (cond ((member content-type '("javascript" "json")) (setq token-re "/\\|\"\\|'\\|`")) ((member content-type '("typescript")) (setq token-re "\"\\|'\\|`\\|//\\|/\\*")) ((member content-type '("jsx")) (setq token-re "/\\|\"\\|'\\|`\\|]")) ((string= web-mode-content-type "css") (setq token-re "\"\\|'\\|/\\*\\|//")) ((string= content-type "css") (setq token-re "\"\\|'\\|/\\*")) (t (setq token-re "/\\*\\|\"\\|'")) ) (while (and token-re (< (point) reg-end) (web-mode-dom-rsf token-re reg-end t)) (setq beg (match-beginning 0) token-type nil continue t ch-at (char-after beg) ch-next (or (char-after (1+ beg)) ?\d) ch-before (or (char-before beg) ?\d)) ;;(message "[%S>%S|%S] %S %c %c %c" reg-beg reg-end depth beg ch-before ch-at ch-next) (cond ((eq ?\' ch-at) (while (and continue (search-forward "'" reg-end t)) (cond ((get-text-property (1- (point)) 'block-side) (setq continue t)) (t (setq continue (web-mode-string-continue-p reg-beg))) ) ) ;while (setq token-type 'string)) ((eq ?\` ch-at) (while (and continue (search-forward "`" reg-end t)) (cond ((get-text-property (1- (point)) 'block-side) (setq continue t)) (t (setq continue (web-mode-string-continue-p reg-beg))) ) ) ;while (setq token-type 'string)) ((eq ?\" ch-at) (while (and continue (search-forward "\"" reg-end t)) (cond ((get-text-property (1- (point)) 'block-side) (setq continue t)) (t (setq continue (web-mode-string-continue-p reg-beg))) ) ;cond ) ;while (cond ((string= content-type "json") (if (looking-at-p "[ ]*:") (cond ((eq ?\@ (char-after (1+ beg))) (setq token-type 'context)) (t (setq token-type 'key)) ) (setq token-type 'string)) ) ;json (t (setq token-type 'string)) ) ;cond ) ((and (eq ?\< ch-at) (not (or (and (>= ch-before 97) (<= ch-before 122)) (and (>= ch-before 65) (<= ch-before 90))))) ;;(message "before [%S>%S|%S] pt=%S" reg-beg reg-end depth (point)) (search-backward "<") (if (web-mode-jsx-skip reg-end) (web-mode-jsx-scan-element beg (point) depth) (forward-char)) ;;(message "after [%S>%S|%S] pt=%S" reg-beg reg-end depth (point)) ) ((and (eq ?\/ ch-at) (member content-type '("javascript" "jsx"))) (cond ((eq ?\\ ch-before) ) ((eq ?\* ch-next) ;;(message "--> %S %S" (point) reg-end) (when (search-forward "*/" reg-end t) (setq token-type 'comment)) ) ((eq ?\/ ch-next) (setq token-type 'comment) (goto-char (if (< reg-end (line-end-position)) reg-end (line-end-position))) ) ((and (looking-at-p ".*/") (looking-back "\\(^\\|case\\|[[(,=:!&|?{};]\\)[ ]*/" (point-min))) ;;(re-search-forward "/[gimyu]*" reg-end t)) (let ((eol (line-end-position))) (while (and continue (search-forward "/" eol t)) (cond ((get-text-property (1- (point)) 'block-side) (setq continue t)) ((looking-back "\\\\+/" reg-beg t) (setq continue (= (mod (- (point) (match-beginning 0)) 2) 0))) (t (re-search-forward "[gimyu]*" eol t) (setq token-type 'string) (setq continue nil)) ) ) ;while ) ;let ) ) ;cond ) ((eq ?\/ ch-next) ;;(message "%S" (point)) (cond ((and (string= content-type "css") (eq ?/ ch-at) (eq ?: ch-before)) ) (t (unless (eq ?\\ ch-before) (setq token-type 'comment) (goto-char (if (< reg-end (line-end-position)) reg-end (line-end-position))) ) ) ) ) ((eq ?\* ch-next) (cond ((search-forward "*/" reg-end t) (setq token-type 'comment)) ((not (eobp)) (forward-char)) ) ;cond ) ) ;cond (when (and beg (>= reg-end (point)) token-type) (put-text-property beg (point) 'part-token token-type) (cond ((eq token-type 'comment) (put-text-property beg (1+ beg) 'syntax-table (string-to-syntax "<")) (when (< (point) (point-max)) (if (< (point) (line-end-position)) (put-text-property (1- (point)) (point) 'syntax-table (string-to-syntax ">")) ;#445 (put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax ">")) ;#377 ) ) ;when ) ;comment ((eq token-type 'string) (put-text-property beg (1+ beg) 'syntax-table (string-to-syntax "|")) (when (< (point) (point-max)) (if (< (point) (line-end-position)) (put-text-property (1- (point)) (point) 'syntax-table (string-to-syntax "|")) (put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax "|")) ) ) ;when ) ;string ) ;cond ) ;when (when (> (point) reg-end) (message "reg-beg(%S) reg-end(%S) token-type(%S) point(%S)" reg-beg reg-end token-type (point))) ;;(message "#[%S>%S|%S] %S %c %c %c | (%S)" reg-beg reg-end depth beg ch-before ch-at ch-next (point)) ) ;while ))) (defun web-mode-string-continue-p (reg-beg) "Is `point' preceeded by an odd number of backslashes?" (let ((p (1- (point)))) (while (and (< reg-beg p) (eq ?\\ (char-before p))) (setq p (1- p))) (= (mod (- (point) p) 2) 0))) ;; css rule = selector(s) + declaration (properties) (defun web-mode-css-rule-next (limit) (let (at-rule var-rule sel-beg sel-end dec-beg dec-end chunk) (skip-chars-forward "\n\t ") (setq sel-beg (point)) (when (and (< (point) limit) (web-mode-part-rsf "[{;]" limit)) (setq sel-end (1- (point))) (cond ((eq (char-before) ?\{) (setq dec-beg (point)) (setq dec-end (web-mode-closing-paren-position (1- dec-beg) limit)) (if dec-end (progn (goto-char dec-end) (forward-char)) (setq dec-end limit) (goto-char limit)) ) (t ) ) ;cond (setq chunk (buffer-substring-no-properties sel-beg sel-end)) (cond ((string-match "@\\([[:alpha:]-]+\\)" chunk) (setq at-rule (match-string-no-properties 1 chunk))) ((string-match "\\$\\([[:alpha:]-]+\\)" chunk) (setq var-rule (match-string-no-properties 1 chunk))) ) ;cond ) ;when (if (not sel-end) (progn (goto-char limit) nil) (list :at-rule at-rule :var-rule var-rule :sel-beg sel-beg :sel-end sel-end :dec-beg dec-beg :dec-end dec-end) ) ;if )) (defun web-mode-css-rule-current (&optional pos part-beg part-end) "Current CSS rule boundaries." (unless pos (setq pos (point))) (unless part-beg (setq part-beg (web-mode-part-beginning-position pos))) (unless part-end (setq part-end (web-mode-part-end-position pos))) (save-excursion (let (beg end) (goto-char pos) (if (not (web-mode-part-sb "{" part-beg)) (progn (setq beg part-beg) (if (web-mode-part-sf ";" part-end) (setq end (1+ (point))) (setq end part-end)) ) ;progn (setq beg (point)) (setq end (web-mode-closing-paren-position beg part-end)) (if end (setq end (1+ end)) (setq end (line-end-position))) ;; (message "%S >>beg%S >>end%S" pos beg end) (if (> pos end) ;;selectors (progn (goto-char pos) (if (web-mode-part-rsb "[};]" part-beg) (setq beg (1+ (point))) (setq beg part-beg) ) ;if (goto-char pos) (if (web-mode-part-rsf "[{;]" part-end) (cond ((eq (char-before) ?\;) (setq end (point)) ) (t (setq end (web-mode-closing-paren-position (1- (point)) part-end)) (if end (setq end (1+ end)) (setq end part-end)) ) ) ;cond (setq end part-end) ) ) ;progn selectors ;; declaration (goto-char beg) (if (web-mode-part-rsb "[}{;]" part-beg) (setq beg (1+ (point))) (setq beg part-beg) ) ;if ) ;if > pos end ) ;; (message "beg(%S) end(%S)" beg end) (when (eq (char-after beg) ?\n) (setq beg (1+ beg))) (cons beg end) ))) (defun web-mode-jsx-skip (reg-end) (let ((continue t) (pos nil) (i 0) tag) (looking-at "<\\([[:alpha:]][[:alnum:]:-]*\\)") (setq tag (match-string-no-properties 1)) ;;(message "point=%S tag=%S" (point) tag) (save-excursion (while continue (cond ((> (setq i (1+ i)) 1000) (message "jsx-skip ** warning **") (setq continue nil)) ((looking-at "<[[:alpha:]][[:alnum:]:-]*[ ]*/>") (goto-char (match-end 0)) (setq pos (point)) (setq continue nil)) ((not (web-mode-dom-rsf ">\\([ \t\n]*[\];,)':}|&]\\)\\|{" reg-end)) (setq continue nil) ) ((eq (char-before) ?\{) (backward-char) (web-mode-closing-paren reg-end) (forward-char) ) (t (setq continue nil) (setq pos (match-beginning 1)) ) ;t ) ;cond ) ;while ) ;save-excursion (when pos (goto-char pos)) ;;(message "jsx-skip: %S" pos) pos)) ;; (defun web-mode-jsx-skip2 (reg-end) ;; (let ((continue t) (pos nil) (i 0) (tag nil) (regexp nil) (counter 1)) ;; (looking-at "<\\([[:alpha:]][[:alnum:]:-]*\\)") ;; (setq tag (match-string-no-properties 1)) ;; (setq regexp (concat " (setq i (1+ i)) 100) ;; (message "jsx-skip ** warning **") ;; (setq continue nil)) ;; ((looking-at "<[[:alpha:]][[:alnum:]:-]*[ ]*/>") ;; (goto-char (match-end 0)) ;; (setq pos (point)) ;; (setq continue nil)) ;; ((not (web-mode-dom-rsf ">\\([ \t\n]*[\];,)':}]\\)\\|{" reg-end)) ;; (setq continue nil) ;; ) ;; ((eq (char-before) ?\{) ;; (backward-char) ;; (web-mode-closing-paren reg-end) ;; (forward-char) ;; ) ;; (t ;; (setq continue nil) ;; (setq pos (match-beginning 1)) ;; ) ;t ;; ) ;cond ;; ) ;while ;; ) ;save-excursion ;; (when pos (goto-char pos)) ;; ;;(message "jsx-skip: %S" pos) ;; pos)) ;; http://facebook.github.io/jsx/ ;; https://github.com/facebook/jsx/blob/master/AST.md (defun web-mode-jsx-scan-element (reg-beg reg-end depth) (unless depth (setq depth 1)) (save-excursion (let (token-beg token-end regexp) (goto-char reg-beg) (put-text-property reg-beg (1+ reg-beg) 'jsx-beg depth) (put-text-property (1- reg-end) reg-end 'jsx-end depth) (put-text-property reg-beg reg-end 'jsx-depth depth) (goto-char reg-beg) (web-mode-scan-elements reg-beg reg-end) (web-mode-jsx-scan-expression reg-beg reg-end (1+ depth)) ))) (defun web-mode-jsx-scan-expression (reg-beg reg-end depth) (let ((continue t) beg end) (save-excursion (goto-char reg-beg) ;;(message "reg-beg=%S reg-end=%S" reg-beg reg-end) (while (and continue (search-forward "{" reg-end t)) (backward-char) (setq beg (point) end (web-mode-closing-paren reg-end)) (cond ((eq (get-text-property beg 'part-token) 'comment) (forward-char)) ((not end) (setq continue nil)) (t (setq end (1+ end)) (put-text-property beg end 'jsx-depth depth) (put-text-property beg (1+ beg) 'jsx-beg depth) (put-text-property (1- end) end 'jsx-end depth) (web-mode-part-scan beg end "jsx" (1+ depth)) ) ;t ) ;cond ) ;while ) ;save-excursion )) (defun web-mode-jsx-is-html (&optional pos) (interactive) (unless pos (setq pos (point))) (let (ret (depth (get-text-property pos 'jsx-depth))) (cond ((or (null depth) (<= pos 2)) (setq pos nil)) ((and (= depth 1) (get-text-property pos 'jsx-beg)) (setq pos nil)) ((get-text-property pos 'tag-end) (setq pos nil)) ((get-text-property pos 'tag-attr-beg) (setq pos nil)) ((get-text-property pos 'jsx-beg) (setq pos (null (get-text-property pos 'tag-beg)))) ((setq pos (web-mode-jsx-depth-beginning-position pos)) (setq pos (not (null (get-text-property pos 'tag-beg))))) (t (setq pos nil)) ) ;cond ;;(message "is-html: %S (depth=%S)" pos depth) pos)) (defun web-mode-jsx-is-expr (&optional pos) (cond ((and (get-text-property pos 'jsx-beg) (not (get-text-property pos 'tag-beg))) nil) (t (setq pos (web-mode-jsx-depth-beginning-position pos)) (null (get-text-property pos 'tag-beg))) ) ;cond ) (defun web-mode-jsx-depth-beginning-position (&optional pos target-depth) (interactive) (unless pos (setq pos (point))) (unless target-depth (setq target-depth (get-text-property pos 'jsx-depth))) (cond ((or (null target-depth) (bobp)) (setq pos nil)) ((and (get-text-property pos 'jsx-beg) (= target-depth (get-text-property pos 'jsx-depth))) ) (t (let ((continue t) depth) (while continue (setq pos (previous-single-property-change pos 'jsx-depth)) (cond ((or (null pos) (null (setq depth (get-text-property pos 'jsx-depth)))) (setq continue nil pos nil)) ((and (get-text-property pos 'jsx-beg) (= target-depth depth)) (setq continue nil)) ) ;cond ) ;while ) ;let ) ;t ) ;cond ;;(message "beg: %S" pos) pos) (defun web-mode-jsx-element-next (reg-end) (let (continue beg end) (setq beg (point)) (unless (get-text-property beg 'jsx-depth) (setq beg (next-single-property-change beg 'jsx-beg))) (setq continue (and beg (< beg reg-end)) end beg) (while continue (setq end (next-single-property-change end 'jsx-end)) (cond ((or (null end) (> end reg-end)) (setq continue nil end nil)) ((eq (get-text-property end 'jsx-depth) 1) (setq continue nil)) (t (setq end (1+ end))) ) ;cond ) ;while ;;(message "beg=%S end=%S" beg end) (if (and beg end (< beg end)) (cons beg end) nil))) (defun web-mode-jsx-expression-next (reg-end) (let (beg end depth continue pos) (setq beg (point)) ;;(message "pt=%S" beg) (unless (and (get-text-property beg 'jsx-beg) (null (get-text-property beg 'tag-beg))) ;;(setq beg (next-single-property-change beg 'jsx-beg)) (setq continue t pos (1+ beg)) (while continue (setq pos (next-single-property-change pos 'jsx-beg)) (cond ((null pos) (setq continue nil beg nil)) ((> pos reg-end) (setq continue nil beg nil)) ((null (get-text-property pos 'jsx-beg)) ) ((null (get-text-property pos 'tag-beg)) (setq continue nil beg pos)) ;;(t ;; (setq pos (1+ pos))) ) ;cond ) ;while ) ;unless ;;(message "beg=%S" beg) (when (and beg (< beg reg-end)) (setq depth (get-text-property beg 'jsx-beg) continue (not (null depth)) pos beg) ;;(message "beg=%S" beg) (while continue (setq pos (next-single-property-change pos 'jsx-end)) ;;(message "pos=%S" pos) (cond ((null pos) (setq continue nil)) ((> pos reg-end) (setq continue nil)) ((eq depth (get-text-property pos 'jsx-end)) (setq continue nil end pos)) (t ;;(setq pos (1+ pos)) ) ) ;cond ) ;while ) ;when ;;(message "%S > %S" beg end) (if (and beg end) (cons beg end) nil))) (defun web-mode-jsx-depth-next (reg-end) (let (beg end depth continue pos) (setq beg (point)) ;;(message "pt=%S" beg) (unless (get-text-property beg 'jsx-beg) ;;(setq beg (next-single-property-change beg 'jsx-beg)) ;;(setq pos (1+ beg)) (setq pos (next-single-property-change (1+ beg) 'jsx-beg)) (cond ((null pos) (setq beg nil)) ((>= pos reg-end) (setq beg nil)) (t (setq beg pos)) ) ;cond ) ;unless ;;(message "beg=%S" beg) (when beg (setq depth (get-text-property beg 'jsx-beg) continue (not (null depth)) pos beg) ;;(message "beg=%S" beg) (while continue (setq pos (next-single-property-change pos 'jsx-end)) ;;(message "pos=%S" pos) (cond ((null pos) (setq continue nil)) ((> pos reg-end) (setq continue nil)) ((eq depth (get-text-property pos 'jsx-end)) (setq continue nil end pos)) (t ;;(setq pos (1+ pos)) ) ) ;cond ) ;while ) ;when ;;(message "%S > %S" beg end) (if (and beg end) (cons beg end) nil))) (defun web-mode-jsx-beginning () (interactive) (let (depth (continue t) (reg-beg (point-min)) (pos (point))) (setq depth (get-text-property pos 'jsx-depth)) (cond ((not depth) ) ((get-text-property (1- pos) 'jsx-beg) (goto-char (1- pos))) (t (while continue (setq pos (previous-single-property-change pos 'jsx-beg)) ;;(message "pos=%S" pos) (cond ((null pos) (setq continue nil)) ((<= pos reg-beg) (setq continue nil)) ((eq depth (get-text-property pos 'jsx-beg)) (setq continue nil)) ) ;cond ) ;while (web-mode-go pos) ) ;t ) ;cond )) (defun web-mode-jsx-end () (interactive) (let (depth (continue t) (reg-end (point-max)) (pos (point))) (setq depth (get-text-property pos 'jsx-depth)) (cond ((not depth) ) ((get-text-property pos 'jsx-end) (goto-char (+ pos 1))) (t (while continue (setq pos (next-single-property-change pos 'jsx-end)) ;;(message "pos=%S" pos) (cond ((null pos) (setq continue nil)) ((> pos reg-end) (setq continue nil)) ((eq depth (get-text-property pos 'jsx-end)) (setq continue nil)) ) ;cond ) ;while (web-mode-go pos 1) ) ;t ) ;cond )) ;;---- FONTIFICATION ----------------------------------------------------------- (defun web-mode-fontify (limit) (when web-mode-trace (message "fontify: point(%S) limit(%S)" (point) limit)) (cond ;;(web-mode-skip-fontification ;; nil) (t (web-mode-with-silent-modifications (save-excursion (save-restriction (save-match-data (let ((beg (point)) (buffer-undo-list t) (end limit) (inhibit-point-motion-hooks t) (inhibit-quit t)) (remove-list-of-text-properties beg end '(font-lock-face face)) (cond ((and (get-text-property beg 'block-side) (not (get-text-property beg 'block-beg))) (web-mode-fontify-block beg end)) ((or (member web-mode-content-type web-mode-part-content-types) (get-text-property beg 'part-side)) (web-mode-fontify-part beg end) (web-mode-block-foreach beg end 'web-mode-fontify-block)) ((string= web-mode-engine "none") (web-mode-fontify-tags beg end) (web-mode-part-foreach beg end 'web-mode-fontify-part)) (t (web-mode-fontify-tags beg end) (web-mode-part-foreach beg end 'web-mode-fontify-part) (web-mode-block-foreach beg end 'web-mode-fontify-block)) ) ;cond (when web-mode-enable-element-content-fontification (web-mode-fontify-elements beg end)) (when web-mode-enable-whitespace-fontification (web-mode-fontify-whitespaces beg end)) ) ;let )))) nil) ;t )) (defun web-mode-buffer-fontify () (interactive) (cond ((and (fboundp 'font-lock-flush) global-font-lock-mode) (font-lock-flush) (font-lock-ensure)) (t ;emacs 24 ;;(font-lock-fontify-buffer) (and global-font-lock-mode (font-lock-fontify-region (point-min) (point-max)))) )) (defun web-mode-unfontify-region (beg end) ;;(message "unfontify: %S %S" beg end) ) (defun web-mode-fontify-region (beg end keywords) ;; (message "beg=%S end=%S keywords=%S" beg end (symbol-name keywords)) (save-excursion (let ((font-lock-keywords keywords) (font-lock-multiline nil) (font-lock-keywords-case-fold-search (member web-mode-engine '("archibus" "asp" "template-toolkit"))) (font-lock-keywords-only t) (font-lock-extend-region-functions nil)) (when (and (listp font-lock-keywords) global-font-lock-mode) (font-lock-fontify-region beg end) ) ))) (defun web-mode-fontify-tags (reg-beg reg-end &optional depth) (let ((continue t)) (goto-char reg-beg) (when (and (not (get-text-property (point) 'tag-beg)) (not (web-mode-tag-next))) (setq continue nil)) (when (and continue (>= (point) reg-end)) (setq continue nil)) (while continue (cond (depth (when (eq depth (get-text-property (point) 'jsx-depth)) (web-mode-fontify-tag)) ) (t (web-mode-fontify-tag)) ) ;cond (when (or (not (web-mode-tag-next)) (>= (point) reg-end)) (setq continue nil)) ) ;while (when web-mode-enable-inlays (when (null web-mode-inlay-regexp) (setq web-mode-inlay-regexp (regexp-opt '("\\[" "\\(" "\\begin{align}")))) (let (beg end expr) (goto-char reg-beg) (while (web-mode-dom-rsf web-mode-inlay-regexp reg-end) (setq beg (match-beginning 0) end nil expr (substring (match-string-no-properties 0) 0 2)) (setq expr (cond ((string= expr "\\[") "\\]") ((string= expr "\\(") "\\)") (t "\\end{align}"))) (when (and (web-mode-dom-sf expr reg-end) (setq end (match-end 0)) (not (text-property-any beg end 'tag-end t))) (font-lock-append-text-property beg end 'font-lock-face 'web-mode-inlay-face) ) ;when ) ;while ) ;let ) ;when (when web-mode-enable-html-entities-fontification (let (beg end) (goto-char reg-beg) (while (web-mode-dom-rsf "&\\([#]?[[:alnum:]]\\{2,8\\}\\);" reg-end) (setq beg (match-beginning 0) end (match-end 0)) (when (not (text-property-any beg end 'tag-end t)) (font-lock-append-text-property beg end 'font-lock-face 'web-mode-html-entity-face) ) ;when ) ;while ) ;let ) ;when )) (defun web-mode-fontify-tag (&optional beg end) (unless beg (setq beg (point))) (unless end (setq end (1+ (web-mode-tag-end-position beg)))) (let (name type face flags slash-beg slash-end bracket-end) (setq flags (get-text-property beg 'tag-beg) type (get-text-property beg 'tag-type) name (get-text-property beg 'tag-name)) (setq bracket-end (> (logand flags 16) 0)) (cond ((eq type 'comment) (put-text-property beg end 'font-lock-face 'web-mode-comment-face) (when (and web-mode-enable-comment-interpolation (> (- end beg) 5)) (web-mode-interpolate-comment beg end nil))) ((eq type 'cdata) (put-text-property beg end 'font-lock-face 'web-mode-doctype-face)) ((eq type 'doctype) (put-text-property beg end 'font-lock-face 'web-mode-doctype-face)) ((eq type 'declaration) (put-text-property beg end 'font-lock-face 'web-mode-doctype-face)) (name (setq slash-beg (> (logand flags 4) 0) slash-end (> (logand flags 8) 0) bracket-end (> (logand flags 16) 0)) (setq face (cond ((not bracket-end) 'web-mode-html-tag-unclosed-face) ((and web-mode-enable-element-tag-fontification (setq face (cdr (assoc name web-mode-element-tag-faces)))) face) ((> (logand flags 32) 0) 'web-mode-html-tag-namespaced-face) ((> (logand flags 2) 0) 'web-mode-html-tag-custom-face) (t 'web-mode-html-tag-face))) (put-text-property beg (+ beg (if slash-beg 2 1)) 'font-lock-face 'web-mode-html-tag-bracket-face) (unless (string= name "_fragment_") (put-text-property (+ beg (if slash-beg 2 1)) (+ beg (if slash-beg 2 1) (length name)) 'font-lock-face face)) (when (or slash-end bracket-end) (put-text-property (- end (if slash-end 2 1)) end 'font-lock-face 'web-mode-html-tag-bracket-face) ) ;when (when (> (logand flags 1) 0) ;;(message "%S>%S" beg end) (web-mode-fontify-attrs beg end)) ) ;case name ) ;cond )) (defun web-mode-fontify-attrs (reg-beg reg-end) (let ((continue t) (pos reg-beg) beg end flags offset face) ;;(message "fontify-attrs %S>%S" reg-beg reg-end) (while continue (setq beg (web-mode-attribute-next-position pos reg-end)) (cond ((or (null beg) (>= beg reg-end)) (setq continue nil)) (t (setq flags (or (get-text-property beg 'tag-attr-beg) 0)) (setq face (cond ((= (logand flags 1) 1) 'web-mode-html-attr-custom-face) ((= (logand flags 2) 2) 'web-mode-html-attr-engine-face) ((= (logand flags 4) 4) nil) (t 'web-mode-html-attr-name-face))) ;;(setq end (if (get-text-property beg 'tag-attr-end) beg (web-mode-attribute-end-position beg))) (setq end (web-mode-attribute-end-position beg)) ;;(message "beg=%S end=%S" beg end) (cond ((or (null end) (>= end reg-end)) (setq continue nil)) (t (setq offset (get-text-property end 'tag-attr-end)) (if (= offset 0) (put-text-property beg (1+ end) 'font-lock-face face) (put-text-property beg (+ beg offset) 'font-lock-face face) (put-text-property (+ beg offset) (+ beg offset 1) 'font-lock-face 'web-mode-html-attr-equal-face) (when (not (get-text-property (+ beg offset 1) 'jsx-beg)) (put-text-property (+ beg offset 1) (1+ end) 'font-lock-face 'web-mode-html-attr-value-face) ) ) ;if offset (setq pos (1+ end)) ) ;t ) ;cond ) ;t );cond ) ;while )) (defun web-mode-fontify-block (reg-beg reg-end) (when web-mode-trace (message "fontify-block: reg-beg(%S) reg-end(%S) engine(%S) keywords(%S)" reg-beg reg-end web-mode-engine (not (null web-mode-engine-font-lock-keywords)))) (let (sub1 sub2 sub3 continue char keywords token-type face beg end (buffer (current-buffer))) ;; NOTE: required for blocks inside tag attrs (remove-list-of-text-properties reg-beg reg-end '(font-lock-face)) (goto-char reg-beg) (when (null web-mode-engine-font-lock-keywords) (setq sub1 (buffer-substring-no-properties reg-beg (+ reg-beg 1)) sub2 (buffer-substring-no-properties reg-beg (+ reg-beg 2)) sub3 (buffer-substring-no-properties reg-beg (+ reg-beg (if (>= (point-max) (+ reg-beg 3)) 3 2)))) ) (cond ((and (get-text-property reg-beg 'block-beg) (eq (get-text-property reg-beg 'block-token) 'comment)) (put-text-property reg-beg reg-end 'font-lock-face 'web-mode-comment-face) ) ;comment block (web-mode-engine-font-lock-keywords (setq keywords web-mode-engine-font-lock-keywords)) ((string= web-mode-engine "django") (cond ((string= sub2 "{{") (setq keywords web-mode-django-expr-font-lock-keywords)) ((string= sub2 "{%") (setq keywords web-mode-django-code-font-lock-keywords)) )) ;django ((string= web-mode-engine "mako") (cond ((member sub3 '("<% " "<%\n" "<%!")) (setq keywords web-mode-mako-block-font-lock-keywords)) ((eq (aref sub2 0) ?\%) (setq keywords web-mode-mako-block-font-lock-keywords)) ((member sub2 '("<%" " %S face(%S)" beg end face) (remove-list-of-text-properties beg end '(face)) (put-text-property beg end 'font-lock-face face) ) (setq continue nil end nil) ) ;if end ) ;progn beg (setq continue nil end nil) ) ;if beg (when (and beg end) (save-match-data (when (and web-mode-enable-heredoc-fontification (eq char ?\<) (> (- end beg) 8) (string-match-p "JS\\|JAVASCRIPT\\|HTM\\|CSS" (buffer-substring-no-properties beg end))) (setq keywords (cond ((string-match-p "H" (buffer-substring-no-properties beg (+ beg 8))) web-mode-html-font-lock-keywords) (t web-mode-javascript-font-lock-keywords) )) (web-mode-fontify-region beg end keywords) ) ) ;save-match-data (when (and web-mode-enable-string-interpolation (member char '(?\" ?\<)) (member web-mode-engine '("php" "erb")) (> (- end beg) 4)) (web-mode-interpolate-block-string beg end) ) ;when (when (and web-mode-enable-comment-interpolation (eq token-type 'comment) (> (- end beg) 3)) (web-mode-interpolate-comment beg end t) ) ;when (when (and web-mode-enable-comment-annotation (eq token-type 'comment) (> (- end beg) 3)) (web-mode-annotate-comment beg end) ) ;when (when (and web-mode-enable-sql-detection (eq token-type 'string) (> (- end beg) 6) (web-mode-looking-at-p (concat "\\(.\\|<<<[[:alnum:]]+\\)[ \n]*" web-mode-sql-queries) beg) ) (web-mode-interpolate-sql-string beg end) ) ;when ) ;when beg end ) ;while continue ) ;when keywords (when (and (member web-mode-engine '("mako")) (> (- reg-end reg-beg) 12) (eq ?\< (char-after reg-beg))) (web-mode-interpolate-block-tag reg-beg reg-end)) (when web-mode-enable-block-face (font-lock-append-text-property reg-beg reg-end 'face 'web-mode-block-face)) )) (defun web-mode-fontify-part (reg-beg reg-end &optional depth) (save-excursion (let (start continue token-type face pos beg end string-face comment-face content-type) ;;(message "fontify-part: reg-beg(%S) reg-end(%S)" reg-beg reg-end) (if (member web-mode-content-type web-mode-part-content-types) (setq content-type web-mode-content-type) (setq content-type (symbol-name (get-text-property reg-beg 'part-side)))) ;;(message "content-type=%S" content-type) (unless depth (when (string= content-type "jsx") (setq depth 0)) ) (setq string-face 'web-mode-part-string-face comment-face 'web-mode-part-comment-face) (cond ((member content-type '("javascript" "jsx")) (setq string-face 'web-mode-javascript-string-face comment-face 'web-mode-javascript-comment-face) (web-mode-fontify-region reg-beg reg-end web-mode-javascript-font-lock-keywords)) ((string= content-type "json") (setq string-face 'web-mode-json-string-face comment-face 'web-mode-json-comment-face) (web-mode-fontify-region reg-beg reg-end web-mode-javascript-font-lock-keywords)) ((string= content-type "css") (setq string-face 'web-mode-css-string-face comment-face 'web-mode-css-comment-face) (web-mode-fontify-css-rules reg-beg reg-end)) ((string= content-type "sql") (web-mode-fontify-region reg-beg reg-end web-mode-sql-font-lock-keywords)) ((string= content-type "stylus") (web-mode-fontify-region reg-beg reg-end web-mode-stylus-font-lock-keywords)) ((string= content-type "sass") (web-mode-fontify-region reg-beg reg-end web-mode-sass-font-lock-keywords)) ((string= content-type "pug") (web-mode-fontify-region reg-beg reg-end web-mode-pug-font-lock-keywords)) ((string= content-type "markdown") (web-mode-fontify-region reg-beg reg-end web-mode-markdown-font-lock-keywords)) ((string= content-type "ruby") (web-mode-fontify-region reg-beg reg-end web-mode-erb-font-lock-keywords)) ((string= content-type "typescript") (web-mode-fontify-region reg-beg reg-end web-mode-javascript-font-lock-keywords)) ) ;cond (goto-char reg-beg) ;;(when (string= content-type "jsx") (web-mode-fontify-tags reg-beg reg-end)) ;;(setq continue (and pos (< pos reg-end))) (setq continue t pos reg-beg) (while continue (if (get-text-property pos 'part-token) (setq beg pos) (setq beg (next-single-property-change pos 'part-token))) (cond ((or (null beg) (>= beg reg-end)) (setq continue nil end nil)) ((and (eq depth 0) (get-text-property beg 'jsx-depth)) (setq pos (or (next-single-property-change beg 'jsx-depth) (point-max)))) (t ;;(message "%c" (char-after beg)) (setq token-type (get-text-property beg 'part-token)) (setq face (cond ((eq token-type 'string) string-face) ((eq token-type 'comment) comment-face) ((eq token-type 'context) 'web-mode-json-context-face) ((eq token-type 'key) 'web-mode-json-key-face) (t nil))) (setq end (or (next-single-property-change beg 'part-token) (point-max)) pos end) (cond ((or (null end) (> end reg-end)) (setq continue nil end nil)) (t (when face (remove-list-of-text-properties beg end '(face)) (put-text-property beg end 'font-lock-face face)) (cond ((< (- end beg) 6) ) ((eq token-type 'string) (cond ((and (eq (char-after beg) ?\`) web-mode-enable-literal-interpolation (member content-type '("javascript" "jsx"))) (web-mode-interpolate-javascript-literal beg end) ) ((and (eq (char-after beg) ?\") web-mode-enable-string-interpolation (member content-type '("javascript" "jsx"))) (web-mode-interpolate-javascript-string beg end)) ) ;cond ) ;case string ((eq token-type 'comment) (when web-mode-enable-comment-interpolation (web-mode-interpolate-comment beg end t)) (when web-mode-enable-comment-annotation (web-mode-annotate-comment beg end)) ) ) ;cond ) ;t ) ;cond ) ;t ) ;cond ) ;while (when (and (string= web-mode-content-type "html") web-mode-enable-part-face) (font-lock-append-text-property reg-beg reg-end 'face (cond ((string= content-type "javascript") 'web-mode-script-face) ((string= content-type "css") 'web-mode-style-face) (t 'web-mode-part-face))) ) (when (and web-mode-enable-css-colorization (string= content-type "stylus")) (goto-char reg-beg) (while (and (re-search-forward "#[0-9a-fA-F]\\{6\\}\\|#[0-9a-fA-F]\\{3\\}\\|rgba?([ ]*\\([[:digit:]]\\{1,3\\}\\)[ ]*,[ ]*\\([[:digit:]]\\{1,3\\}\\)[ ]*,[ ]*\\([[:digit:]]\\{1,3\\}\\)\\(.*?\\))" end t) (<= (point) reg-end)) (web-mode-colorize (match-beginning 0) (match-end 0)) ) ) (when (and (eq depth 0) (string= content-type "jsx")) (let (pair elt-beg elt-end exp-beg exp-end exp-depth) (goto-char reg-beg) (while (setq pair (web-mode-jsx-element-next reg-end)) ;;(message "elt-pair=%S" pair) (setq elt-beg (car pair) elt-end (cdr pair)) (remove-list-of-text-properties elt-beg (1+ elt-end) '(face)) (web-mode-fontify-tags elt-beg elt-end 1) (goto-char elt-beg) (while (setq pair (web-mode-jsx-expression-next elt-end)) ;;(message "exp-pair=%S elt-end=%S" pair elt-end) (setq exp-beg (car pair) exp-end (cdr pair)) (when (eq (char-after exp-beg) ?\{) ;;(message "%S : %c %c" exp-beg (char-after (+ exp-beg 1)) (char-after (+ exp-beg 2))) (cond ;;((and (eq (char-after (+ exp-beg 1)) ?\/) (eq (char-after (+ exp-beg 2)) ?\*)) ;; (put-text-property exp-beg (1+ exp-end) 'font-lock-face 'web-mode-part-comment-face) ;; ) (t (setq exp-depth (get-text-property exp-beg 'jsx-depth)) (remove-list-of-text-properties exp-beg exp-end '(font-lock-face)) (put-text-property exp-beg (1+ exp-beg) 'font-lock-face 'web-mode-block-delimiter-face) (when (and (eq (get-text-property exp-beg 'tag-attr-beg) 4) (web-mode-looking-at-p "\.\.\." (1+ exp-beg))) (put-text-property exp-beg (+ exp-beg 4) 'font-lock-face 'web-mode-block-delimiter-face)) (put-text-property exp-end (1+ exp-end) 'font-lock-face 'web-mode-block-delimiter-face) (web-mode-fontify-tags (1+ exp-beg) exp-end (1+ exp-depth)) (web-mode-fontify-part (1+ exp-beg) exp-end exp-depth) (web-mode-fontify-region (1+ exp-beg) exp-end web-mode-javascript-font-lock-keywords) ) ;t ) ;cond ) ;when (goto-char (1+ exp-beg)) ) ;while exp (when (and elt-beg web-mode-jsx-depth-faces) (let (depth-beg depth-end jsx-face) (goto-char elt-beg) (while (setq pair (web-mode-jsx-depth-next reg-end)) ;;(message "depth-pair=%S" pair) (setq depth-beg (car pair) depth-end (cdr pair) depth (get-text-property depth-beg 'jsx-depth) jsx-face (elt web-mode-jsx-depth-faces (1- depth))) ;;(message "%S" jsx-face) (font-lock-prepend-text-property depth-beg (1+ depth-end) 'face jsx-face) (goto-char (+ depth-beg 2)) ) ) ;let ) (goto-char (1+ elt-end)) ) ;while elt ) ;let ) ;when ) ;let ) ;save-excursion ) (defun web-mode-fontify-css-rules (part-beg part-end) (save-excursion (goto-char part-beg) (let (rule (continue t) (i 0) (at-rule nil) (var-rule nil)) (while continue (setq rule (web-mode-css-rule-next part-end)) ;;(message "rule=%S" rule) (cond ((> (setq i (1+ i)) 1000) (message "fontify-css-rules ** too much rules **") (setq continue nil)) ((null rule) (setq continue nil)) ((and (setq at-rule (plist-get rule :at-rule)) (not (member at-rule '("charset" "font-face" "import" "viewport"))) (plist-get rule :dec-end)) (web-mode-fontify-css-rule (plist-get rule :sel-beg) (plist-get rule :sel-end) nil nil) (web-mode-fontify-css-rules (plist-get rule :dec-beg) (plist-get rule :dec-end))) (t (web-mode-fontify-css-rule (plist-get rule :sel-beg) (plist-get rule :sel-end) (plist-get rule :dec-beg) (plist-get rule :dec-end))) ) ;cond ) ;while ) ;let )) (defun web-mode-fontify-css-rule (sel-beg sel-end dec-beg dec-end) (save-excursion ;;(let ((end sel-end)) ;;(message "sel-beg=%S sel-end=%S dec-beg=%S dec-end=%S" sel-beg sel-end dec-beg dec-end) (web-mode-fontify-region sel-beg sel-end web-mode-selector-font-lock-keywords) (when (and dec-beg dec-end) ;;(setq end dec-end) (web-mode-fontify-region dec-beg dec-end web-mode-declaration-font-lock-keywords) ) ;when (when (and dec-beg dec-end) (goto-char dec-beg) (while (and web-mode-enable-css-colorization (re-search-forward "#[0-9a-fA-F]\\{6\\}\\|#[0-9a-fA-F]\\{3\\}\\|rgba?([ ]*\\([[:digit:]]\\{1,3\\}\\)[ ]*,[ ]*\\([[:digit:]]\\{1,3\\}\\)[ ]*,[ ]*\\([[:digit:]]\\{1,3\\}\\)\\(.*?\\))" dec-end t) ;;(progn (message "%S %S" end (point)) t) (<= (point) dec-end)) (web-mode-colorize (match-beginning 0) (match-end 0)) ) ;while ) ;when ;;) ;let )) (defun web-mode-colorize-foreground (color) (let* ((values (x-color-values color)) (r (car values)) (g (cadr values)) (b (car (cdr (cdr values))))) (if (> 128.0 (floor (+ (* .3 r) (* .59 g) (* .11 b)) 256)) "white" "black"))) (defun web-mode-colorize (beg end) (let (str plist len) (setq str (buffer-substring-no-properties beg end)) (setq len (length str)) (cond ((string= (substring str 0 1) "#") (setq plist (list :background str :foreground (web-mode-colorize-foreground str))) (put-text-property beg end 'face plist)) ((or (string= (substring str 0 4) "rgb(") (string= (substring str 0 5) "rgba(")) (setq str (format "#%02X%02X%02X" (string-to-number (match-string-no-properties 1)) (string-to-number (match-string-no-properties 2)) (string-to-number (match-string-no-properties 3)))) (setq plist (list :background str :foreground (web-mode-colorize-foreground str))) (put-text-property beg end 'face plist)) ) ;cond )) (defun web-mode-interpolate-block-tag (beg end) (save-excursion (goto-char (+ 4 beg)) (setq end (1- end)) (while (re-search-forward "${.*?}" end t) (remove-list-of-text-properties (match-beginning 0) (match-end 0) '(face)) (web-mode-fontify-region (match-beginning 0) (match-end 0) web-mode-uel-font-lock-keywords)) )) (defun web-mode-interpolate-javascript-string (beg end) (save-excursion (goto-char (1+ beg)) (setq end (1- end)) (while (re-search-forward "${.*?}" end t) (put-text-property (match-beginning 0) (match-end 0) 'font-lock-face 'web-mode-variable-name-face) ) )) (defun web-mode-interpolate-javascript-literal (beg end) (save-excursion (goto-char (1+ beg)) (setq end (1- end)) (while (re-search-forward "${.*?}" end t) (put-text-property (match-beginning 0) (match-end 0) 'font-lock-face 'web-mode-variable-name-face) ) (cond ((web-mode-looking-back "\\(css\\|styled[[:alnum:].]+\\)" beg) (goto-char (1+ beg)) (while (re-search-forward ".*?:" end t) (put-text-property (match-beginning 0) (match-end 0) 'font-lock-face 'web-mode-interpolate-color1-face) ) ) ;case css ((web-mode-looking-back "\\(template\\|html\\)" beg) (goto-char (1+ beg)) (while (re-search-forward web-mode-tag-regexp end t) (put-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'web-mode-interpolate-color1-face) ) (goto-char (1+ beg)) (while (re-search-forward "\\| [[:alnum:]]+=" end t) (cond ((member (char-after (match-beginning 0)) '(?\< ?\/ ?\>)) (put-text-property (match-beginning 0) (match-end 0) 'font-lock-face 'web-mode-interpolate-color2-face) ) (t (put-text-property (1+ (match-beginning 0)) (1- (match-end 0)) 'font-lock-face 'web-mode-interpolate-color3-face) ) ;t ) ;cond ) ;while ) ;case html ) ;cond type of literal )) ;; todo : parsing plus compliqué: {$obj->values[3]->name} (defun web-mode-interpolate-block-string (beg end) (save-excursion (goto-char (1+ beg)) (setq end (1- end)) (cond ((string= web-mode-engine "php") (while (re-search-forward "$[[:alnum:]_]+\\(->[[:alnum:]_]+\\)*\\|{[ ]*$.+?}" end t) ;; (message "%S > %S" (match-beginning 0) (match-end 0)) (remove-list-of-text-properties (match-beginning 0) (match-end 0) '(font-lock-face)) (web-mode-fontify-region (match-beginning 0) (match-end 0) web-mode-php-var-interpolation-font-lock-keywords) )) ((string= web-mode-engine "erb") (while (re-search-forward "#{.*?}" end t) (remove-list-of-text-properties (match-beginning 0) (match-end 0) '(font-lock-face)) (put-text-property (match-beginning 0) (match-end 0) 'font-lock-face 'web-mode-variable-name-face) )) ) ;cond )) (defun web-mode-interpolate-comment (beg end block-side) (save-excursion (let ((regexp (concat "\\_<\\(" web-mode-comment-keywords "\\)\\_>"))) (goto-char beg) (while (re-search-forward regexp end t) (font-lock-prepend-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'web-mode-comment-keyword-face) ) ;while ))) (defun web-mode-annotate-comment (beg end) (save-excursion ;;(message "beg=%S end=%S" beg end) (goto-char beg) (when (looking-at-p "/\\*\\*") (while (re-search-forward "\\(.+\\)" end t) (font-lock-prepend-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'web-mode-annotation-face)) (goto-char beg) (while (re-search-forward "[ ]+\\({[^}]+}\\)" end t) (font-lock-prepend-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'web-mode-annotation-type-face)) (goto-char beg) (while (re-search-forward "\\(@[[:alnum:]]+\\)" end t) (font-lock-prepend-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'web-mode-annotation-tag-face)) (goto-char beg) (while (re-search-forward "}[[:blank:]]+\\([[:graph:]]+\\)" end t) (font-lock-prepend-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'web-mode-annotation-value-face)) (goto-char beg) (while (re-search-forward "@see[[:blank:]]+\\([[:graph:]]+\\)" end t) (font-lock-prepend-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'web-mode-annotation-value-face)) (goto-char beg) (while (re-search-forward "{\\(@\\(?:link\\|code\\)\\)\\s-+\\([^}\n]+\\)\\(#.+\\)?}" end t) (font-lock-prepend-text-property (match-beginning 2) (match-end 2) 'font-lock-face 'web-mode-annotation-value-face)) (goto-char beg) (while (re-search-forward "\\(\\)" end t) (font-lock-prepend-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'web-mode-annotation-html-face) (font-lock-prepend-text-property (match-beginning 2) (match-end 2) 'font-lock-face 'web-mode-annotation-html-face) (font-lock-prepend-text-property (match-beginning 3) (match-end 3) 'font-lock-face 'web-mode-annotation-html-face)) ) ;when )) (defun web-mode-interpolate-sql-string (beg end) (save-excursion (let ((case-fold-search t) (regexp (concat "\\_<\\(" web-mode-sql-keywords "\\)\\_>"))) (goto-char beg) (while (re-search-forward regexp end t) (font-lock-prepend-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'web-mode-sql-keyword-face) ) ;while ))) ;;---- EFFECTS ----------------------------------------------------------------- (defun web-mode-fill-paragraph (&optional justify) (save-excursion (let ((pos (point)) fill-coll prop pair beg end delim-beg delim-end chunk fill-col) (cond ((or (eq (get-text-property pos 'part-token) 'comment) (eq (get-text-property pos 'block-token) 'comment)) (setq prop (if (get-text-property pos 'part-token) 'part-token 'block-token)) (setq pair (web-mode-property-boundaries prop pos)) (when (and pair (> (- (cdr pair) (car pair)) 6)) (setq fill-coll (if (< fill-column 10) 70 fill-column)) (setq beg (car pair) end (cdr pair)) (goto-char beg) (setq chunk (buffer-substring-no-properties beg (+ beg 2))) (cond ((string= chunk "//") (setq delim-beg "//" delim-end "EOL")) ((string= chunk "/*") (setq delim-beg "/*" delim-end "*/")) ((string= chunk "{#") (setq delim-beg "{#" delim-end "#}")) ((string= chunk "")) ) ) ) ;comment - case ((web-mode-is-content) (setq pair (web-mode-content-boundaries pos)) (setq beg (car pair) end (cdr pair)) ) ) ;cond ;;(message "beg(%S) end(%S)" beg end) (when (and beg end) (fill-region beg end)) t))) (defun web-mode-engine-syntax-check () (interactive) (let ((proc nil) (errors nil) (file (concat temporary-file-directory "emacs-web-mode-tmp"))) (write-region (point-min) (point-max) file) (cond ;; ((null (buffer-file-name)) ;; ) ((string= web-mode-engine "php") (setq proc (start-process "php-proc" nil "php" "-l" file)) (set-process-filter proc (lambda (proc output) (cond ((string-match-p "No syntax errors" output) (message "No syntax errors") ) (t ;; (setq output (replace-regexp-in-string temporary-file-directory "" output)) ;; (message output) (message "Syntax error") (setq errors t)) ) ;cond ;; (delete-file file) ) ;lambda ) ) ;php (t (message "no syntax checker found") ) ;t ) ;cond errors)) (defun web-mode-jshint () "Run JSHint on all the JavaScript parts." (interactive) (let (proc lines) (when (buffer-file-name) (setq proc (start-process "jshint-proc" nil (or (executable-find "jshint") "/usr/local/bin/jshint") "--extract=auto" (buffer-file-name))) (setq web-mode-jshint-errors 0) (set-process-filter proc (lambda (proc output) (let ((offset 0) overlay pos (old 0) msg) (remove-overlays (point-min) (point-max) 'font-lock-face 'web-mode-error-face) (while (string-match "line \\([[:digit:]]+\\), col \\([[:digit:]]+\\), \\(.+\\)\\.$" output offset) (setq web-mode-jshint-errors (1+ web-mode-jshint-errors)) (setq offset (match-end 0)) (setq pos (web-mode-coord-position (match-string-no-properties 1 output) (match-string-no-properties 2 output))) (when (get-text-property pos 'tag-beg) (setq pos (1- pos))) (when (not (= pos old)) (setq old pos) (setq overlay (make-overlay pos (1+ pos))) (overlay-put overlay 'font-lock-face 'web-mode-error-face) ) (setq msg (or (overlay-get overlay 'help-echo) (concat "line=" (match-string-no-properties 1 output) " column=" (match-string-no-properties 2 output) ))) (overlay-put overlay 'help-echo (concat msg " ## " (match-string-no-properties 3 output))) ) ;while )) ) ) ;when )) (defun web-mode-dom-errors-show () "Show unclosed tags." (interactive) (let (beg end tag pos l n tags i cont cell overlay overlays first (ori (point)) (errors 0) (continue t) ) (setq overlays (overlays-in (point-min) (point-max))) (when overlays (dolist (overlay overlays) (when (eq (overlay-get overlay 'face) 'web-mode-warning-face) (delete-overlay overlay) ) ) ) (goto-char (point-min)) (when (not (or (get-text-property (point) 'tag-beg) (web-mode-tag-next))) (setq continue nil)) (while continue (setq pos (point)) (setq tag (get-text-property pos 'tag-name)) (cond ((eq (get-text-property (point) 'tag-type) 'start) (setq tags (add-to-list 'tags (list tag pos))) ;; (message "(%S) opening %S" pos tag) ) ((eq (get-text-property (point) 'tag-type) 'end) (setq i 0 l (length tags) cont t) (while (and (< i l) cont) (setq cell (nth i tags)) ;; (message "cell=%S" cell) (setq i (1+ i)) (cond ((string= tag (nth 0 cell)) (setq cont nil) ) (t (setq errors (1+ errors)) (setq beg (nth 1 cell)) (setq end (web-mode-tag-end-position beg)) (unless first (setq first beg)) (setq overlay (make-overlay beg (1+ end))) (overlay-put overlay 'font-lock-face 'web-mode-warning-face) ;; (message "invalid <%S> at %S" (nth 0 cell) (nth 1 cell)) ) ) ;cond ) ;while (dotimes (i i) (setq tags (cdr tags))) ) ) ;cond (when (not (web-mode-tag-next)) (setq continue nil)) ) ;while (message "%S error(s) detected" errors) (if (< errors 1) (goto-char ori) (goto-char first) (recenter)) ;; (message "%S" tags) )) (defun web-mode-fontify-elements (beg end) (save-excursion (goto-char beg) (let ((continue (or (get-text-property (point) 'tag-beg) (web-mode-tag-next))) (i 0) (ctx nil) (face nil)) (while continue (cond ((> (setq i (1+ i)) 1000) (message "fontify-elements ** too much tags **") (setq continue nil)) ((> (point) end) (setq continue nil)) ((not (get-text-property (point) 'tag-beg)) (setq continue nil)) ((eq (get-text-property (point) 'tag-type) 'start) (when (and (setq ctx (web-mode-element-boundaries (point))) (<= (car (cdr ctx)) end) (setq face (cdr (assoc (get-text-property (point) 'tag-name) web-mode-element-content-faces)))) (font-lock-prepend-text-property (1+ (cdr (car ctx))) (car (cdr ctx)) 'font-lock-face face)) ) ) ;cond (when (not (web-mode-tag-next)) (setq continue nil)) ) ;while ))) (defun web-mode-enable (feature) "Enable one feature." (interactive (list (completing-read "Feature: " (let (features) (dolist (elt web-mode-features) (setq features (append features (list (car elt))))) features)))) (when (and (or (not feature) (< (length feature) 1)) web-mode-last-enabled-feature) (setq feature web-mode-last-enabled-feature)) (when feature (setq web-mode-last-enabled-feature feature) (setq feature (cdr (assoc feature web-mode-features))) (cond ((eq feature 'web-mode-enable-current-column-highlight) (web-mode-column-show)) ((eq feature 'web-mode-enable-current-element-highlight) (when (not web-mode-enable-current-element-highlight) (web-mode-toggle-current-element-highlight)) ) ((eq feature 'web-mode-enable-whitespace-fontification) (web-mode-whitespaces-on)) (t (set feature t) (web-mode-buffer-fontify)) ) ) ;when ) (defun web-mode-disable (feature) "Disable one feature." (interactive (list (completing-read "Feature: " (let (features) (dolist (elt web-mode-features) (setq features (append features (list (car elt))))) features)))) (when (and (or (not feature) (< (length feature) 1)) web-mode-last-enabled-feature) (setq feature web-mode-last-enabled-feature)) (when feature (setq feature (cdr (assoc feature web-mode-features))) (cond ((eq feature 'web-mode-enable-current-column-highlight) (web-mode-column-hide)) ((eq feature 'web-mode-enable-current-element-highlight) (when web-mode-enable-current-element-highlight (web-mode-toggle-current-element-highlight)) ) ((eq feature 'web-mode-enable-whitespace-fontification) (web-mode-whitespaces-off)) (t (set feature nil) (web-mode-buffer-fontify)) ) ) ;when ) (defun web-mode-toggle-current-element-highlight () "Toggle highlighting of the current html element." (interactive) (if web-mode-enable-current-element-highlight (progn (web-mode-delete-tag-overlays) (setq web-mode-enable-current-element-highlight nil)) (setq web-mode-enable-current-element-highlight t) )) (defun web-mode-make-tag-overlays () (unless web-mode-overlay-tag-start (setq web-mode-overlay-tag-start (make-overlay 1 1) web-mode-overlay-tag-end (make-overlay 1 1)) (overlay-put web-mode-overlay-tag-start 'font-lock-face 'web-mode-current-element-highlight-face) (overlay-put web-mode-overlay-tag-end 'font-lock-face 'web-mode-current-element-highlight-face))) (defun web-mode-delete-tag-overlays () (when web-mode-overlay-tag-start (delete-overlay web-mode-overlay-tag-start) (delete-overlay web-mode-overlay-tag-end))) (defun web-mode-column-overlay-factory (index) (let (overlay) (when (null web-mode-column-overlays) (dotimes (i 100) (setq overlay (make-overlay 1 1)) (overlay-put overlay 'font-lock-face 'web-mode-current-column-highlight-face) (setq web-mode-column-overlays (append web-mode-column-overlays (list overlay))) ) ) ;when (setq overlay (nth index web-mode-column-overlays)) (when (null overlay) (setq overlay (make-overlay 1 1)) (overlay-put overlay 'font-lock-face 'web-mode-current-column-highlight-face) (setq web-mode-column-overlays (append web-mode-column-overlays (list overlay))) ) ;when overlay)) (defun web-mode-column-hide () (setq web-mode-enable-current-column-highlight nil) (remove-overlays (point-min) (point-max) 'font-lock-face 'web-mode-current-column-highlight-face)) (defun web-mode-column-show () (let ((index 0) overlay diff column line-to line-from) (web-mode-column-hide) (setq web-mode-enable-current-column-highlight t) (save-excursion (back-to-indentation) (setq column (current-column) line-to (web-mode-line-number)) (when (and (get-text-property (point) 'tag-beg) (member (get-text-property (point) 'tag-type) '(start end)) (web-mode-tag-match) (setq line-from (web-mode-line-number)) (not (= line-from line-to))) (when (> line-from line-to) (let (tmp) (setq tmp line-from) (setq line-from line-to) (setq line-to tmp)) ) ;when ;;(message "column(%S) line-from(%S) line-to(%S)" column line-from line-to) (goto-char (point-min)) (when (> line-from 1) (forward-line (1- line-from))) (while (<= line-from line-to) (setq overlay (web-mode-column-overlay-factory index)) (setq diff (- (line-end-position) (point))) (cond ((or (and (= column 0) (= diff 0)) (> column diff)) (end-of-line) (move-overlay overlay (point) (point)) (overlay-put overlay 'after-string (concat (if (> column diff) (make-string (- column diff) ?\s) "") (propertize " " 'font-lock-face 'web-mode-current-column-highlight-face) ) ;concat ) ) (t (move-to-column column) (overlay-put overlay 'after-string nil) (move-overlay overlay (point) (1+ (point))) ) ) ;cond (setq line-from (1+ line-from)) (forward-line) (setq index (1+ index)) ) ;while ) ;when ) ;save-excursion ) ;let ) (defun web-mode-highlight-current-element () (let ((ctx (web-mode-element-boundaries)) len) (cond ((null ctx) (web-mode-delete-tag-overlays)) ((eq (get-text-property (caar ctx) 'tag-type) 'void) ;; #1046 (web-mode-make-tag-overlays) (setq len (length (get-text-property (caar ctx) 'tag-name))) (move-overlay web-mode-overlay-tag-start (+ (caar ctx) 1) (+ (caar ctx) 1 len)) ) (t (web-mode-make-tag-overlays) (setq len (length (get-text-property (caar ctx) 'tag-name))) (move-overlay web-mode-overlay-tag-start (+ (caar ctx) 1) (+ (caar ctx) 1 len)) (move-overlay web-mode-overlay-tag-end (+ (cadr ctx) 2) (+ (cadr ctx) 2 len)) ) ;t ) ;cond )) (defun web-mode-fontify-whitespaces (beg end) (save-excursion (goto-char beg) (while (re-search-forward web-mode-whitespaces-regexp end t) (add-text-properties (match-beginning 0) (match-end 0) '(face web-mode-whitespace-face)) ) ;while )) (defun web-mode-whitespaces-show () "Toggle whitespaces." (interactive) (if web-mode-enable-whitespace-fontification (web-mode-whitespaces-off) (web-mode-whitespaces-on))) (defun web-mode-whitespaces-on () "Show whitespaces." (interactive) (when web-mode-display-table (setq buffer-display-table web-mode-display-table)) (setq web-mode-enable-whitespace-fontification t)) (defun web-mode-whitespaces-off () (setq buffer-display-table nil) (setq web-mode-enable-whitespace-fontification nil)) (defun web-mode-use-tabs () "Tweaks vars to be compatible with TAB indentation." (let (offset) (setq web-mode-block-padding 0) (setq web-mode-script-padding 0) (setq web-mode-style-padding 0) (setq offset (cond ((and (boundp 'tab-width) tab-width) tab-width) ((and (boundp 'standard-indent) standard-indent) standard-indent) (t 4))) ;; (message "offset(%S)" offset) (setq web-mode-attr-indent-offset offset) (setq web-mode-code-indent-offset offset) (setq web-mode-css-indent-offset offset) (setq web-mode-markup-indent-offset offset) (setq web-mode-sql-indent-offset offset) (add-to-list 'web-mode-indentation-params '("lineup-args" . nil)) (add-to-list 'web-mode-indentation-params '("lineup-calls" . nil)) (add-to-list 'web-mode-indentation-params '("lineup-concats" . nil)) (add-to-list 'web-mode-indentation-params '("lineup-ternary" . nil)) )) (defun web-mode-element-children-fold-or-unfold (&optional pos) "Fold/Unfold all the children of the current html element." (interactive) (unless pos (setq pos (point))) (save-excursion (dolist (child (reverse (web-mode-element-children pos))) (goto-char child) (web-mode-fold-or-unfold)) )) (defun web-mode-fold-or-unfold (&optional pos) "Toggle folding on an html element or a control block." (interactive) (web-mode-scan) (web-mode-with-silent-modifications (save-excursion (if pos (goto-char pos)) (let (beg-inside beg-outside end-inside end-outside overlay overlays regexp) (when (looking-back "^[\t ]*" (point-min)) (back-to-indentation)) (setq overlays (overlays-at (point))) (dolist (elt overlays) (when (and (not overlay) (eq (overlay-get elt 'font-lock-face) 'web-mode-folded-face)) (setq overlay elt))) (cond ;; *** unfolding (overlay (setq beg-inside (overlay-start overlay) end-inside (overlay-end overlay)) (remove-overlays beg-inside end-inside) (put-text-property beg-inside end-inside 'invisible nil) ) ;; *** block folding ((and (get-text-property (point) 'block-side) (cdr (web-mode-block-is-control (point)))) (setq beg-outside (web-mode-block-beginning-position (point))) (setq beg-inside (1+ (web-mode-block-end-position (point)))) (when (web-mode-block-match) (setq end-inside (point)) (setq end-outside (1+ (web-mode-block-end-position (point))))) ) ;; *** html comment folding ((eq (get-text-property (point) 'tag-type) 'comment) (setq beg-outside (web-mode-tag-beginning-position)) (setq beg-inside (+ beg-outside 4)) (setq end-outside (web-mode-tag-end-position)) (setq end-inside (- end-outside 3)) ) ;; *** tag folding ((or (member (get-text-property (point) 'tag-type) '(start end)) (web-mode-element-parent)) (when (not (web-mode-element-is-collapsed (point))) (web-mode-tag-beginning) (when (eq (get-text-property (point) 'tag-type) 'end) (web-mode-tag-match)) (setq beg-outside (point)) (web-mode-tag-end) (setq beg-inside (point)) (goto-char beg-outside) (when (web-mode-tag-match) (setq end-inside (point)) (web-mode-tag-end) (setq end-outside (point))) ) ) ) ;cond (when (and beg-inside beg-outside end-inside end-outside) (setq overlay (make-overlay beg-outside end-outside)) (overlay-put overlay 'font-lock-face 'web-mode-folded-face) (put-text-property beg-inside end-inside 'invisible t)) )))) ;;---- TRANSFORMATION ---------------------------------------------------------- (defun web-mode-buffer-change-tag-case (&optional type) "Change html tag case." (interactive) (save-excursion (goto-char (point-min)) (let ((continue t) f) (setq f (if (member type '("upper" "uppercase" "upper-case")) 'uppercase 'downcase)) (when (and (not (get-text-property (point) 'tag-beg)) (not (web-mode-tag-next))) (setq continue nil)) (while continue (skip-chars-forward " and < in html content." (interactive) (save-excursion (let (expr (min (point-min)) (max (point-max))) (when mark-active (setq min (region-beginning) max (region-end)) (deactivate-mark)) (goto-char min) (while (web-mode-content-rsf "[&<>]" max) (replace-match (cdr (assq (char-before) web-mode-xml-chars)) t t)) ))) (defun web-mode-dom-quotes-replace () "Replace dumb quotes." (interactive) (save-excursion (let (expr (min (point-min)) (max (point-max))) (when mark-active (setq min (region-beginning) max (region-end)) (deactivate-mark)) (goto-char min) (setq expr (concat (car web-mode-smart-quotes) "\\2" (cdr web-mode-smart-quotes))) (while (web-mode-content-rsf "\\(\"\\)\\(.\\{1,200\\}\\)\\(\"\\)" max) (replace-match expr) ) ;while ))) ;;---- INDENTATION ------------------------------------------------------------- ;; todo : passer de règle en règle et mettre un \n à la fin (defun web-mode-css-indent () (save-excursion (goto-char (point-min)) (let ((continue t) rule part-end) (while continue (cond ((not (web-mode-part-next)) (setq continue nil)) ((eq (get-text-property (point) 'part-side) 'css) (setq part-end (web-mode-part-end-position)) (while (setq rule (web-mode-css-rule-next part-end)) (when (not (looking-at-p "[[:space:]]*\\($\\|<\\)")) (newline) (indent-according-to-mode) (setq part-end (web-mode-part-end-position))) ) ) ) ;cond ) ))) (defun web-mode-buffer-indent () "Indent all buffer." (interactive) (let ((debug t) (ts (current-time)) (sub nil)) (indent-region (point-min) (point-max)) (when debug (setq sub (time-subtract (current-time) ts)) (message "buffer-indent: time elapsed = %Ss %9Sµs" (nth 1 sub) (nth 2 sub))) (delete-trailing-whitespace))) (defun web-mode-point-context (pos) "POS should be at the beginning of the indentation." (save-excursion (let (curr-char curr-indentation curr-line language options reg-beg reg-col prev-char prev-indentation prev-line prev-pos token part-language depth) (setq reg-beg (point-min) reg-col 0 token "live" options "" language "" prev-line "" prev-char 0 prev-pos nil) (when (get-text-property pos 'part-side) (setq part-language (symbol-name (get-text-property pos 'part-side)))) ;;(message "part-language=%S" part-language) (cond ((and (bobp) (member web-mode-content-type '("html" "xml"))) (setq language web-mode-content-type) ) ((string= web-mode-content-type "css") (setq language "css" curr-indentation web-mode-css-indent-offset)) ((member web-mode-content-type '("javascript" "json" "typescript")) (setq language web-mode-content-type curr-indentation web-mode-code-indent-offset)) ((or (string= web-mode-content-type "jsx") (and part-language (string= part-language "jsx"))) (setq language "jsx" curr-indentation web-mode-code-indent-offset) (cond ((web-mode-jsx-is-html pos) (setq curr-indentation web-mode-markup-indent-offset options "is-html")) ((and (setq depth (get-text-property pos 'jsx-depth)) (> depth 1)) (when (get-text-property pos 'jsx-beg) (setq depth (1- depth))) (setq reg-beg (web-mode-jsx-depth-beginning-position pos depth)) (setq reg-beg (1+ reg-beg)) ;;(message "%S" (point)) (save-excursion (goto-char reg-beg) ;;(message "pt=%S" reg-beg) (cond ((and (not (looking-at-p "[ ]*$")) (looking-back "^[[:space:]]*{" (point-min))) (setq reg-col (+ (current-indentation) ;; #1027 (cond ((looking-at "[ ]+") (1+ (length (match-string-no-properties 0)))) (t 0)) )) ) ((looking-at-p "[ ]*\\[[ ]*$") ;; #0659 (setq reg-col (current-indentation)) ) ((and (looking-back "=[ ]*{" (point-min)) ;; #0739 #1022 (not (looking-at-p "[[:space:]]*<"))) (setq reg-col (current-indentation)) ) ;;((and (looking-back "=[ ]*{" (point-min)) ;; #0739 ;; (looking-at-p "{[ ]*")) ;; (setq reg-col (current-indentation)) ;; ) ((get-text-property (1- (point)) 'tag-beg) ;;(message "point=%S" (point)) (setq reg-col (current-indentation)) ) (t (message "%S : %S %S" (point) (current-indentation) web-mode-code-indent-offset) ;;(setq reg-col (+ (current-indentation) web-mode-code-indent-offset web-mode-jsx-expression-padding))) (setq reg-col (+ (current-indentation) web-mode-code-indent-offset))) ) ;;(message "%S %S %S" (point) (current-indentation) reg-col) ) ;save-excursion ) ((string= web-mode-content-type "jsx") (setq reg-beg (point-min))) (t (setq reg-beg (or (web-mode-part-beginning-position pos) (point-min))) (save-excursion (goto-char reg-beg) (search-backward "<" nil t) (setq reg-col (current-column)) ) ;save-excursion ) ) ;cond ;;(message "jsx reg-beg=%S" reg-beg) ) ;jsx ((string= web-mode-content-type "php") (setq language "php" curr-indentation web-mode-code-indent-offset)) ((or (string= web-mode-content-type "xml")) (setq language "xml" curr-indentation web-mode-markup-indent-offset)) ;; TODO: est ce util ? ((and (get-text-property pos 'tag-beg) (get-text-property pos 'tag-name) ;;(not (get-text-property pos 'part-side)) ) (setq language "html" curr-indentation web-mode-markup-indent-offset)) ((and (get-text-property pos 'block-side) (not (get-text-property pos 'block-beg))) (setq reg-beg (or (web-mode-block-beginning-position pos) (point-min))) (goto-char reg-beg) (setq reg-col (current-column)) ;;(message "%S %S" reg-beg reg-col) (setq language web-mode-engine) (setq curr-indentation web-mode-code-indent-offset) (cond ((string= web-mode-engine "blade") (save-excursion (when (web-mode-rsf "{[{!]+[ ]*") (setq reg-col (current-column)))) (setq reg-beg (+ reg-beg 2)) ) ((string= web-mode-engine "razor") ;;(setq reg-beg (+ reg-beg 2)) ;;(setq reg-col (current-column)) ) ;; tests/demo.chtml ((string= web-mode-engine "ctemplate") (save-excursion (when (web-mode-rsf "{{#?") (setq reg-col (current-column)))) ) ((string= web-mode-engine "dust") (save-excursion (when (web-mode-rsf "{@") (setq reg-col (current-column)))) ) ((string= web-mode-engine "svelte") (save-excursion (when (web-mode-rsf "{@") (setq reg-col (current-column)))) ) ((string= web-mode-engine "template-toolkit") (setq reg-beg (+ reg-beg 3) reg-col (+ reg-col 3)) ) ((and (string= web-mode-engine "jsp") (web-mode-looking-at "<%@" reg-beg)) (save-excursion (goto-char reg-beg) (looking-at "<%@[ ]*[[:alpha:]]+[ ]+\\| pos (point-min)) (eq (get-text-property pos 'part-token) 'comment) (eq (get-text-property (1- pos) 'part-token) 'comment) (progn (setq reg-beg (previous-single-property-change pos 'part-token)) t)) (and (> pos (point-min)) (eq (get-text-property pos 'block-token) 'comment) (eq (get-text-property (1- pos) 'block-token) 'comment) (progn (setq reg-beg (previous-single-property-change pos 'block-token)) t)) (and (> pos (point-min)) (eq (get-text-property pos 'tag-type) 'comment) (not (get-text-property pos 'tag-beg)) (progn (setq reg-beg (web-mode-tag-beginning-position pos)) t)) ) (setq token "comment")) ((or (and (> pos (point-min)) (member (get-text-property pos 'part-token) '(string context key)) (member (get-text-property (1- pos) 'part-token) '(string context key))) (and (eq (get-text-property pos 'block-token) 'string) (eq (get-text-property (1- pos) 'block-token) 'string))) (setq token "string")) ) (goto-char pos) (setq curr-line (web-mode-trim (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) (setq curr-char (if (string= curr-line "") 0 (aref curr-line 0))) (when (or (member language '("php" "blade" "javascript" "typescript" "jsx" "razor" "css")) (and (member language '("html" "xml")) (not (eq ?\< curr-char)))) (let (prev) (cond ((member language '("html" "xml" "javascript" "jsx" "css")) (when (setq prev (web-mode-part-previous-live-line reg-beg)) (setq prev-line (nth 0 prev) prev-indentation (nth 1 prev) prev-pos (nth 2 prev)) ) ) ((setq prev (web-mode-block-previous-live-line)) (setq prev-line (car prev) prev-indentation (cdr prev)) (setq prev-line (web-mode-clean-block-line prev-line))) ) ;cond ) ;let (when (>= (length prev-line) 1) (setq prev-char (aref prev-line (1- (length prev-line)))) (setq prev-line (substring-no-properties prev-line)) ) ) (cond ((not (member web-mode-content-type '("html" "xml"))) ) ((member language '("javascript" "typescript" "jsx" "ruby")) (setq reg-col (if web-mode-script-padding (+ reg-col web-mode-script-padding) 0))) ((member language '("css" "sql" "markdown" "pug" "sass" "stylus")) (setq reg-col (if web-mode-style-padding (+ reg-col web-mode-style-padding) 0))) ((not (member language '("html" "xml"))) (setq reg-col (cond ((not web-mode-block-padding) reg-col) ((eq web-mode-block-padding -1) 0) (t (+ reg-col web-mode-block-padding)) ) ;cond ) ;setq ) ) (list :curr-char curr-char :curr-indentation curr-indentation :curr-line curr-line :language language :options options :prev-char prev-char :prev-indentation prev-indentation :prev-line prev-line :prev-pos prev-pos :reg-beg reg-beg :reg-col reg-col :token token) ))) (defun web-mode-indent-line () (web-mode-scan) (let ((offset nil) (char nil) (debug nil) (inhibit-modification-hooks nil) (adjust t)) (save-excursion (back-to-indentation) (setq char (char-after)) (let* ((pos (point)) (ctx (web-mode-point-context pos)) (curr-char (plist-get ctx :curr-char)) (curr-indentation (plist-get ctx :curr-indentation)) (curr-line (plist-get ctx :curr-line)) (language (plist-get ctx :language)) (prev-char (plist-get ctx :prev-char)) (prev-indentation (plist-get ctx :prev-indentation)) (prev-line (plist-get ctx :prev-line)) (prev-pos (plist-get ctx :prev-pos)) (reg-beg (plist-get ctx :reg-beg)) (reg-col (plist-get ctx :reg-col)) (token (plist-get ctx :token)) (options (plist-get ctx :options)) (chars (list curr-char prev-char)) (tmp nil) (is-js (member language '("javascript" "jsx" "ejs")))) (when (member language '("json" "typescript")) (setq language "javascript")) ;;(message "%S" language) ;;(message "curr-char=[%c] prev-char=[%c]\n%S" curr-char prev-char ctx) ;;(message "options=%S" ctx) (cond ((or (bobp) (= (line-number-at-pos pos) 1)) (when debug (message "I100(%S) first line" pos)) (setq offset 0)) ;; #123 #1145 ((and web-mode-enable-front-matter-block (eq (char-after (point-min)) ?\-) (or (looking-at-p "---") (search-forward "---" (point-max) t))) (when debug (message "I108(%S) front-matter-block" pos)) (setq offset nil)) ;; #1073 ((get-text-property pos 'invisible) (when debug (message "I110(%S) invible" pos)) (setq offset nil)) ((string= token "string") (when debug (message "I120(%S) string" pos)) (cond ((web-mode-is-token-end pos) (if (get-text-property pos 'block-side) (web-mode-block-token-beginning) (web-mode-part-token-beginning)) (setq offset (current-indentation)) ) ((and web-mode-enable-sql-detection (web-mode-block-token-starts-with (concat "[ \n]*" web-mode-sql-queries))) (save-excursion (let (col) (web-mode-block-string-beginning) (skip-chars-forward "[ \"'\n]") (setq col (current-column)) (goto-char pos) (if (looking-at-p "\\(SELECT\\|INSERT\\|DELETE\\|UPDATE\\|FROM\\|LEFT\\|JOIN\\|WHERE\\|GROUP BY\\|LIMIT\\|HAVING\\|\)\\)") (setq offset col) (setq offset (+ col web-mode-sql-indent-offset))) ) ) ;save-excursion ) ((and is-js (web-mode-is-ql-string pos "Relay\.QL")) (setq offset (web-mode-relayql-indentation pos)) ) ((and is-js (web-mode-is-ql-string pos "gql")) (setq offset (web-mode-relayql-indentation pos "gql")) ) ((and is-js (web-mode-is-ql-string pos "graphql")) (setq offset (web-mode-relayql-indentation pos "graphql")) ) ((and is-js (web-mode-is-css-string pos)) (when debug (message "I127(%S) css string" pos)) (setq offset (web-mode-token-css-indentation pos)) ) ((and is-js (web-mode-is-html-string pos)) (when debug (message "I128(%S) html string" pos)) (setq offset (web-mode-token-html-indentation pos)) ) (t (setq offset nil)) ) ;cond ) ;case string ((string= token "comment") (when debug (message "I130(%S) comment" pos)) (if (eq (get-text-property pos 'tag-type) 'comment) (web-mode-tag-beginning) (goto-char (car (web-mode-property-boundaries (if (eq (get-text-property pos 'part-token) 'comment) 'part-token 'block-token) pos)))) (setq offset (current-column)) (cond ((string= web-mode-engine "freemarker") (setq offset (+ (current-indentation) 2))) ((member (buffer-substring-no-properties (point) (+ (point) 2)) '("/*" "{*" "@*")) (cond ((eq ?\* curr-char) (setq offset (+ offset 1))) (t (setq offset (+ offset 3))) ) ;cond ) ((string= (buffer-substring-no-properties (point) (+ (point) 4)) "" curr-line) (setq offset offset)) ((string-match-p "^-" curr-line) (setq offset (+ offset 3))) (t (setq offset (+ offset 5))) ) ;cond ) ((and (string= web-mode-engine "django") (looking-back "{% comment %}" (point-min))) (setq offset (- offset 12))) ((and (string= web-mode-engine "mako") (looking-back "<%doc%>" (point-min))) (setq offset (- offset 6))) ((and (string= web-mode-engine "mason") (looking-back "<%doc%>" (point-min))) (setq offset (- offset 6))) ) ;cond ) ;case comment ((and (string= web-mode-engine "mason") (string-match-p "^%" curr-line)) (when debug (message "I140(%S) mason" pos)) (setq offset 0)) ((and (get-text-property pos 'block-beg) (or (web-mode-block-is-close pos) (web-mode-block-is-inside pos))) (when debug (message "I150(%S) block-match" pos)) (cond ((not (web-mode-block-match)) ) ((and (string= web-mode-engine "closure") (string-match-p "{\\(case\\|default\\)" curr-line)) (setq offset (+ (current-indentation) web-mode-markup-indent-offset))) (t (setq offset (current-indentation)) (if (and (string= web-mode-engine "blade") (string-match-p "@break" curr-line)) (setq offset (+ (current-indentation) offset))) ) ) ;cond ) ((eq (get-text-property pos 'block-token) 'delimiter-end) (when debug (message "I160(%S) block-beginning" pos)) (when (web-mode-block-beginning) (setq reg-col (current-indentation)) (setq offset (current-column)))) ((or (and (get-text-property pos 'tag-beg) (eq (get-text-property pos 'tag-type) 'end)) (and (eq (get-text-property pos 'tag-type) 'comment) (string-match-p "" (point)) (web-mode-insert-text-at-pos "" (point)) (web-mode-insert-text-at-pos "") (search-backward " -->") ) ;case html ) ;cond )) (defun web-mode-comment (pos) (let (ctx language col sel beg end tmp block-side single-line-block pos-after content) (setq pos-after pos) (setq block-side (get-text-property pos 'block-side)) (setq single-line-block (web-mode-is-single-line-block pos)) (cond ((and block-side (string= web-mode-engine "erb")) (web-mode-comment-erb-block pos) ) ((and block-side (string= web-mode-engine "artanis")) (web-mode-comment-artanis-block pos) ) ((and single-line-block block-side (intern-soft (concat "web-mode-comment-" web-mode-engine "-block"))) (funcall (intern (concat "web-mode-comment-" web-mode-engine "-block")) pos) ) (t (setq ctx (web-mode-point-context (if mark-active (region-beginning) (line-beginning-position)))) ;;(message "%S" ctx) (setq language (plist-get ctx :language)) (setq col (current-column)) (cond (mark-active ;;(message "%S %S" (point) col) ) ((and (member language '("html" "xml")) (get-text-property (progn (back-to-indentation) (point)) 'tag-beg)) (web-mode-element-select)) (t (end-of-line) (set-mark (line-beginning-position))) ) ;cond (setq beg (region-beginning) end (region-end)) (when (> (point) (mark)) (exchange-point-and-mark)) (if (and (eq (char-before end) ?\n) (not (eq (char-after end) ?\n))) (setq end (1- end))) (setq sel (buffer-substring-no-properties beg end)) (cond ((member language '("html" "xml")) (cond ((and (= web-mode-comment-style 2) (string= web-mode-engine "django")) (setq content (concat "{# " sel " #}"))) ((and (= web-mode-comment-style 2) (member web-mode-engine '("ejs" "erb"))) (setq content (concat "<%# " sel " %>"))) ((and (= web-mode-comment-style 2) (string= web-mode-engine "artanis")) (setq content (concat "<%; " sel " %>"))) ((and (= web-mode-comment-style 2) (string= web-mode-engine "aspx")) (setq content (concat "<%-- " sel " --%>"))) ((and (= web-mode-comment-style 2) (string= web-mode-engine "smarty")) (setq content (concat "{* " sel " *}"))) ((and (= web-mode-comment-style 2) (string= web-mode-engine "expressionengine")) (setq content (concat "{!-- " sel " --}"))) ((and (= web-mode-comment-style 2) (string= web-mode-engine "xoops")) (setq content (concat "<{* " sel " *}>"))) ((and (= web-mode-comment-style 2) (string= web-mode-engine "hero")) (setq content (concat "<%# " sel " %>"))) ((and (= web-mode-comment-style 2) (string= web-mode-engine "blade")) (setq content (concat "{{-- " sel " --}}"))) ((and (= web-mode-comment-style 2) (string= web-mode-engine "ctemplate")) (setq content (concat "{{!-- " sel " --}}"))) ((and (= web-mode-comment-style 2) (string= web-mode-engine "razor")) (setq content (concat "@* " sel " *@"))) (t (setq content (concat "")) (when (< (length sel) 1) (search-backward " -->") (setq pos-after nil)) )) ) ;case html ((member language '("php" "javascript" "typescript" "java" "jsx")) (let (alt) (setq alt (cdr (assoc language web-mode-comment-formats))) ;;(message "language=%S alt=%S sel=%S col=%S" language alt sel col) (cond ((and alt (string= alt "//")) (setq content (replace-regexp-in-string (concat "\n[ ]\\{" (number-to-string col) "\\}") "\n" sel)) (setq content (replace-regexp-in-string (concat "\n") "\n// " content)) (setq content (concat "// " content))) ((get-text-property pos 'jsx-depth) (setq content (concat "{/* " sel " */}"))) (web-mode-comment-prefixing (setq content (replace-regexp-in-string (concat "\n[ ]\\{" (number-to-string col) "\\}") "\n* " sel)) (setq content (concat "/* " content " */"))) (t (setq content (concat "/* " sel " */"))) ) ;cond ) ;let ) ((member language '("erb")) (setq content (replace-regexp-in-string "^[ ]*" "#" sel))) ((member language '("asp")) (setq content (replace-regexp-in-string "^[ ]*" "''" sel))) (t (setq content (concat "/* " sel " */"))) ) ;cond (when content (delete-region beg end) (deactivate-mark) (let (beg end) (setq beg (point-at-bol)) (insert content) (setq end (point-at-eol)) (indent-region beg end) ) ) ;when ) ;t ) ;cond (when pos-after (goto-char pos-after)) )) (defun web-mode-comment-ejs-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-insert-text-at-pos "//" (+ beg 2)))) (defun web-mode-comment-erb-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-insert-text-at-pos "#" (+ beg 2)))) (defun web-mode-comment-artanis-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-insert-text-at-pos ";" (+ beg 2)))) (defun web-mode-comment-django-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-insert-text-at-pos "#" end) (web-mode-insert-text-at-pos "#" (1+ beg)))) (defun web-mode-comment-dust-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-insert-text-at-pos "!" end) (web-mode-insert-text-at-pos "!" (1+ beg)))) (defun web-mode-comment-aspx-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-insert-text-at-pos "#" end) (web-mode-insert-text-at-pos "#" (1+ beg)))) (defun web-mode-comment-jsp-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-insert-text-at-pos "--" (+ beg 2)))) (defun web-mode-comment-go-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-insert-text-at-pos "*/" (1- end)) (web-mode-insert-text-at-pos "/*" (+ beg (if (web-mode-looking-at "{{" beg) 2 0))))) (defun web-mode-comment-php-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-insert-text-at-pos "*/" (- end 2)) (web-mode-insert-text-at-pos "/*" (+ beg 1 (if (web-mode-looking-at "<\\?php" beg) 5 3))))) (defun web-mode-comment-svelte-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-insert-text-at-pos "!" end) (web-mode-insert-text-at-pos "!" (1+ beg)))) (defun web-mode-comment-boundaries (&optional pos) (interactive) (unless pos (setq pos (point))) (let ((beg pos) (end pos) prop) (save-excursion (goto-char pos) (setq prop (cond ((eq (get-text-property pos 'block-token) 'comment) 'block-token) ((eq (get-text-property pos 'tag-type) 'comment) 'tag-type) ((eq (get-text-property pos 'part-token) 'comment) 'part-token) (t nil) )) (if (null prop) (setq beg nil end nil) (when (and (not (bobp)) (eq (get-text-property pos prop) (get-text-property (1- pos) prop))) (setq beg (or (previous-single-property-change pos prop) (point-min)))) (when (and (not (eobp)) (eq (get-text-property pos prop) (get-text-property (1+ pos) prop))) (setq end (or (next-single-property-change pos prop) (point-max))))) (message "beg(%S) end(%S) point-max(%S)" beg end (point-max)) (when (and beg (string= (buffer-substring-no-properties beg (+ beg 2)) "//")) (goto-char end) (while (and (looking-at-p "\n[ ]*//") (not (eobp))) (search-forward "//") (backward-char 2) ;;(message "%S" (point)) (setq end (next-single-property-change (point) prop)) (goto-char end) ;;(message "%S" (point)) ) ;while ) ;when ;;(when end (setq end (1- end))) ;; #1021 ) ;save-excursion ;;(message "beg=%S end=%S" beg end) (if (and beg end) (cons beg end) nil) )) (defun web-mode-uncomment (pos) (let ((beg pos) (end pos) (sub2 "") comment boundaries) (save-excursion (cond ((and (get-text-property pos 'block-side) (intern-soft (concat "web-mode-uncomment-" web-mode-engine "-block"))) (funcall (intern (concat "web-mode-uncomment-" web-mode-engine "-block")) pos)) ((and (setq boundaries (web-mode-comment-boundaries pos)) (setq beg (car boundaries)) (setq end (1+ (cdr boundaries))) (> (- end beg) 4)) (when (and (get-text-property beg 'jsx-depth) (eq (char-after (1- beg)) ?\{)) (setq beg (1- beg) end (1+ end))) ;;(message "%S" boundaries) ;;(message "beg(%S) end(%S)" beg end) (setq comment (buffer-substring-no-properties beg end)) (setq sub2 (substring comment 0 2)) (cond ((member sub2 '("$\\)" "" comment))) ((string= sub2 "{#") (setq comment (replace-regexp-in-string "\\(^{#[ ]?\\|[ ]?#}$\\)" "" comment))) ((string= sub2 "{/") ;jsx comments (setq comment (replace-regexp-in-string "\\(^{/\\*[ ]?\\|[ ]?\\*/}$\\)" "" comment))) ((string= sub2 "/*") ;;(message "%S" comment) ;;(setq comment (replace-regexp-in-string "\\(\\*/\\|^/\\*[ ]?\\|^[ \t]*\\*\\)" "" comment)) (setq comment (replace-regexp-in-string "\\([ ]?\\*/$\\|^/\\*[ ]?\\)" "" comment)) (setq comment (replace-regexp-in-string "\\(^[ \t]*\\*\\)" "" comment)) ;;(message "%S" comment) ) ((string= sub2 "//") (setq comment (replace-regexp-in-string "^ *//" "" comment))) ) ;cond (delete-region beg end) (web-mode-insert-and-indent comment) (goto-char beg) ) ) ;cond (indent-according-to-mode) ))) (defun web-mode-uncomment-erb-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (cond ((string= (buffer-substring-no-properties beg (+ beg 4)) "<%#=") (web-mode-remove-text-at-pos 1 (+ beg 2))) ((string-match-p "<[%[:alpha:]]" (buffer-substring-no-properties (+ beg 2) (- end 2))) (web-mode-remove-text-at-pos 2 (1- end)) (web-mode-remove-text-at-pos 3 beg)) (t (web-mode-remove-text-at-pos 1 (+ beg 2))) ) ;cond ) ) (defun web-mode-uncomment-artanis-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (cond ((string= (buffer-substring-no-properties beg (+ beg 4)) "<%;=") (web-mode-remove-text-at-pos 1 (+ beg 2))) ((string-match-p "<[%[:alpha:]]" (buffer-substring-no-properties (+ beg 2) (- end 2))) (web-mode-remove-text-at-pos 2 (1- end)) (web-mode-remove-text-at-pos 3 beg)) (t (web-mode-remove-text-at-pos 1 (+ beg 2))) ) ;cond ) ) (defun web-mode-uncomment-ejs-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-remove-text-at-pos 1 (+ beg 2)))) (defun web-mode-uncomment-django-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (cond ((web-mode-looking-at-p "{#[{%]" beg) (web-mode-remove-text-at-pos 1 (1- end)) (web-mode-remove-text-at-pos 1 (1+ beg)) ) (t (web-mode-remove-text-at-pos 2 (1- end)) (web-mode-remove-text-at-pos 2 beg)) ) ;cond )) (defun web-mode-uncomment-ctemplate-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-remove-text-at-pos 5 (- end 4)) (web-mode-remove-text-at-pos 5 beg))) (defun web-mode-uncomment-dust-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-remove-text-at-pos 1 (1- end)) (web-mode-remove-text-at-pos 1 (1+ beg)))) (defun web-mode-uncomment-aspx-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-remove-text-at-pos 1 (1- end)) (web-mode-remove-text-at-pos 1 (1+ beg)))) (defun web-mode-uncomment-jsp-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-remove-text-at-pos 2 (+ beg 2)))) (defun web-mode-uncomment-go-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-remove-text-at-pos 2 (+ beg 2)) (web-mode-remove-text-at-pos 2 (- end 5)))) (defun web-mode-uncomment-svelte-block (pos) (let (beg end) (setq beg (web-mode-block-beginning-position pos) end (web-mode-block-end-position pos)) (web-mode-remove-text-at-pos 1 (1- end)) (web-mode-remove-text-at-pos 1 (1+ beg)))) (defun web-mode-snippet-names () (let (codes) (dolist (snippet web-mode-snippets) (add-to-list 'codes (car snippet) t)) codes)) (defun web-mode-snippet-insert (code) "Insert a snippet." (interactive (list (completing-read "Snippet: " (web-mode-snippet-names)))) (let (beg (continue t) (counter 0) end sel snippet (l (length web-mode-snippets)) pos) (when mark-active (setq sel (web-mode-trim (buffer-substring-no-properties (region-beginning) (region-end)))) (delete-region (region-beginning) (region-end))) (while (and continue (< counter l)) (setq snippet (nth counter web-mode-snippets)) (when (string= (car snippet) code) (setq continue nil)) (setq counter (1+ counter))) (when snippet (setq snippet (cdr snippet)) (setq beg (point-at-bol)) (insert snippet) (setq pos (point) end (point)) (cond ((string-match-p "¦" snippet) (search-backward "¦") (delete-char 1) (setq pos (point) end (1- end))) ((string-match-p "|" snippet) (search-backward "|") (delete-char 1) (setq pos (point) end (1- end))) ) ;cond (when sel (insert sel) (setq pos (point) end (+ end (length sel)))) (goto-char end) (setq end (point-at-eol)) (unless sel (goto-char pos)) (indent-region beg end)) )) (defun web-mode-looking-at (regexp pos) (save-excursion (goto-char pos) (looking-at regexp))) (defun web-mode-looking-at-p (regexp pos) (save-excursion (goto-char pos) (looking-at-p regexp))) (defun web-mode-looking-back (regexp pos &optional limit greedy) (save-excursion (goto-char pos) (if limit (looking-back regexp limit greedy) (looking-back regexp (point-min))))) (defun web-mode-insert-text-at-pos (text pos) (let ((mem web-mode-enable-auto-pairing)) (setq web-mode-enable-auto-pairing nil) (save-excursion (goto-char pos) (insert text) (setq web-mode-enable-auto-pairing mem) ))) (defun web-mode-remove-text-at-pos (n &optional pos) (unless pos (setq pos (point))) (delete-region pos (+ pos n))) (defun web-mode-insert-and-indent (text) (let (beg end) (setq beg (point-at-bol)) (insert text) (setq end (point-at-eol)) (indent-region beg end) )) (defun web-mode-column-at-pos (pos) (save-excursion (goto-char pos) (current-column))) (defun web-mode-indentation-at-pos (pos) (save-excursion (goto-char pos) (current-indentation))) (defun web-mode-navigate (&optional pos) "Move point to the matching opening/closing tag/block." (interactive) (unless pos (setq pos (point))) (let (init) (goto-char pos) (setq init (point)) (when (> (current-indentation) (current-column)) (back-to-indentation)) (setq pos (point)) (cond ((and (get-text-property pos 'block-side) (web-mode-block-beginning) (web-mode-block-controls-get (point))) (web-mode-block-match)) ((member (get-text-property pos 'tag-type) '(start end)) (web-mode-tag-beginning) (web-mode-tag-match)) (t (goto-char init)) ) )) (defun web-mode-block-match (&optional pos) (unless pos (setq pos (point))) (let (pos-ori controls control (counter 1) type (continue t) pair) (setq pos-ori pos) (goto-char pos) (setq controls (web-mode-block-controls-get pos)) ;;(message "controls=%S" controls) (cond (controls (setq pair (car controls)) (setq control (cdr pair)) (setq type (car pair)) (when (eq type 'inside) (setq type 'close)) (while continue (cond ((and (> pos-ori 1) (bobp)) (setq continue nil)) ((or (and (eq type 'open) (not (web-mode-block-next))) (and (eq type 'close) (not (web-mode-block-previous)))) (setq continue nil) ) ((null (setq controls (web-mode-block-controls-get (point)))) ) (t ;;TODO : est il nécessaire de faire un reverse sur controls si on doit matcher backward (dolist (pair controls) (cond ((not (string= (cdr pair) control)) ) ((eq (car pair) 'inside) ) ((eq (car pair) type) (setq counter (1+ counter))) (t (setq counter (1- counter))) ) ) ;dolist (when (= counter 0) (setq continue nil)) ) ;t ) ;cond ) ;while (if (= counter 0) (point) nil) ) ;controls (t (goto-char pos-ori) nil ) ;controls = nul ) ;conf )) (defun web-mode-tag-match (&optional pos) "Move point to the matching opening/closing tag." (interactive) (unless pos (setq pos (point))) (let (regexp name) (cond ((eq (get-text-property pos 'tag-type) 'void) (web-mode-tag-beginning)) ((and (eq (get-text-property pos 'tag-type) 'comment) (web-mode-looking-at-p " %S %S" pos (get-text-property pos 'jsx-depth)) ) ((and blockside (member (get-text-property pos 'block-token) '(string comment)) (eq (get-text-property pos 'block-token) (get-text-property (1- pos) 'block-token))) (setq pos (web-mode-block-token-beginning-position pos))) ((and (not blockside) (member (get-text-property pos 'part-token) '(string comment)) (eq (get-text-property pos 'part-token) (get-text-property (1- pos) 'part-token))) (setq pos (web-mode-part-token-beginning-position pos))) ((and (not blockside) (get-text-property pos 'block-side)) (when (setq pos (web-mode-block-beginning-position pos)) (setq pos (1- pos)))) ((member char '(?\) ?\] ?\})) (setq pos (web-mode-part-opening-paren-position pos reg-beg)) (setq pos (1- pos))) ((and (eq char ?\=) (web-mode-looking-back "[<>!=]+" pos reg-beg t)) (setq pos (- pos 1 (length (match-string-no-properties 0))))) ((member char '(?\( ?\{ ?\[ ?\= ?\< ?\>)) (web-mode-looking-at ".[ \t\n]*" pos) (setq continue nil pos (+ pos (length (match-string-no-properties 0))))) ((web-mode-looking-at "\\(return\\)[ \n]" pos) (setq continue nil pos (+ pos (length (match-string-no-properties 0))))) ((and (eq char ?\:) (web-mode-looking-back "[{,][ \t\n]*[[:alnum:]_]+[ ]*" pos)) (web-mode-looking-at ".[ \t\n]*" pos) (setq continue nil pos (+ pos (length (match-string-no-properties 0))))) (t (setq pos (web-mode-rsb-position pos regexp reg-beg)) (when (not pos) (cond (is-jsx (when (web-mode-looking-at "[ \n]*" reg-beg) (setq pos (+ reg-beg (length (match-string-no-properties 0))))) (setq continue nil)) (t (message "javascript-statement-beginning-position ** search failure **") (setq continue nil pos reg-beg)) ) ;cond ) ) ;t ) ;cond ) ;while ;;(message "%S -------" pos) pos)) (defun web-mode-javascript-args-beginning-position (pos &optional reg-beg) (unless pos (setq pos (point))) (setq pos (1- pos)) (let ((char nil) (blockside (get-text-property pos 'block-side)) (i 0) (continue (not (null pos)))) (unless reg-beg (if blockside (setq reg-beg (web-mode-block-beginning-position pos)) (setq reg-beg (web-mode-part-beginning-position pos))) ) (while continue (setq char (char-after pos)) ;;(message "pos(%S) char(%c)" pos char) (cond ((> (setq i (1+ i)) 20000) (message "javascript-args-beginning-position ** warning (%S) **" pos) (setq continue nil pos nil)) ((null pos) (message "javascript-args-beginning-position ** invalid pos **") (setq continue nil)) ((< pos reg-beg) (message "javascript-args-beginning-position ** failure(position) **") (setq continue nil pos reg-beg)) ((and blockside (member (get-text-property pos 'block-token) '(string comment)) (eq (get-text-property pos 'block-token) (get-text-property (1- pos) 'block-token))) (setq pos (web-mode-block-token-beginning-position pos))) ((and (not blockside) (member (get-text-property pos 'part-token) '(string comment)) (eq (get-text-property pos 'part-token) (get-text-property (1- pos) 'part-token))) (setq pos (web-mode-part-token-beginning-position pos))) ((and (not blockside) (get-text-property pos 'block-side)) (when (setq pos (web-mode-block-beginning-position pos)) (setq pos (1- pos))) ) ((member char '(?\) ?\] ?\})) (when (setq pos (web-mode-part-opening-paren-position pos reg-beg)) (setq pos (1- pos)))) ((member char '(?\( ?\[ ?\{)) (web-mode-looking-at ".[ ]*" pos) (setq pos (+ pos (length (match-string-no-properties 0))) continue nil) ) ((web-mode-looking-at "\\(var\\|let\\|return\\|const\\)[ \n]" pos) (setq pos (+ pos (length (match-string-no-properties 0))) continue nil)) (t (setq pos (web-mode-rsb-position pos "[\]\[}{)(]\\|\\(var\\|let\\|return\\|const\\)" reg-beg)) (when (not pos) (message "javascript-args-beginning-position ** search failure **") (setq continue nil pos reg-beg))) ) ;cond ) ;while ;;(message "=%S" pos) pos)) (defun web-mode-javascript-calls-beginning-position (pos &optional reg-beg) (unless pos (setq pos (point))) ;;(message "pos=%S" pos) (let ((char nil) (dot-pos nil) (blockside (get-text-property pos 'block-side)) (i 0) (continue (not (null pos)))) (unless reg-beg (setq reg-beg (if blockside (web-mode-block-beginning-position pos) (web-mode-part-beginning-position pos)))) (while continue (setq char (char-after pos)) ;;(message "%S| %S=%c" reg-beg pos char) (cond ((> (setq i (1+ i)) 20000) (message "javascript-calls-beginning-position ** warning (%S) **" pos) (setq continue nil pos nil)) ((null pos) (message "javascript-calls-beginning-position ** invalid pos **") (setq continue nil)) ((< pos reg-beg) (setq continue nil pos reg-beg)) ((and blockside (member (get-text-property pos 'block-token) '(string comment)) (eq (get-text-property pos 'block-token) (get-text-property (1- pos) 'block-token))) (setq pos (web-mode-block-token-beginning-position pos))) ((and (not blockside) (member (get-text-property pos 'part-token) '(string comment)) (eq (get-text-property pos 'part-token) (get-text-property (1- pos) 'part-token))) (setq pos (web-mode-part-token-beginning-position pos))) ((and (not blockside) (get-text-property pos 'block-side)) (when (setq pos (web-mode-block-beginning-position pos)) (setq pos (1- pos)))) ((and (member char '(?\.)) (> i 1)) (setq dot-pos pos pos (1- pos))) ((member char '(?\) ?\])) (when (setq pos (web-mode-part-opening-paren-position pos reg-beg)) (setq pos (1- pos))) ) ((member char '(?\( ?\{ ?\} ?\[ ?\= ?\? ?\: ?\; ?\, ?\& ?\| ?\>)) (web-mode-looking-at ".[ \t\n]*" pos) (setq pos (+ pos (length (match-string-no-properties 0))) continue nil)) ((web-mode-looking-at "\\(return\\|else\\|const\\)[ \n]" pos) (setq pos (+ pos (length (match-string-no-properties 0))) continue nil)) (t (setq pos (web-mode-rsb-position pos "[\]\[}{)(=?:;,&|>.]\\|\\(return\\|else\\|const\\)" reg-beg)) (when (not pos) (message "javascript-calls-beginning-position ** search failure **") (setq pos reg-beg continue nil)) ) ;t ) ;cond ) ;while ;;(message "pos=%S dot-pos=%S" pos dot-pos) (if (null pos) pos (cons pos dot-pos)) )) (defun web-mode-part-token-beginning-position (&optional pos) (unless pos (setq pos (point))) (cond ((not (get-text-property pos 'part-token)) nil) ((or (= pos (point-min)) (and (> pos (point-min)) (not (get-text-property (1- pos) 'part-token)))) pos) (t (setq pos (previous-single-property-change pos 'part-token)) (if (and pos (> pos (point-min))) pos (point-min))) )) (defun web-mode-part-token-end-position (&optional pos) (unless pos (setq pos (point))) (cond ((not (get-text-property pos 'part-token)) nil) ((or (= pos (point-max)) (not (get-text-property (1+ pos) 'part-token))) pos) (t (1- (next-single-property-change pos 'part-token))) )) (defun web-mode-block-token-beginning-position (&optional pos) (unless pos (setq pos (point))) (cond ((not (get-text-property pos 'block-token)) nil) ((or (= pos (point-min)) (and (> pos (point-min)) (not (get-text-property (1- pos) 'block-token)))) pos) (t (setq pos (previous-single-property-change pos 'block-token)) (if (and pos (> pos (point-min))) pos (point-min))) )) (defun web-mode-block-token-end-position (&optional pos) (unless pos (setq pos (point))) (cond ((not (get-text-property pos 'block-token)) nil) ((or (= pos (point-max)) (not (get-text-property (1+ pos) 'block-token))) pos) (t (1- (next-single-property-change pos 'block-token))) )) (defun web-mode-block-code-end-position (&optional pos) (unless pos (setq pos (point))) (setq pos (web-mode-block-end-position pos)) (cond ((not pos) nil) ((and (eq (get-text-property pos 'block-token) 'delimiter-end) (eq (get-text-property (1- pos) 'block-token) 'delimiter-end)) (previous-single-property-change pos 'block-token)) ((= pos (1- (point-max))) ;; TODO: comparer plutot avec line-end-position (point-max)) (t pos) )) (defun web-mode-block-end-position (&optional pos) (unless pos (setq pos (point))) (cond ((get-text-property pos 'block-end) pos) ((get-text-property pos 'block-side) (or (next-single-property-change pos 'block-end) (point-max))) (t nil) )) (defun web-mode-block-previous-position (&optional pos) (unless pos (setq pos (point))) (cond ((= pos (point-min)) (setq pos nil)) ((get-text-property pos 'block-side) (setq pos (web-mode-block-beginning-position pos)) (cond ((or (null pos) (= pos (point-min))) (setq pos nil) ) ((and (setq pos (previous-single-property-change pos 'block-beg)) (> pos (point-min))) (setq pos (1- pos)) ) ) ) ;block-side ((get-text-property (1- pos) 'block-side) (setq pos (web-mode-block-beginning-position (1- pos))) ) (t (setq pos (previous-single-property-change pos 'block-side)) (cond ((and (null pos) (get-text-property (point-min) 'block-beg)) (setq pos (point-min))) ((and pos (> pos (point-min))) (setq pos (web-mode-block-beginning-position (1- pos)))) ) ) ) ;conf pos) (defun web-mode-block-next-position (&optional pos limit) (unless pos (setq pos (point))) (unless limit (setq limit (point-max))) (cond ((and (get-text-property pos 'block-side) (setq pos (web-mode-block-end-position pos)) (< pos (point-max)) (setq pos (1+ pos))) (unless (get-text-property pos 'block-beg) (setq pos (next-single-property-change pos 'block-side))) ) (t (setq pos (next-single-property-change pos 'block-side))) ) ;cond (if (and pos (<= pos limit)) pos nil)) (defun web-mode-is-css-string (pos) (let (beg) (cond ((and (setq beg (web-mode-part-token-beginning-position pos)) (web-mode-looking-at-p "`" beg) (web-mode-looking-back "\\(styled[[:alnum:].]+\\|css\\)" beg)) beg) (t nil) ) ;cond )) ;; Relay.QL , gql, graphql (defun web-mode-is-ql-string (pos prefix-regexp) (let (beg) (cond ((and (setq beg (web-mode-part-token-beginning-position pos)) (web-mode-looking-back prefix-regexp beg)) beg) (t nil) ) ;cond )) (defun web-mode-is-html-string (pos) (let (beg) (cond ((and (setq beg (web-mode-part-token-beginning-position pos)) (web-mode-looking-at-p "`[ \t\n]*<[a-zA-Z]" beg) (web-mode-looking-back "\\(template\\|html\\)\\([ ]*[=:][ ]*\\)?" beg)) beg) (t nil) ) ;cond )) ;;---- EXCURSION --------------------------------------------------------------- (defun web-mode-backward-sexp (n) (interactive "p") (if (< n 0) (web-mode-forward-sexp (- n)) (let (pos) (dotimes (_ n) (skip-chars-backward "[:space:]") (setq pos (point)) (cond ((bobp) nil) ((get-text-property (1- pos) 'block-end) (backward-char 1) (web-mode-block-beginning)) ((get-text-property (1- pos) 'block-token) (backward-char 1) (web-mode-block-token-beginning)) ((get-text-property (1- pos) 'part-token) (backward-char 1) (web-mode-part-token-beginning)) ((get-text-property (1- pos) 'tag-end) (backward-char 1) (web-mode-element-beginning)) ((get-text-property (1- pos) 'tag-attr) (backward-char 1) (web-mode-attribute-beginning)) ((get-text-property (1- pos) 'tag-type) (backward-char 1) (web-mode-tag-beginning)) ((get-text-property (1- pos) 'jsx-end) (backward-char 1) (web-mode-jsx-beginning)) (t (let ((forward-sexp-function nil)) (backward-sexp)) ) ;case t ) ;cond ) ;dotimes ))) ;let if defun (defun web-mode-forward-sexp (n) (interactive "p") (if (< n 0) (web-mode-backward-sexp (- n)) (let (pos) (dotimes (_ n) (skip-chars-forward "[:space:]") (setq pos (point)) (cond ((eobp) nil) ((get-text-property pos 'block-beg) (web-mode-block-end)) ((get-text-property pos 'block-token) (web-mode-block-token-end)) ((get-text-property pos 'part-token) (web-mode-part-token-end)) ((get-text-property pos 'tag-beg) (web-mode-element-end)) ((get-text-property pos 'tag-attr) (web-mode-attribute-end)) ((get-text-property pos 'tag-type) (web-mode-tag-end)) ((get-text-property pos 'jsx-beg) (web-mode-jsx-end)) (t (let ((forward-sexp-function nil)) (forward-sexp)) ) ;case t ) ;cond ) ;dotimes ))) ;let if defun (defun web-mode-comment-beginning () "Fetch current comment beg." (interactive) (web-mode-go (web-mode-comment-beginning-position (point)))) (defun web-mode-comment-end () "Fetch current comment end." (interactive) (web-mode-go (web-mode-comment-end-position (point)) 1)) (defun web-mode-tag-beginning () "Fetch current html tag beg." (interactive) (web-mode-go (web-mode-tag-beginning-position (point)))) (defun web-mode-tag-end () "Fetch current html tag end." (interactive) (web-mode-go (web-mode-tag-end-position (point)) 1)) (defun web-mode-tag-previous () "Fetch previous tag." (interactive) (web-mode-go (web-mode-tag-previous-position (point)))) (defun web-mode-tag-next () "Fetch next tag. Might be html comment or server tag (e.g. jsp)." (interactive) (web-mode-go (web-mode-tag-next-position (point)))) (defun web-mode-attribute-beginning () "Fetch html attribute beginning." (interactive) (web-mode-go (web-mode-attribute-beginning-position (point)))) (defun web-mode-attribute-end () "Fetch html attribute end." (interactive) (web-mode-go (web-mode-attribute-end-position (point)) 1)) (defun web-mode-attribute-next (&optional arg) "Fetch next attribute." (interactive "p") (unless arg (setq arg 1)) (cond ((= arg 1) (web-mode-go (web-mode-attribute-next-position (point)))) ((< arg 1) (web-mode-element-previous (* arg -1))) (t (while (>= arg 1) (setq arg (1- arg)) (web-mode-go (web-mode-attribute-next-position (point))) ) ) ) ) (defun web-mode-attribute-previous (&optional arg) "Fetch previous attribute." (interactive "p") (unless arg (setq arg 1)) (unless arg (setq arg 1)) (cond ((= arg 1) (web-mode-go (web-mode-attribute-previous-position (point)))) ((< arg 1) (web-mode-element-next (* arg -1))) (t (while (>= arg 1) (setq arg (1- arg)) (web-mode-go (web-mode-attribute-previous-position (point))) ) ) ) ) (defun web-mode-element-previous (&optional arg) "Fetch previous element." (interactive "p") (unless arg (setq arg 1)) (cond ((= arg 1) (web-mode-go (web-mode-element-previous-position (point)))) ((< arg 1) (web-mode-element-next (* arg -1))) (t (while (>= arg 1) (setq arg (1- arg)) (web-mode-go (web-mode-element-previous-position (point))) ) ;while ) ;t ) ;cond ) (defun web-mode-element-next (&optional arg) "Fetch next element." (interactive "p") (unless arg (setq arg 1)) (cond ((= arg 1) (web-mode-go (web-mode-element-next-position (point)))) ((< arg 1) (web-mode-element-previous (* arg -1))) (t (while (>= arg 1) (setq arg (1- arg)) (web-mode-go (web-mode-element-next-position (point))) ) ;while ) ;t ) ;cond ) (defun web-mode-element-sibling-next () "Fetch next sibling element." (interactive) (let ((pos (point))) (save-excursion (cond ((not (get-text-property pos 'tag-type)) (if (and (web-mode-element-parent) (web-mode-tag-match) (web-mode-tag-next) (member (get-text-property (point) 'tag-type) '(start void comment))) (setq pos (point)) (setq pos nil)) ) ((member (get-text-property pos 'tag-type) '(start void)) (if (and (web-mode-tag-match) (web-mode-tag-next) (member (get-text-property (point) 'tag-type) '(start void comment))) (setq pos (point)) (setq pos nil)) ) ((and (web-mode-tag-next) (member (get-text-property (point) 'tag-type) '(start void comment))) (setq pos (point))) (t (setq pos nil)) ) ;cond ) ;save-excursion (web-mode-go pos))) (defun web-mode-element-sibling-previous () "Fetch previous sibling element." (interactive) (let ((pos (point))) (save-excursion (cond ((not (get-text-property pos 'tag-type)) (if (and (web-mode-element-parent) (web-mode-tag-previous) (web-mode-element-beginning)) (setq pos (point)) (setq pos nil)) ) ((eq (get-text-property pos 'tag-type) 'start) (if (and (web-mode-tag-beginning) (web-mode-tag-previous) (web-mode-element-beginning)) (setq pos (point)) (setq pos nil)) ) ((and (web-mode-element-beginning) (web-mode-tag-previous) (web-mode-element-beginning)) (setq pos (point))) (t (setq pos nil)) ) ;cond ) ;save-excursion (web-mode-go pos))) (defun web-mode-element-beginning () "Move to beginning of element." (interactive) (web-mode-go (web-mode-element-beginning-position (point)))) (defun web-mode-element-end () "Move to end of element." (interactive) (web-mode-go (web-mode-element-end-position (point)) 1)) (defun web-mode-element-parent () "Fetch parent element." (interactive) (web-mode-go (web-mode-element-parent-position (point)))) (defun web-mode-element-child () "Fetch child element." (interactive) (web-mode-go (web-mode-element-child-position (point)))) (defun web-mode-dom-traverse () "Traverse html dom tree." (interactive) (cond ((web-mode-element-child) ) ((web-mode-element-sibling-next) ) ((and (web-mode-element-parent) (not (web-mode-element-sibling-next))) (goto-char (point-min))) (t (goto-char (point-min))) ) ;cond ) (defun web-mode-closing-paren (limit) (let ((pos (web-mode-closing-paren-position (point) limit))) (if (or (null pos) (> pos limit)) nil (goto-char pos) pos) )) (defun web-mode-part-next () "Move point to the beginning of the next part." (interactive) (web-mode-go (web-mode-part-next-position (point)))) (defun web-mode-part-beginning () "Move point to the beginning of the current part." (interactive) (web-mode-go (web-mode-part-beginning-position (point)))) (defun web-mode-part-end () "Move point to the end of the current part." (interactive) (web-mode-go (web-mode-part-end-position (point)) 1)) (defun web-mode-block-previous () "Move point to the beginning of the previous block." (interactive) (web-mode-go (web-mode-block-previous-position (point)))) (defun web-mode-block-next () "Move point to the beginning of the next block." (interactive) (web-mode-go (web-mode-block-next-position (point)))) (defun web-mode-block-beginning () "Move point to the beginning of the current block." (interactive) (web-mode-go (web-mode-block-beginning-position (point)))) (defun web-mode-block-end () "Move point to the end of the current block." (interactive) (web-mode-go (web-mode-block-end-position (point)) 1)) (defun web-mode-block-token-beginning () (web-mode-go (web-mode-block-token-beginning-position (point)))) (defun web-mode-block-token-end () (web-mode-go (web-mode-block-token-end-position (point)) 1)) (defun web-mode-part-token-beginning () (web-mode-go (web-mode-part-token-beginning-position (point)))) (defun web-mode-part-token-end () (web-mode-go (web-mode-part-token-end-position (point)) 1)) (defun web-mode-block-opening-paren (limit) (web-mode-go (web-mode-block-opening-paren-position (point) limit))) (defun web-mode-block-string-beginning (&optional pos block-beg) (unless pos (setq pos (point))) (unless block-beg (setq block-beg (web-mode-block-beginning-position pos))) (web-mode-go (web-mode-block-string-beginning-position pos block-beg))) (defun web-mode-block-statement-beginning (pos block-beg is-ternary) (unless pos (setq pos (point))) (unless block-beg (setq block-beg (web-mode-block-beginning-position pos))) (web-mode-go (web-mode-block-statement-beginning-position pos block-beg is-ternary))) (defun web-mode-block-args-beginning (&optional pos block-beg) (unless pos (setq pos (point))) (unless block-beg (setq block-beg (web-mode-block-beginning-position pos))) (web-mode-go (web-mode-block-args-beginning-position pos block-beg))) (defun web-mode-block-calls-beginning (&optional pos block-beg) (unless pos (setq pos (point))) (unless block-beg (setq block-beg (web-mode-block-beginning-position pos))) (web-mode-go (web-mode-block-calls-beginning-position pos block-beg))) (defun web-mode-javascript-string-beginning (&optional pos reg-beg) (unless pos (setq pos (point))) (unless reg-beg (if (get-text-property pos 'block-side) (setq reg-beg (web-mode-block-beginning-position pos)) (setq reg-beg (web-mode-part-beginning-position pos)))) (web-mode-go (web-mode-javascript-string-beginning-position pos reg-beg))) (defun web-mode-javascript-statement-beginning (pos reg-beg is-ternary) (unless pos (setq pos (point))) (unless reg-beg (if (get-text-property pos 'block-side) (setq reg-beg (web-mode-block-beginning-position pos)) (setq reg-beg (web-mode-part-beginning-position pos)))) (web-mode-go (web-mode-javascript-statement-beginning-position pos reg-beg is-ternary))) (defun web-mode-javascript-args-beginning (&optional pos reg-beg) (unless pos (setq pos (point))) (unless reg-beg (setq reg-beg (if (get-text-property pos 'block-side) (web-mode-block-beginning-position pos) (web-mode-part-beginning-position pos)))) ;;(message "reg-beg%S" reg-beg) (web-mode-go (web-mode-javascript-args-beginning-position pos reg-beg))) (defun web-mode-javascript-calls-beginning (&optional pos reg-beg) (unless pos (setq pos (point))) (unless reg-beg (if (get-text-property pos 'block-side) (setq reg-beg (web-mode-block-beginning-position pos)) (setq reg-beg (web-mode-part-beginning-position pos)))) (let (pair) (setq pair (web-mode-javascript-calls-beginning-position pos reg-beg)) (when pair (web-mode-go (car pair))) )) (defun web-mode-go (pos &optional offset) (unless offset (setq offset 0)) (when pos (cond ((and (> offset 0) (<= (+ pos offset) (point-max))) (setq pos (+ pos offset))) ((and (< offset 0) (>= (+ pos offset) (point-min))) (setq pos (+ pos offset))) ) ;cond (goto-char pos)) pos) ;;---- SEARCH ------------------------------------------------------------------ (defun web-mode-rsf-balanced (regexp-open regexp-close &optional limit noerror) (unless noerror (setq noerror t)) (let ((continue t) (level 1) (pos (point)) ret (regexp (concat regexp-open "\\|" regexp-close))) (while continue (setq ret (re-search-forward regexp limit noerror)) (cond ((null ret) (setq continue nil) ) (t (if (string-match-p regexp-open (match-string-no-properties 0)) (setq level (1+ level)) (setq level (1- level))) (when (< level 1) (setq continue nil) ) ) ;t ) ;cond ) ;while (when (not (= level 0)) (goto-char pos)) ret)) (defun web-mode-block-sb (expr &optional limit noerror) (unless limit (setq limit (web-mode-block-beginning-position (point)))) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (search-backward expr limit noerror)) (when (or (null ret) (not (get-text-property (point) 'block-token))) (setq continue nil) ) ;when ) ;while ret)) (defun web-mode-block-sf (expr &optional limit noerror) (unless limit (setq limit (web-mode-block-end-position (point)))) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (search-forward expr limit noerror)) (when (or (null ret) (not (get-text-property (point) 'block-token))) (setq continue nil) ) ;when ) ;while ret)) (defun web-mode-block-rsb (regexp &optional limit noerror) (unless limit (setq limit (web-mode-block-beginning-position (point)))) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (re-search-backward regexp limit noerror)) (when (or (null ret) (not (get-text-property (point) 'block-token))) (setq continue nil) ) ;when ) ;while ret)) (defun web-mode-block-rsf (regexp &optional limit noerror) (unless limit (setq limit (web-mode-block-end-position (point)))) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (re-search-forward regexp limit noerror)) (when (or (null ret) (not (get-text-property (point) 'block-token))) (setq continue nil) ) ;when ) ;while ret)) (defun web-mode-part-sb (expr &optional limit noerror) (unless limit (setq limit (web-mode-part-beginning-position (point)))) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (search-backward expr limit noerror)) (when (or (null ret) (and (not (get-text-property (point) 'part-token)) (not (get-text-property (point) 'block-side))) ) (setq continue nil) ) ;when ) ;while ret)) (defun web-mode-part-sf (expr &optional limit noerror) (unless limit (setq limit (web-mode-part-end-position (point)))) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (search-forward expr limit noerror)) (when (or (null ret) (and (not (get-text-property (point) 'part-token)) (not (get-text-property (point) 'block-side))) ) (setq continue nil) ) ;when ) ;while ret)) (defun web-mode-part-rsb (regexp &optional limit noerror) (unless limit (setq limit (web-mode-part-beginning-position (point)))) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (re-search-backward regexp limit noerror)) (when (or (null ret) (and (not (get-text-property (point) 'part-token)) (not (get-text-property (point) 'block-side))) ) (setq continue nil) ) ;when ) ;while ret)) (defun web-mode-part-rsf (regexp &optional limit noerror) (unless limit (setq limit (web-mode-part-end-position (point)))) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (re-search-forward regexp limit t)) (when (or (null ret) (and (not (get-text-property (point) 'part-token)) (not (get-text-property (point) 'block-side))) ) (setq continue nil) ) ;when ) ;while ret)) (defun web-mode-javascript-rsb (regexp &optional limit noerror) (unless limit (setq limit (web-mode-part-beginning-position (point)))) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (re-search-backward regexp limit noerror)) (when (or (null ret) (and (not (get-text-property (point) 'part-token)) (not (get-text-property (point) 'block-side)) (not (get-text-property (point) 'jsx-depth))) ) (setq continue nil) ) ;when ) ;while ret)) (defun web-mode-javascript-rsf (regexp &optional limit noerror) (unless limit (setq limit (web-mode-part-end-position (point)))) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (re-search-forward regexp limit t)) (when (or (null ret) (and (not (get-text-property (point) 'part-token)) (not (get-text-property (point) 'block-side)) (not (get-text-property (point) 'jsx-depth))) ) (setq continue nil) ) ;when ) ;while ret)) (defun web-mode-dom-sf (expr &optional limit noerror) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (search-forward expr limit noerror)) (if (or (null ret) (not (get-text-property (- (point) (length expr)) 'block-side))) (setq continue nil)) ) ret)) (defun web-mode-dom-rsf (regexp &optional limit noerror) (unless noerror (setq noerror t)) (let ((continue t) (ret nil)) (while continue (setq ret (re-search-forward regexp limit noerror)) ;; (message "ret=%S point=%S limit=%S i=%S" ret (point) limit 0) (cond ((null ret) (setq continue nil)) ((or (get-text-property (match-beginning 0) 'block-side) (get-text-property (match-beginning 0) 'part-token)) ) (t (setq continue nil)) ) ;cond ) ;while ret)) (defun web-mode-rsb-position (pos regexp &optional limit noerror) (unless noerror (setq noerror t)) (save-excursion (goto-char pos) (if (re-search-backward regexp limit noerror) (point) nil) )) (defun web-mode-rsb (regexp &optional limit noerror) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (re-search-backward regexp limit noerror)) (if (or (null ret) (not (web-mode-is-comment-or-string))) (setq continue nil))) ret)) (defun web-mode-rsf (regexp &optional limit noerror) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (re-search-forward regexp limit noerror)) (if (or (null ret) (not (web-mode-is-comment-or-string))) (setq continue nil)) ) ret)) (defun web-mode-sb (expr &optional limit noerror) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (search-backward expr limit noerror)) (if (or (null ret) (not (web-mode-is-comment-or-string))) (setq continue nil))) ret)) (defun web-mode-sf (expr &optional limit noerror) (unless noerror (setq noerror t)) (let ((continue t) ret) (while continue (setq ret (search-forward expr limit noerror)) (if (or (null ret) (not (web-mode-is-comment-or-string))) (setq continue nil))) ret)) (defun web-mode-content-rsf (regexp &optional limit noerror) (unless noerror (setq noerror t)) (let ((continue t) ret beg end) (while continue (setq ret (re-search-forward regexp limit noerror) beg (if (null ret) (point) (match-beginning 0)) end (if (null ret) (point) (1- (match-end 0)))) (if (or (null ret) (and (web-mode-is-content beg) (web-mode-is-content end))) (setq continue nil))) ret)) ;;---- ADVICES ----------------------------------------------------------------- (defadvice ac-start (before web-mode-set-up-ac-sources activate) "Set `ac-sources' based on current language before running auto-complete." (when (equal major-mode 'web-mode) ;; set ignore each time to nil. User has to implement a hook to change it ;; for each completion (setq web-mode-ignore-ac-start-advice nil) (run-hooks 'web-mode-before-auto-complete-hooks) (unless web-mode-ignore-ac-start-advice (when web-mode-ac-sources-alist (let ((new-web-mode-ac-sources (assoc (web-mode-language-at-pos) web-mode-ac-sources-alist))) (setq ac-sources (cdr new-web-mode-ac-sources))))))) ;;---- MINOR MODE ADDONS ------------------------------------------------------- (defun web-mode-yasnippet-exit-hook () "Yasnippet exit hook" (when (and (boundp 'yas-snippet-beg) (boundp 'yas-snippet-end)) (indent-region yas-snippet-beg yas-snippet-end))) (defun web-mode-imenu-index () (interactive) "Returns imenu items." (let (toc-index line) (save-excursion (goto-char (point-min)) (while (not (eobp)) (setq line (buffer-substring-no-properties (line-beginning-position) (line-end-position))) (let (found (i 0) item regexp type type-idx content content-idx content-regexp close-tag-regexp concat-str jumpto str) (while (and (not found ) (< i (length web-mode-imenu-regexp-list))) (setq item (nth i web-mode-imenu-regexp-list)) (setq regexp (nth 0 item)) (setq type-idx (nth 1 item)) (setq content-idx (nth 2 item)) (setq concat-str (nth 3 item)) (when (not (numberp content-idx)) (setq content-regexp (nth 2 item) close-tag-regexp (nth 4 item) content-idx nil)) (when (string-match regexp line) (cond (content-idx (setq type (match-string type-idx line)) (setq content (match-string content-idx line)) (setq str (concat type concat-str content)) (setq jumpto (line-beginning-position))) (t (let (limit) (setq type (match-string type-idx line)) (goto-char (line-beginning-position)) (save-excursion (setq limit (re-search-forward close-tag-regexp (point-max) t))) (when limit (when (re-search-forward content-regexp limit t) (setq content (match-string 1)) (setq str (concat type concat-str content)) (setq jumpto (line-beginning-position)) ) ))) ) (when str (setq toc-index (cons (cons str jumpto) toc-index) ) (setq found t)) ) (setq i (1+ i)))) (forward-line) (goto-char (line-end-position)) ;; make sure we are at eobp )) (nreverse toc-index))) ;;---- UNIT TESTING ------------------------------------------------------------ (defun web-mode-test () "Executes web-mode unit tests. See `web-mode-tests-directory'." (interactive) (let (files ret regexp) (setq regexp "^[[:alnum:]][[:alnum:]._]+\\'") (setq files (directory-files web-mode-tests-directory t regexp)) (dolist (file files) (cond ((eq (string-to-char (file-name-nondirectory file)) ?\_) (delete-file file)) (t (setq ret (web-mode-test-process file))) ) ;cond ) ;dolist )) (defun web-mode-test-process (file) (with-temp-buffer (let (out sig1 sig2 success err) (setq-default indent-tabs-mode nil) (if (string-match-p "sql" file) (setq web-mode-enable-sql-detection t) (setq web-mode-enable-sql-detection nil)) (insert-file-contents file) (set-visited-file-name file) (web-mode) (setq sig1 (md5 (current-buffer))) (delete-horizontal-space) (while (not (eobp)) (forward-line) (delete-horizontal-space) (end-of-line)) (web-mode-buffer-indent) (setq sig2 (md5 (current-buffer))) (setq success (string= sig1 sig2)) (setq out (concat (if success "ok" "ko") " : " (file-name-nondirectory file) "\n")) (princ out) (setq err (concat (file-name-directory file) "_err." (file-name-nondirectory file))) (if success (when (file-readable-p err) (delete-file err)) (write-file err) (message "[%s]" (buffer-string)) ) ;if out))) ;;---- MISC -------------------------------------------------------------------- (defun web-mode-set-engine (engine) "Set the engine for the current buffer." (interactive (list (completing-read "Engine: " (let (engines) (dolist (elt web-mode-engines) (setq engines (append engines (list (car elt))))) engines)))) (setq web-mode-content-type "html" web-mode-engine (web-mode-engine-canonical-name engine) web-mode-minor-engine engine) (web-mode-on-engine-setted) (web-mode-buffer-fontify)) (defun web-mode-set-content-type (content-type) "Set the content-type for the current buffer" (interactive (list (completing-read "Content-type: " web-mode-part-content-types))) (setq web-mode-content-type content-type) (when (called-interactively-p 'any) ) (web-mode-buffer-fontify)) (defun web-mode-on-engine-setted () (let (elt elts engines) (when (string= web-mode-engine "razor") (setq web-mode-enable-block-face t)) ;;(setq web-mode-engine-attr-regexp (cdr (assoc web-mode-engine web-mode-engine-attr-regexps))) (setq web-mode-engine-token-regexp (cdr (assoc web-mode-engine web-mode-engine-token-regexps))) ;;(message "%S %S %S" web-mode-engine web-mode-engine-attr-regexp web-mode-engine-token-regexp) (when (null web-mode-minor-engine) (setq web-mode-minor-engine "none")) (setq elt (assoc web-mode-engine web-mode-engine-open-delimiter-regexps)) (cond (elt (setq web-mode-block-regexp (cdr elt))) ((string= web-mode-engine "archibus") (setq web-mode-block-regexp nil)) (t (setq web-mode-engine "none")) ) (unless (boundp 'web-mode-extra-auto-pairs) (setq web-mode-extra-auto-pairs nil)) (setq web-mode-auto-pairs (append (cdr (assoc web-mode-engine web-mode-engines-auto-pairs)) (cdr (assoc nil web-mode-engines-auto-pairs)) (cdr (assoc web-mode-engine web-mode-extra-auto-pairs)) (cdr (assoc nil web-mode-extra-auto-pairs)))) (unless (boundp 'web-mode-extra-snippets) (setq web-mode-extra-snippets nil)) (setq elts (append (cdr (assoc web-mode-engine web-mode-extra-snippets)) (cdr (assoc nil web-mode-extra-snippets)) (cdr (assoc web-mode-engine web-mode-engines-snippets)) (cdr (assoc nil web-mode-engines-snippets)))) ;;(message "%S" elts) (dolist (elt elts) (unless (assoc (car elt) web-mode-snippets) (setq web-mode-snippets (append (list elt) web-mode-snippets))) ) (setq web-mode-engine-font-lock-keywords (symbol-value (cdr (assoc web-mode-engine web-mode-engines-font-lock-keywords)))) (when (and (string= web-mode-minor-engine "jinja") (not (member "endtrans" web-mode-django-control-blocks))) (add-to-list 'web-mode-django-control-blocks "endtrans") (setq web-mode-django-control-blocks-regexp (regexp-opt web-mode-django-control-blocks t)) ) (when (string= web-mode-engine "spip") (modify-syntax-entry ?# "w" (syntax-table))) ;; (message "%S" (symbol-value (cdr (assoc web-mode-engine web-mode-engines-font-lock-keywords)))) )) (defun web-mode-detect-engine () (save-excursion (goto-char (point-min)) (when (re-search-forward "-\\*- engine:[ ]*\\([[:alnum:]-]+\\)[ ]*-\\*-" web-mode-chunk-length t) (setq web-mode-minor-engine (match-string-no-properties 1)) (setq web-mode-engine (web-mode-engine-canonical-name web-mode-minor-engine))) web-mode-minor-engine)) (defun web-mode-guess-engine-and-content-type () (let (buff-name elt found) (setq buff-name (buffer-file-name)) (unless buff-name (setq buff-name (buffer-name))) (setq web-mode-is-scratch (string= buff-name "*scratch*")) (setq web-mode-content-type nil) (when (boundp 'web-mode-content-types-alist) (setq found nil) (dolist (elt web-mode-content-types-alist) (when (and (not found) (string-match-p (cdr elt) buff-name)) (setq web-mode-content-type (car elt) found t)) ) ;dolist ) ;when (unless web-mode-content-type (setq found nil) (dolist (elt web-mode-content-types) (when (and (not found) (string-match-p (cdr elt) buff-name)) (setq web-mode-content-type (car elt) found t) ;;(message "%S" web-mode-content-type) ) ;when ) ;dolist ) ;unless (when (boundp 'web-mode-engines-alist) (setq found nil) (dolist (elt web-mode-engines-alist) (cond ((stringp (cdr elt)) (when (string-match-p (cdr elt) buff-name) (setq web-mode-engine (car elt)))) ((functionp (cdr elt)) (when (funcall (cdr elt)) (setq web-mode-engine (car elt)))) ) ;cond ) ;dolist ) ;when (unless web-mode-engine (setq found nil) (dolist (elt web-mode-engine-file-regexps) ;;(message "%S %S" (cdr elt) buff-name) (when (and (not found) (string-match-p (cdr elt) buff-name)) (setq web-mode-engine (car elt) found t)) ) ) (when (and (or (null web-mode-engine) (string= web-mode-engine "none")) (string-match-p "php" (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) (setq web-mode-engine "php")) (when (and (string= web-mode-content-type "javascript") (string-match-p "@jsx" (buffer-substring-no-properties (point-min) (if (< (point-max) web-mode-chunk-length) (point-max) web-mode-chunk-length) ))) (setq web-mode-content-type "jsx")) (when web-mode-engine (setq web-mode-minor-engine web-mode-engine web-mode-engine (web-mode-engine-canonical-name web-mode-engine)) ) (when (and (or (null web-mode-engine) (string= web-mode-engine "none")) web-mode-enable-engine-detection) (web-mode-detect-engine)) (web-mode-on-engine-setted) )) (defun web-mode-engine-canonical-name (name) (let (engine) (cond ((null name) nil) ((assoc name web-mode-engines) name) (t (dolist (elt web-mode-engines) (when (and (null engine) (member name (cdr elt))) (setq engine (car elt))) ) ;dolist engine) ))) (defun web-mode-on-after-save () (when web-mode-is-scratch (web-mode-guess-engine-and-content-type) (web-mode-buffer-fontify)) nil) (defun web-mode-on-exit () (web-mode-with-silent-modifications (put-text-property (point-min) (point-max) 'invisible nil) (remove-overlays) (remove-hook 'change-major-mode-hook 'web-mode-on-exit t) )) (defun web-mode-file-link (file) "Insert a link to a file in html document. This function can be extended to support more filetypes by customizing `web-mode-links'." (interactive (list (file-relative-name (read-file-name "Link file: ")))) (let ((matched nil) (point-line (line-number-at-pos)) (point-column (current-column))) (dolist (type web-mode-links) (when (string-match (car type) file) (setq matched t) (when (nth 2 type) (goto-char (point-min)) (search-forward "") (backward-char 7) (open-line 1)) (insert (format (cadr type) file)) (indent-for-tab-command) (when (nth 2 type) ;; return point where it was and fix indentation (forward-line) (indent-for-tab-command) (if (> point-line (- (line-number-at-pos) 2)) (forward-line (+ (- point-line (line-number-at-pos)) 1)) (forward-line (- point-line (line-number-at-pos)))) (move-to-column point-column)) ;; move point back if needed (backward-char (nth 3 type)))) (when (not matched) (user-error "Unknown file type")))) (defun web-mode-reload () "Reload web-mode." (interactive) (web-mode-with-silent-modifications (put-text-property (point-min) (point-max) 'invisible nil) (remove-overlays) (setq font-lock-unfontify-region-function 'font-lock-default-unfontify-region) (load "web-mode.el") (setq web-mode-change-beg nil web-mode-change-end nil) (web-mode) )) (defun web-mode-measure (msg) (let (sub) (when (null web-mode-time) (setq web-mode-time (current-time))) (setq sub (time-subtract (current-time) web-mode-time)) (when nil (save-excursion (let ((n 0)) (goto-char (point-min)) (while (web-mode-tag-next) (setq n (1+ n)) ) (message "%S tags found" n) ))) (message "%18s: time elapsed = %Ss %9Sµs" msg (nth 1 sub) (nth 2 sub)) )) (defun web-mode-reveal () "Display text properties at point." (interactive) (let (symbols out) (setq out (format "[point=%S engine=%S minor=%S content-type=%S language-at-pos=%S]\n" (point) web-mode-engine web-mode-minor-engine web-mode-content-type (web-mode-language-at-pos (point)))) (setq symbols (append web-mode-scan-properties '(font-lock-face face))) (dolist (symbol symbols) (when symbol (setq out (concat out (format "%s(%S) " (symbol-name symbol) (get-text-property (point) symbol))))) ) (message "%s\n" out) ;;(message "syntax-class=%S" (syntax-class (syntax-after (point)))) (message nil))) (defun web-mode-toggle-tracing () "Toggle tracing." (interactive) (if web-mode-trace (setq web-mode-trace nil) (message "** tracing on ** point(%S) web-mode-change-beg(%S) web-mode-change-end(%S) web-mode-skip-fontification(%S)" (point) web-mode-change-beg web-mode-change-end web-mode-skip-fontification) (setq web-mode-trace t))) (defun web-mode-debug () "Display informations useful for debugging." (interactive) (let ((modes nil) (customs '(web-mode-enable-current-column-highlight web-mode-enable-current-element-highlight indent-tabs-mode)) (ignore '(abbrev-mode auto-composition-mode auto-compression-mode auto-encryption-mode auto-insert-mode blink-cursor-mode column-number-mode delete-selection-mode display-time-mode electric-indent-mode file-name-shadow-mode font-lock-mode global-font-lock-mode global-hl-line-mode line-number-mode menu-bar-mode mouse-wheel-mode recentf-mode show-point-mode tool-bar-mode tooltip-mode transient-mark-mode))) (message "\n") (message "--- WEB-MODE DEBUG BEG ---") (message "versions: emacs(%S.%S) web-mode(%S)" emacs-major-version emacs-minor-version web-mode-version) (message "vars: engine(%S) minor(%S) content-type(%S) file(%S)" web-mode-engine web-mode-minor-engine web-mode-content-type (or (buffer-file-name) (buffer-name))) (message "system: window(%S) config(%S)" window-system system-configuration) (message "colors: fg(%S) bg(%S) " (cdr (assoc 'foreground-color default-frame-alist)) (cdr (assoc 'background-color default-frame-alist))) (mapc (lambda (mode) (condition-case nil (if (and (symbolp mode) (symbol-value mode) (not (member mode ignore))) (add-to-list 'modes mode)) (error nil)) ) ;lambda minor-mode-list) (message "minor modes: %S" modes) (message "vars:") (dolist (custom customs) (message (format "%s=%S " (symbol-name custom) (symbol-value custom)))) (message "--- WEB-MODE DEBUG END ---") (switch-to-buffer "*Messages*") (goto-char (point-max)) (recenter) )) (provide 'web-mode) ;;; web-mode.el ends here ;; Local Variables: ;; coding: utf-8 ;; indent-tabs-mode: nil ;; End: