{{ message }}

# Add support for autocompletion of LaTeX commands with leading backslash #181

Merged
merged 6 commits into from Sep 23, 2018
Merged

merged 6 commits into from Sep 23, 2018

## Conversation

### Description of the Change

As discussed in #180, this PR adds snippets that allow users to autocomplete existing snippets for LaTeX commands if they started them with a backslash (\). Previously \parag would be autocompleted to \\paragraph (because parag was autocompleted to \paragraph and the leading \ was ignored) instead of \paragraph, which is now the case.

I did this by inserting a separate snippet for each LaTeX command with backslash, before the snippet without backslash, in the snippets file of this repository.

I only changed at the snippets for standard LaTeX files, as I'm not that familiar with the other filetypes specified in the snippets file. I also did not add a backslash version of snippets which don't directly map to a LaTeX command, e.g. align autocompletes to \begin{align}...\end{align} and \align still autocompletes to \\begin{align}...\end{align}

### Alternate Designs

As far as a I'm aware there is no other way to implementing this using just cson/json files.

As for the position of the snippets inside the cson file, it does not seem to be (currently) necessary for the new snippets to appear before the existing snippet. Alternatively the snippets with / could be grouped together, personally I prefer two snippets that essentially do the same thing to be together.

### Benefits

This users can now use a backslash (\) if they want to start a command and autocomplete it with this packages snippets.

### Possible Drawbacks

"Double" the snippets might slow down the package, but I don't think this will be a problem given the current number of snippets.

### Applicable Issues

 Add support to autocomplete document level snippets starting with a \ 
 b994437 
 Add support to autocomplete \begin without inserting extra backslash 
 74c3ef8 
Addresses #119 and #151
changed the title Snippets with backslash Add support for autocompletion of LaTeX commands with leading backslash Apr 14, 2018

### kylebarron commented Jul 3, 2018

 Any thoughts from maintainers?

### ericcornelissen commented Sep 3, 2018

 Any thoughts from maintainers? I would be interested in that as well 😅 Pinging @Aerijo

### Aerijo commented Sep 23, 2018

 This PR only covers half of the snippets, @ericcornelissen could you make them all have the double definition? I personally don't mind if they transition completely to backslash only (though optional backslash fro math snippets could be nice), but that may disrupt people who have become used to no slash. For now, I'd say have the slash as optional for everything, and remove the non-slash option later.
 Merge branch 'master' into snippets-with-backslash 
 91f8d7e 

### ericcornelissen commented Sep 23, 2018

 This PR only covers half of the snippets, @ericcornelissen could you make them all have the double definition? The reason I did not do the same for any of the other snippets is because the prefix for those snippets isn't the same as the actual prefix for the LaTeX code. Take or example the align(*) snippet, the assigned prefix is "align" but the body is \begin.... However, after a quick review of my changes I did note some snippets that can be transformed into a backslash version. So I'll be adding those and push them later 👍 I personally don't mind if they transition completely to backslash only (though optional backslash fro math snippets could be nice), but that may disrupt people who have become used to no slash. For now, I'd say have the slash as optional for everything, and remove the non-slash option later. I don't think it is that simple. Both of your points are valid, disruption and backslash for things such as math. Especially the latter, as some snippets just don't work with a backslash as I explained above.

### Aerijo commented Sep 23, 2018

 Especially the latter, as some snippets just don't work with a backslash as I explained above. Personally, I use \salign to get a starred align environment. I threw out precise matching a long time ago. I see the backslash as more of a way to stop the popup appearing every word, rather than any proper meaning.
 Add support to autocomplete \RequirePackage and \usepackage with(out)… 
 a4be17c 
… backslash
 Add support to autocomplete \frac with backslash 
 d9103c5 
 Add support to autocomplete \item (w/ or w/o description) with or wit… 
 44e9456 
…hout backslash

### ericcornelissen commented Sep 23, 2018

 Personally, I use \salign to get a starred align environment. I threw out precise matching a long time ago. I'm guessing that is a snippet you defined yourself? Cuz my Atom doesn't know about it 😅 I see the backslash as more of a way to stop the popup appearing every word, rather than any proper meaning. I actually do agree with that. I guess if you want to achieve that, you should get rid of snippets such as align...

### Aerijo commented Sep 23, 2018

 @ericcornelissen Yes, and yes I don't use these snippets (or this language package) at all; I use my autocomplete package https://github.com/Aerijo/autocomplete-latex

### ericcornelissen commented Sep 23, 2018

 I don't use these snippets (or this language package) at all; I use my autocomplete package Interesting that you're not using a package you seem to be maintaining @Aerijo, but I guess its because you prefer to use language-latex2e?

### Aerijo commented Sep 23, 2018

 Yup, I just don't want to see this package get neglected. It does have 200 000 downloads after all, and will be one of the first packages new LaTeX / Atom users will install. I'll see if I have publish permissions soon, after handling this PR. On the other hand, at least until I take over the entire LaTeX / Atom ecosystem, I find having my own packages more freeing. I can implement what I want without needing others to aprove it. My grammar was written largely independently of this one (except where commented), and all my other packages mostly expect it (there are some scope differences which I haven't fixed yet).
approved these changes
merged commit bad3003 into area:master Sep 23, 2018
deleted the ericcornelissen:snippets-with-backslash branch Sep 23, 2018