julia-emacs icon indicating copy to clipboard operation
julia-emacs copied to clipboard

Use completion-at-point for latexsub instead of overriding TAB keybinding

Open non-Jedi opened this issue 6 years ago • 2 comments

This would integrate nicely with e.g. company and would generally make this package a better emacs citizen. I have some custom stuff bound to TAB in my config having to do with company completion, and the hacks to make latexsub work as well aren't very nice.

The implementation is to write julia-latexsub-at-point-function and push it to completion-at-point-functions.

Are there any objections to this?

non-Jedi avatar Nov 08 '19 13:11 non-Jedi

One advantage of the current setup is that we can very easily keep the completion list in sync with what Julia supports.

The binding for TAB is local to the julia-mode-map, so it should not interfere with other buffers.

the hacks to make latexsub work as well aren't very nice

Can you please clarify?

Also, do you want to be able to customize/combine other completions for Julia buffers with the current setup? An example would be helpful.

tpapp avatar Nov 08 '19 14:11 tpapp

One advantage of the current setup is that we can very easily keep the completion list in sync with what Julia supports.

I'm not sure why you think switching to completion-at-point would preclude this.

The binding for TAB is local to the julia-mode-map, so it should not interfere with other buffers.

the hacks to make latexsub work as well aren't very nice

Can you please clarify?

See below.

Also, do you want to be able to customize/combine other completions for Julia buffers with the current setup? An example would be helpful.

Yes. Using eglot with the Julia language server provides completion via completion-at-point which I use via company-capf. I have "TAB" bound to complete-or-indent:

(defun complete-or-indent ()
  (interactive)
  (if (company-manual-begin)
      (company-complete-common-or-cycle)
    (indent-for-tab-command)))

So then for Julia mode I have to do:

(defun complete-or-indent-or-latexsub ()
  (interactive)
  (if (latexsub)
      (complete-or-indent)))

Which admittedly isn't really as much of a "hack" as I made it sound.

What I'm really after is to be able to type \aTAB into a julia-mode buffer and get the same completion experience I get for completing other symbols in the buffer:

eglot-completion-example

Except showing the unicode results of \alpha, \annuity, \asteraccent, etc.

I can write this, and I'm fairly confident it will work. I just don't necessarily want to put the effort into doing so if there's no chance of it being merged.

EDIT: nevermind. This doesn't work. You can't complete to an entirely different string. You can complete the string that will then become the latexsub, though, and that should be a relatively uncontroversial PR.

non-Jedi avatar Nov 08 '19 16:11 non-Jedi

Closed by #185

non-Jedi avatar Mar 18 '24 12:03 non-Jedi