-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use completion-at-point and abbrev-mode for LaTeX substitution, take 2 #185
Conversation
This is a version of #82 without the usage of :exit-function to replace the LaTeX string with a unicode symbol.
This allows user abbrevs to keep on working with the expected behavior.
Hook into :exit-function to automatically replace LaTeX codes with unicode symbols when completion is finished. This will not work when ivy is used for completion due to <abo-abo/swiper#2345>. Using abbrev-mode or expand-abbrev still works for those users.
Co-authored-by: Tamas K. Papp <[email protected]>
See comments for reasoning. This commit allows company-mode users to comfortably press TAB for completion of latex codes to unicode symbols. Previously, indent-for-tab-command would fallback to emacs' native completion UI instead of using company. This commit also contains a slight cleanup to make the :exit-function more robust to the condition where abbrev-symbol fails.
This follows the pattern for conditional integration code from "net/tramp-integration.el".
This predicate ensures that the symbol you're trying to complete is a substring of the completion candidates. With "before" completion this isn't necessary since there isn't potential for the symbol you're trying to complete containing text that isn't intended to be completed. This commit also includes some refactors for clarity and DRY.
@non-Jedi, thanks for the great work on this. I understand that you did not have to time to review my changes, but I have been using this version for months now and it works fine, on Emacs 28 and 29, so I am merging. A separate PR will remove support for 25. |
Thank you for pushing this over the finish line @tpapp. And apologies for ghosting you a little bit with respect to non-Jedi#1. Hopefully we won't get a sudden raft of bug reports like #188, but I'll try to at least poke my head in a bit more often to triage those that I can. |
Hello! I have set up my Emacs to upgrade my (m)elpa packages automatically on a weekly basis. Thus, it came as a surprise to me that tab completion substitution for LaTeX symbols in julia-mode broke some time earlier this week. Then it took me a while to investigate the issue and track the root cause down to this PR. Granted, I have ivy-mode installed, and I noticed the comments in the source code related to a bug. But that seems like an old issue, yet julia-mode worked perfectly until recently. Furthermore, there is nothing wrong with the substitution of LaTeX symbols which are unambiguous, e.g., Moreover, when I type I spent the better part of an hour trying to figure out how to patch the change to bring the old behavior back, to no avail. I finally gave up and went back to the January 19 version of julia-mode which I restored from a snapshot. Note that I don't really want to start using abbrev. As I switch back-and-forth between Emacs and REPL, I definitely want to use the same key to expand symbols, otherwise I'm sure to mess it up regularly. I think this will be an issue for others as well, so I'd like to offer my help to come up with a solution that suits (almost) everybody. |
This finishes #100.