Loading ...
Sorry, an error occurred while loading the content.
 

Re: matchit: problem when matching end of function in matlab

Expand Messages
  • Szabolcs
    ... This is not entirely correct ... A function can be terminated with end , and nested functions are legal: function y = myfun(x) function h = g(k) h = k*k;
    Message 1 of 5 , Feb 1, 2008
      On Feb 1, 3:55 pm, seth <vim_3...@...> wrote:
      >
      > i want to use "matchit" to match begin and end of functions in matlab.
      > the begin is indicated by keyword "function". the end is implicitly
      > defined by next occurrence of "function" or end-of-file, whatever comes
      > first. example:

      This is not entirely correct ...

      A function can be terminated with "end", and nested functions are
      legal:

      function y = myfun(x)

      function h = g(k)
      h = k*k;
      end

      y = g(x);

      end
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • seth
      hi! ... of course. ... i just wanted to simplify my question as much as possible. and so the answer of A.Politz was the clarification i needed. prosit seth
      Message 2 of 5 , Feb 1, 2008
        hi!

        Szabolcs wrote:
        > On Feb 1, 3:55 pm, seth <vim_3...@...> wrote:
        >
        >> i want to use "matchit" to match begin and end of functions in
        >> matlab. the begin is indicated by keyword "function". the end is
        >> implicitly defined by next occurrence of "function" or end-of-file,
        >> whatever comes first. [...]
        >
        > This is not entirely correct ...
        >
        > A function can be terminated with "end", and nested functions are
        > legal:
        >
        > function y = myfun(x)
        >
        > function h = g(k) h = k*k; end
        >
        > y = g(x);
        >
        > end

        of course.
        you did not read my whole message. i wrote:
        >> in matlab every function may be ended by "end", but it many cases
        >> this "end" may be omitted. but this is something i want to examine
        >> later on.

        i just wanted to simplify my question as much as possible. and so the
        answer of A.Politz was the clarification i needed.

        prosit
        seth

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • A.Politz
        ... Sadly it was entirely wrong. I am sorry. The reason why the cursor is moved without beeing on a match_word is, that the plugin chooses the best match,
        Message 3 of 5 , Feb 7, 2008
          seth wrote:

          >hi!
          >
          >Szabolcs wrote:
          >
          >
          >>On Feb 1, 3:55 pm, seth <vim_3...@...> wrote:
          >>
          >>
          >>
          >>>i want to use "matchit" to match begin and end of functions in
          >>>matlab. the begin is indicated by keyword "function". the end is
          >>>implicitly defined by next occurrence of "function" or end-of-file,
          >>>whatever comes first. [...]
          >>>
          >>>
          >>This is not entirely correct ...
          >>
          >>A function can be terminated with "end", and nested functions are
          >>legal:
          >>
          >>function y = myfun(x)
          >>
          >>function h = g(k) h = k*k; end
          >>
          >>y = g(x);
          >>
          >>end
          >>
          >>
          >
          >of course.
          >you did not read my whole message. i wrote:
          >
          >
          >>>in matlab every function may be ended by "end", but it many cases
          >>>this "end" may be omitted. but this is something i want to examine
          >>>later on.
          >>>
          >>>
          >
          >i just wanted to simplify my question as much as possible. and so the
          >answer of A.Politz was the clarification i needed.
          >
          >
          >
          >
          Sadly it was entirely wrong. I am sorry. The reason why the cursor
          is moved without beeing on a match_word is, that the plugin chooses
          the "best" match, rather than doing nothing. Take a look at ':h
          matchit-choose'


          -ap


          --
          :wq


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • seth
          hi! ... well, i read :h matchit-choose already, but i still don t know, why the following is happening: ... if true foo end function bar baz ... with the
          Message 4 of 5 , Feb 11, 2008
            hi!

            A.Politz wrote:
            > seth wrote:
            >>i just wanted to simplify my question as much as possible. and so the
            >>answer of A.Politz was the clarification i needed.
            >
            > Sadly it was entirely wrong. I am sorry. The reason why the cursor
            > is moved without beeing on a match_word is, that the plugin chooses
            > the "best" match, rather than doing nothing. Take a look at ':h
            > matchit-choose'

            well, i read ":h matchit-choose" already, but i still don't know, why
            the following is happening:

            let's use this matlab-code:

            --------%<--------
            if true
            foo
            end

            function bar
            baz
            -------->%--------

            with the matchit-code:
            let b:match_words = '\<if\>:\<end\>,\<function\>:\%$'

            now let the cursor be somewhere at "foo" and now press "%"
            -> nothing will happen.

            but if the cursor is at "b" in "baz",
            -> cursor will jump to the beginning of the function.

            your first anwser, that matchit can only match linewise, seemed more
            plausible. was that wrong?

            prost
            seth

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          Your message has been successfully submitted and would be delivered to recipients shortly.