-
-
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
Consider creating an option to mimic previous tab behavior #193
Comments
I really prefer the old behavior because it is consistent with REPL. If you hit TAB after a LaTeX symbol, it replaces it, and if you hit TAB at the beginning of the line, it increase indentation. It is much easier (at least in my setup) to format docstrings. |
@ronisbr: We can bring it back, and with the hash table lookup it should be easy, but let's focus on the details first. In the examples below,
Note that the REPL behavior is the following on 1.9:
I think that the REPL is made for interactively entering text and expanding on whatever comes before the point. It is very rare (I think) to go back in the REPL prompt and expand text. Whereas in an editor there is text before and after the point. I kind of missed the REPL behavior for a while, so I understand the issue, but in the end I arrived at the conclusion that editors need different semantics. I am very happy with the current setup now, as we get expansion within the symbol a way to resolve multiple options. That said, I am open to a mechanism that mimics the REPL in some way. Just please spend some time thinking about the semantics. |
Perfect @tpapp ! Maybe we should not really replicate the entire REPL behavior. Is there any technical problem to always call auto-completion if a symbol does not resolve to a single solution? So, in all those cases, it would open that popup if I hit TAB? What I really miss is the ability to use TAB to increase indentation if we does not have a LaTeX symbol. For example, if I hit TAB here:
I would like to go to here:
instead of indenting the current line. |
(copied from a comment on #185) 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 #185. Granted, I have ivy-mode installed, and I noticed the comments in the source code related to abo-abo/swiper#2345. 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. |
@dhanak: please read the discussion above. TL;DR: the key question is defining the semantics, after that we can implement it. |
I think I would prefer simple prefix completion, offering choices if there are several. In the case of your examples:
I don't think I have ever pressed tab in the middle of a word and expected the editor to take the suffix into account as well. When I do press tab in the middle of a word, it happens because it is not really a word, I just went back and started to enter something before what was already there. So I'd prefer the editor to leave that part as is. With a somewhat forced example:
(As for the indentation, I have no issues with it.) |
Sounds like we actually have two separate desires here:
Path forward I see is to have a |
What we could do the following: On
Otherwise, if there is no |
I am working on a solution in #193. Please test, suggestions welcome (including code improvements, UI suggestions, etc). |
Do I understand correctly that at the moment there's no way to get |
Hi @giordano. Sorry I missed your question until now. Invoking |
Yes, "\alph" for me is completed to "\alpha", not "α", further pressing |
I've managed to replicate. Will create a new issue. |
Eventually, I upgraded to Emacs 29, and atreplinit() do repl
REPL = Base.REPL_MODULE_REF[]
LE = REPL.LineEdit
RC = REPL.REPLCompletions
# define a new keymap
my_keymap = Dict()
push!(repl.options.extra_keymap, my_keymap)
# auto-replace escaped latex and emoji sequences with their symbol
# counterparts after a punctuation key, just like Emacs abbrev-mode
function abbrev_expand(s, data, c)
buf = LE.buffer(s)
(pos, buf) = (position(buf), LE.content(buf))
(comp, r, _) = RC.bslash_completions(buf, thisind(buf, pos))[2]
if length(comp) == 1 && comp[].bslash[1] != '\\'
LE.edit_splice!(s, prevind(buf, r.start) => r.stop, comp[].bslash)
LE.refresh_line(s)
end
LE.edit_insert(s, c)
end
punct = filter(ispunct, Char(1):Char(127))
for c in [' '; setdiff(punct, ";?]>")]
my_keymap[c] = abbrev_expand
end
end |
Just to repeat for everyone looking at this issue: #196 works so you can use it, I just did not merge it because I haven't had time to finish it properly (tests etc). |
Reopening because #196 doesn't allow you to use |
Per @ronisbr, #185 significantly change the behavior of TAB.
#188 (comment):
To me, this brings TAB behavior back in line with how users of the rest of emacs would expect it to behave, and I see it as a benefit. If there's sufficient interest, I could create a configuration option that would cause TAB to simulate the old behavior.
The text was updated successfully, but these errors were encountered: