orbitalquark / textadept

Textadept is a fast, minimalist, and remarkably extensible cross-platform text editor for programmers.
https://orbitalquark.github.io/textadept
MIT License
649 stars 38 forks source link

Textadept will autoclose " ' ", making it very difficult to write english contractions like "don't" #514

Closed quesada closed 6 months ago

quesada commented 6 months ago

I assumed there was some code I copied from someone else's "init.lua", but I don't see which part is creating this behavior. Seems to be built-in with the editor? It's an interesting choice. Other editors do it too, but are smart in detecting when it doesn't apply (example: micro editor). Textadept will autoclose at all times; this will easily discourage anyone trying to write prose with it and not being willing to play with config files.

quesada commented 6 months ago

I tried using chatGPT 4 to solve the problem, while looking at the code myself. I'm new to lua and textadept. I didn't manage, every fix suggested by chatGPT was totally a failure :) This is the conversation. Interesting that it seems to know so much about textadept (a surprise) but it's all wrong!

https://chat.openai.com/share/d14227e6-9988-4ae6-88ee-2c7e9a5e7c42

orbitalquark commented 6 months ago

Fascinating. It looks like chatGPT's knowledge of Textadept is up-to-date in some places, but outdated in others. This auto-close feature is called auto-pair, and the manual demonstrates how to turn it off (https://orbitalquark.github.io/textadept/manual.html#adept-editing). Put the following in your ~/.textadept/init.lua:

textadept.editing.auto_pair = nil

If you just want to turn off the behavior for apostrophes, you'd use

textadept.editing.auto_pair["'"] = nil
quesada commented 6 months ago

Thanks so much! You are right, it's in the manual; really sorry I wasted your time. And also sorry I thought it would be faster to use chatGTP than reading the manual. A pity it's so inconsistent. It would be wonderful it it knew the latest API. Maybe one can try doing retrieval-augmented-generation with an open source LLM using the docs... interesting side project! maybe I'll attempt it.

I tried both solutions, and somehow they didn't work for me. The first one fails silently, second one with an error image

Here's my init.lua (could be there's an interaction with something else?) https://pastebin.com/edDv1cc6

orbitalquark commented 6 months ago

That was my mistake. It's textadept.editing.auto_pairs. Note the trailing 's'. Sorry about that.

quesada commented 6 months ago

Thanks, that works, closing issue