Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Allow customization of which characters to automatically pair #121

Closed
jrsconfitto opened this issue Mar 31, 2015 · 14 comments
Closed

Allow customization of which characters to automatically pair #121

jrsconfitto opened this issue Mar 31, 2015 · 14 comments

Comments

@jrsconfitto
Copy link

i'm currently maintaining an Atom language grammar for the PowerShell language, and i received an issue that complains about automatic quote insertion for the backtick character (`) in the language. In PowerShell the backtick is used for escapes, so backticks rarely surround a phrase of code, rendering this behavior a small annoyance.

i've started a discussion in the forum about this behavior, and it seems this can be an issue for the LaTeX grammar as well.

Is there a way to turn this behavior off for a particular character without losing automatic quote insertion (is that the term for this behavior?) for the other kinds of quotes? It's a nice feature and losing it for one exception is a bit of a bummer 😦

If not, would it be possible to bake this into some sort of language setting? and is this an addition you'd want in this package?

Relevant links

@requnix
Copy link

requnix commented Apr 10, 2015

This is also an issue in Clojure where ' is used as an escape character, not a quote, and never needs to be paired.

This causes issues like the following: atom/language-clojure#9

It would be great if we could set this per character pair per grammar. If not, I'd settle for excluding grammars and leave it to someone to create a specialised package that deals exclusively with bracketing and quoting for that grammar a la https://github.com/MarcoPolo/atom-paredit.

@michaelsproul
Copy link

+1, in Rust a single ' is used for lifetimes, which only appear in certain contexts:

fn something<'a>(&'a self) -> &'a u32 {}
struct Thing<X: 'a> {}

Allowing the language packs to adjust the completion rules would be great.

@spencergibb
Copy link

+1 driving me crazy editing markdown

@patrickhpan
Copy link

+1 on LaTeX. Driving me crazy because switching between coding (where I am physically dependent on bracket autocompletion) and LaTeX (which is undoable with buggy completion) is really getting annoying because I have to re-enable and disable the package.

@m-bra
Copy link

m-bra commented Sep 21, 2015

+1 for rust

@richard-uk1
Copy link

Does anyone have any ideas about how to achieve this? Could you add the ability to register a boolean function where returning false aborts the bracket add? Something like

bracket_matcher.register_match_function(function(editor, other_params_that_are_useful) {
    if(we_dont_want_a_matching_bracket) {
        return false;
    } else {
        return true;
    }
});

PS I'm from Rust

@richard-uk1
Copy link

It should at least be easy to add settings to configure which types of brackets should be matched

@loveencounterflow
Copy link

+1 for the ability to configure matching character pairs with ease. That should probably include per-language-settings; those would probably optionally have to be made from the respective language-specific plugin.

Also see https://discuss.atom.io/t/add-bracket-pairs-to-highlighting-auto-insertion/22673; not sure which of the forums is the appropriate one for discussions like this.

@J-qak
Copy link

J-qak commented Mar 14, 2016

+1 for Common Lisp, where single ' is used for "quoting" lists and stuff pretty frequently. I've been trying to disable whole quote-completing feature from my fork of language package with no avail. Anybody know why the following code in my language-lisp/settings/language-lisp.cson doesn't work?

  "bracket-matcher":
    autocompleteBrackets: false

@notslang
Copy link

@J-qak: if you upgrade Atom that should work, since 26d598d has been merged.

@potto007
Copy link
Contributor

@michaelsproul, @m-bra, @derekdreery : my frustrations with editing Rust code using Atom is what motivated me to write PR #249. I have some changes to make before it has any hope of acceptance, but wanted to let you know it's out there so you could at least benefit from it and give any feedback you may have.

Given that bracket-matcher is so core to Atom, it stands to reason that it should be highly configurable and as performant as possible.

@georgd
Copy link

georgd commented Sep 26, 2016

Besides of programming and markup languages the configurability of the bracket matcher is also essential for natural language. Currently it only supports typographical quotation mark matching only for English and French and languages the two oft them share patterns with. For all the other languages there’s no matching at all or faulty matching.

The latter is true for German: There are two sets of quotation marks »« and „“. Using the first one will trigger matching according to French rules at entering the closing mark, resulting in »...«», while using the second set will trigger matching according to English rules at entering the closing mark, resulting in „“” (and the same goes for the single quote variants).

@potto007
Copy link
Contributor

@georgd PR #249 should resolve this issue for you. Please observe this animated GIF screencast:

bracket-matcher-germanquotes

@winstliu
Copy link
Contributor

winstliu commented Dec 6, 2016

Fixed by #249.

@winstliu winstliu closed this as completed Dec 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests