Coder Social home page Coder Social logo

syntactic-close's Introduction

CircleCI syntactic-close

Insert closing delimiter char(s), i.e. parenthesis, bracket(s), brace(s) or whatever is needed - think of syntactic consequence.

Honor multi-char pairs like triplequoted string, padding and escape-sequences.

For example when called at the end of an open string like

"\(^ *\|^Foo: *\|\( BAR\|'s\|Bad\|BAZ\|Bnter\(?: \(?:\(?:sam\|th

C-u M-x syntactic-close RET should result in

"\(^ *\|^Foo: *\|\( BAR\|'s\|Bad\|BAZ\|Bnter\(?: \(?:\(?:sam\|th\)\)\)\)\)"

That way continuation may be inserted by just one key.

Sometimes language-specific treatment is needed.

Currently supports the following modes:

agda2-mode emacs-lisp-mode html-mode js-mode mhtml-mode nxml-mode org-mode php-mode python-mode ruby-mode sgml-mode web-mode xml-mode xxml-mode

Feel free to file a feature request should your favourite mode not being mentioned.

A first draft was proposed at emacs-devel mailing-list: http://lists.gnu.org/archive/html/emacs-devel/2013-09/msg00512.html

syntactic-close's People

Contributors

andreas-roehler avatar pxlpnk avatar amosbird avatar til avatar ptrv avatar tarsius avatar arcli avatar purcell avatar wbolster avatar

Stargazers

Ravioli avatar Aayush avatar  avatar DarkBuffalo avatar Marco Craveiro avatar  avatar Luke Inglis avatar Alex Holder avatar  avatar Jonathan McHugh avatar Dirk Gómez avatar Clemens Radermacher avatar Compro Prasad avatar Oleg Pykhalov avatar Ray Grasso avatar a13ph avatar  avatar  avatar  avatar  avatar Naupaka Zimmerman avatar Stuart Glaser avatar Brendan Jackman avatar Adam Porter avatar Łukasz Korecki avatar  avatar Julien Blanchard avatar Diego Alvarez avatar  avatar Randy Morris avatar Filipe A Moreira avatar  avatar Foivos avatar Alexandra Catalina avatar DarkSun avatar Tu Do avatar Johannes Goslar avatar Corey Reece avatar Johan Lindstrom avatar David Briscoe avatar  avatar  avatar Jorge Araya Navarro avatar Rich Loveland avatar Roland Kaercher avatar pogin avatar François Févotte avatar Anler avatar Michael Abrahams avatar  avatar

Watchers

Daniel Barreto avatar Dirk Gómez avatar pogin avatar James Cloos avatar  avatar Diego Alvarez avatar  avatar  avatar

syntactic-close's Issues

Simple Mode

Hi

Thanks for a great package. Is there an easy way to only have support for "'[({ in all modes and not all the other stuff, like : in python?

Ruby block close might fail.

Delivered two tests which should reveal a Ruby-lang related bug, but succeed strangely in batch-mode:

passed 58/61 syntactic-close-ruby-block-close-XhSYAJ

while getting the failure running them interactively.

Close Org Mode "+BEGIN"-Expressions

Would it be too hard to add org mode's "+BEGIN_QUOTE", "+BEGIN_VERSE", "+BEGIN_EXAMPLE" and "+BEGIN_SRC" to syntactic close? (Akin to C-] in latex-mode, when closing environments) So that would add a corresponding "+END_SRC", "+END_QUOTE", etc.

Inappropriate semicolon in PHP-modus

Hi there! It's me again.

[] stands for the cursor.
Consider the following, while in PHP-mode:

if ($foobar){
    foreach ($foobar as $key =>  $val) {
         echo $key;[]

When I call general-close twice, he places the closing bracket twice with the right indentation. Perfectly. 😃.

However, when the cursor is on a line below, like:

if ($foobar){
    foreach ($foobar as $key =>  $val) ;{
         echo $key;
         []

When I call general-close, he will put a semicolon instead putting a closing bracket. When I call general-close again but twice, there are the closing brackets twices right on the indendation. But the semicolon doesn't belong there.

I also noticed that general-close-stack-based is doing this job right, without placing the semicolon there. But it lacks the indendation, like in general-close. So I'm wondering what the difference between general-close-stack-based and general-close is? 😦.

Any way to get the right behaviour of general-close-stack-based in the case of the unneccesary semicolon, but with the auto indentation of general-close?

Semicolon inserted where it probably shouldn't be?

In js-mode

function foo(a,b,c,d) {
if ( (a == b) || (c == d

Using general-close here results in
function foo{
if ( (a == b) || (c == d);
)
While I'd expect it to
function foo{
if ( (a == b) || (c == d) )

Hope this helps

Emacs Lisp prefix conventions

Am 24.07.2015 um 14:41 schrieb Steve Purcell:

Thanks. The symbol naming is a bit random in these files. There are prefixes like gen--, gen-, gc-- etc. -- the code should instead follow the elisp coding conventions and prefix all top-level symbols with general-close- (or general-close-- for package-private symbols).

Strange failing of python-mode tests

Travis CI repeatedly sends errors like this:

FAILED gen-close-python-doublequoted-tqs-test
FAILED gen-close-python-singlequoted-tqs-test

for example from
https://travis-ci.org/emacs-berlin/general-close/builds/68578148

AFAICS these tests succeed, if boolean gen-verbose-p is set to t, which OTOH isn't intendet at batch-mode.

Both macros in question -- for example gen-test-with-python-buffer-- have this:

   `(when gen-verbose-p
 (switch-to-buffer (current-buffer))
 (font-lock-fontify-buffer))`

Where is the relation between this switch/fontlock and the code, which inserts the TQS?

AFAICS the error is caused, because TQS-syntax in python.el is set by syntax-propertize-function

Documentation:
Mode-specific function to apply syntax-table' text properties. It is the work horse ofsyntax-propertize', which is called by things like
Font-Lock and indentation.

Setting up syntax seems to require font-lock - which doesn't feel right.

General close inside web-mode

This issue might be related: #4

For example, I have the following snippet

$(document).ready(function() {
    var test = 0 []

[] stands for the cursor.

Let assume the above snippet is in JS2-mode.
When I call general-close, it will insert ;, then }, and finally );.

But what if the buffer is in the web-mode?

Then you have the following in HTML file.

<script>
    $(document).ready(function() {
        var test = 0 []
</script>

When I'm calling general-close, the bracket }, and parenthese ) are
inserted, but no semicolon. So I was wondering if this could be possible?

Note that you could check which part of the HTML file is Javascript and which
part is HTML, with for example

 (if (string= (web-mode-language-at-pos) "html")
 Do something here

Adding the C-family of languages

Hi!

Very interesting plugin, hopefully will be incorporated into emacs directly one day.

On that note, would it be possible to add official support for the C-family of languages? I don't think that separating them out would be necessary: as Java, Rust, Go and many others have extremely similar semantics in terms of where the delimiters could be (and should be) closed.

LICENCE again

Text in LICENCE isn't the license yet, but a reference to it. This reference commonly is used by code-files. Suggest to put in the complete license instead.

avoid major-mode switching after insertion.

When using evil together with syntactic-close, inserting a closing pair in evil-insert-mode somehow triggers a major-mode switching, which in turn leads to a evil-state change. Is there a way to avoid this? Thanks.

Ability to add a semicolon?

Hi there! I got hinted from Andreas that I could use this plugin. This plugin is nearly perfect. Only one thingy I am missing.

For example, like in PHP, you have the following

 public function Foobar()
 {
     echo "Foobar

So when I will call general close, he will close the double quote ("), missing in order to close the string "Foobar", but he will not close then with a semicolon (;) to end the line. But he will close it with a bracket (}) to close the function Foobar.

I was wondering if general-close could use a semicolon (;), (I use PHP-mode by the way). When I looked in the source code of general close, I noticed he will check for the open signs (like {, [, (). But the problem is that there is no correspodenting sign for the semicolon. Then I assume we need to invent something.

So I'm wondering if there is a way to have magic powers in this case?

auto newline-and-indent

If a following call to gc would newline-and-indent, it could auto-insert that w/ the previous call.

do block in ruby not always closed correctly

Lately I'm having some trouble with syntactic-close with ruby do ... end blocks.

Good

def toon<-- cursor here
while 1 do<-- cursor here

Bad

it 'is' do<-- cursor here

It should add end, but instead it adds ,.

Defunct PHP Mode for Testing

The version of PHP Mode used in the project is very out of date. Personally I think you should use the current version just in case some of the work we've done with handling syntax in PHP Mode causes problems with general-close.

Match space separators

A feature request, which was raised already Oscar Fuentes at
http://lists.gnu.org/archive/html/emacs-devel/2013-09/msg00593.html:

"""
I'll like to match the space separators too. With your example, pressing
`)' thrice would result in:

{ (a * [(b) - (c)]) }_

Note how the space between (c) _' disappeared and how an space was inserted before }'.

Without this sub-feature, the user would be forced to edit after
pressing `)'.
"""

Semicolon support for Javascript?

In addition to the previous issue (#3), the ability to add a semicolon for PHP-mode was added, which I fell in love with it. I really appreciate your support in this. 😃

Now when I use general-close for Javascript (with JS2-mode), I'm already missing the semicolon.

For example, the structure could look like this:

      $(document).ready(function() {

          $('.nav-tabs-custom-2').tabs();

          $('.table').delegate('td','mouseover mouseleave',function(e) {
              if (e.type == 'mouseover') {
                  $(this).addClass('hover');
              }
          });
        });

So I'm wondering if it's perhaps an option to add support for Javascript, if that's not too much to ask? 😦...

Thanks in advance for your reply.

Trouble with markdown

When I use syntactic-close with markdown-mode, the cursor jumps to beginning of line.

Other than that it works fine for {, (, and [.

I haven't had time to look in to it more deeply, but I was wondering if others also suffered from this problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.