Dear Lyx Developors,
I have improved the match autocorrect for lyx to support autocorrect sequences 
with more than 2 characters, for example if the following line is in the 
autocorrect file:
    --       >   \rightarrow\rightarrow
Typing --> will then autocorect to →→
Previously the first and last columns of the autocorrect file were restricted 
to having 2 elements.

I havn't updated the autocorrect file as I'm not sure what autocorrects you'd 
want to be standard (ideas of the top of my head include ==> to ⟹ and /== to ≢)

I also added a button in the preferences window (in Editing → Input Completion) 
to reload the autocorrect file, in case you modify it whilst LyX is running.

I have attached my git patch if you want to incorporate this feature into LyX.

I also wanted to get Ctrl+Z to undo the autocorrect (but not the character that 
triggered it), for example
you would type -->
it would get replaced by →→
you press Ctrl+Z it replaces the arrows with '-->'

However I was unable to get the undo working. In Correction::correct, I tried 
the following lines of code:
cur.insert(c); // insert, verbatim, write the character that trigered the 
autocorrection
cur.recordUndo(); // save the current state on the undo stack...
cur.backspace(true); // delete the character we just inserted
... // do the actual autocorrection

Obviously recordUndo does not do what I want it to do, namely save the state of 
the cursor so that when Ctrl+Z is pressed, it will revert to the save state. If 
anyone can help me get this working it would be greatley apreciated!

I'm also considiring making a similar autocorrect feature in text mode, so you 
don't have to enter math mode to wright symbols, it could also be used for 
example to correct words like "naive" to "naïve". Let me know if this sounds 
like something you'd like Lyx to have.

— Isaac

Attachment: 0001-Make-math-autocorrrect-work-with-more-than-2-chars.patch
Description: 0001-Make-math-autocorrrect-work-with-more-than-2-chars.patch

Reply via email to