Git Product home page Git Product logo

Comments (7)

alaindanet avatar alaindanet commented on August 17, 2024 1

Thank you so much! I will get a look tomorrow, it looks great =)

from intim.

iago-lito avatar iago-lito commented on August 17, 2024

Yupe, confirmed.


  • python interpreter considers it's your job to indent each new line the way it has to be indented, whereas..
  • sage interpreter automatically indents the first line of new scopes for you.

The solution may be to preprocess or not lines sent by <Plug>IntimSendSelection in a way that depends on your interpreter or your language. I'll get into this.


As a workaround for now, you may use <Plug>IntimSendChunk instead, which should not mind about indentation, although it's a totally different way to send script lines.

Thank you for reporting :)

from intim.

iago-lito avatar iago-lito commented on August 17, 2024

106a9c6 should fix it. The problem actually affects every ipython interpreter, which I think sage interpreter is an instance.


Considering deprecation of the old sage %autoindent feature. I have chosen to use ipython's %cpaste magic command to send selection just like we would do while pasting text to the console.

This requires the SendSelection function to choose now whether or not to send selection naively line-by-line or using the new MagicCpaste procedure. So I had to introduce an new sendSelection intim option to handle this case.

However, in order to keep basic user out of this subtle tweak. I've made this option automagically set to the right value if user's invoked interpreter is detected to be sage or ipython. This can be done with a new hook triggered while user is setting an Intim option.


This should work transparently from now on, unless you have a very specific case to handle.

See :help intim-autoindent or :help intim-sage to keep updated :)

from intim.

alaindanet avatar alaindanet commented on August 17, 2024

Hi Iago,

the magical option seems not to work. I have still the indentation problem.

Moreover, The call Intim_sendSelection('sage', 'MagicCpaste') throws an error:
latest-screenshot

Thank you so much for your help!

from intim.

iago-lito avatar iago-lito commented on August 17, 2024

Ay.

  • For the magic to occur, sage must have been somehow defined as your formal invoke command by:

    call Intim_invokeCommand('python', 'sage')

    or

    call Intim_invokeCommand('sage', 'sage')

    or anything like that (see :help intim-invoke).. is this the case? Otherwise, could you provide the output of:

    :echo <SNR>29_get_invokeCommand()     
    :echo <SNR>29_get_sendSelection()

    (I wrote 29_ because it is the number that shows up in your error message. It may change if you have installed/uninstalled other plugins since then. Please use the latest one.)

  • As for this E117 error. Thanks to your report, I found out that Intim function were guaranteed to be defined only.. at least.. at the time of vim autocmd resolving (see :help autocommand). As a consequence, wrapping your call in something like:

    augroup PythonGroup
        autocmd!
        autocmd VimEnter *.py,*.sage call Intim_sendSelection('sage', 'MagicCpaste')
    augroup end

    Should fix it. I'll update the doc to warn about this.

Thanks for reporting again. Keep me updated :)

from intim.

alaindanet avatar alaindanet commented on August 17, 2024

Thank you for your help!

When I start Intim from my somefile.sage, I get a python session.
The output that you resquested are:

:echo <SNR>29_get_invokeCommand()
python
:echo <SNR>29_get_sendSelection()
LineByLine

I have added your wrap to my $VIMRC. Opening a .sage file results in:
latest-screenshot

Futhermore, call Intim_invokeCommand('python', 'sage') throws me also an error:
latest-screenshot

from intim.

iago-lito avatar iago-lito commented on August 17, 2024

Thank you. So the magic is not happening because it turns out you cannot actually set your options correctly. This is another problem, if you don't mind skipping to #6 :)

from intim.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.