<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/1186588d5da72a466c3a1190d2f6937c"
  from="Stefano Zacchiroli &lt;zack@b...&gt;"
  author="Stefano Zacchiroli"
  date="2003-11-17T16:40:17"
  subject="[Caml-list] vim - switching between .ml and .mli"
  prev="2003/11/80f6a150cec1a35aec3601f9b5fe1fa8"
  next="2003/11/3d9cc991dadd878e66293fc2a0aa9594"
  prev-in-thread="2003/11/3d9cc991dadd878e66293fc2a0aa9594"
  prev-thread="2003/11/5d3e596b74eaa9ee75a58da8d20cd9d9"
  next-thread="2003/11/d9694c4eef770fa17289a4d313aa19c0"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Jumping to matching keywords with % in Vim">
<msg 
  url="2003/11/bacc85928dbd73f2643743fc792e3b9b"
  from="Issac Trotts &lt;ijtrotts@n...&gt;"
  author="Issac Trotts"
  date="2003-11-17T11:29:47"
  subject="[Caml-list] Jumping to matching keywords with % in Vim">
<msg 
  url="2003/11/77454b1dcd0bf70ae065fae653e1090a"
  from="Aleksey Nogin &lt;nogin@c...&gt;"
  author="Aleksey Nogin"
  date="2003-11-17T16:15:07"
  subject="Re: [Caml-list] Jumping to matching keywords with % in Vim">
<msg 
  url="2003/11/3d9cc991dadd878e66293fc2a0aa9594"
  from="Issac Trotts &lt;ijtrotts@n...&gt;"
  author="Issac Trotts"
  date="2003-11-17T16:47:54"
  subject="Re: [Caml-list] Jumping to matching keywords with % in Vim">
</msg>
</msg>
<msg 
  url="2003/11/1186588d5da72a466c3a1190d2f6937c"
  from="Stefano Zacchiroli &lt;zack@b...&gt;"
  author="Stefano Zacchiroli"
  date="2003-11-17T16:40:17"
  subject="[Caml-list] vim - switching between .ml and .mli">
</msg>
</msg>
</thread>

<contents>
On Mon, Nov 17, 2003 at 03:30:30AM -0800, Issac Trotts wrote:
&gt; For those who use Vim and have the matchit.vim plugin installed,
&gt; here are a few lines to put in $HOME/.vim/ftplugin/ocaml.vim :

Thanks! This is what I offer in exchange: support for switching from .ml
to .mli with ",s" and ",S" (the latter split a new window). It requires
vim-python in order to remember the previous position in a file:

    " switching between interfaces (.mli) and implementations (.ml)
  if !exists("g:did_ocaml_switch") &amp;&amp; has("python")
    let g:did_ocaml_switch = 1
    map ,s :call OCaml_switch_switch()&lt;CR&gt;
    map ,S :call OCaml_switch_switch_new()&lt;CR&gt;
    fun OCaml_switch_pynit()
      python &lt;&lt; EOF
  import vim
  positions = {}
  def ocaml_save_position():
      positions[vim.current.buffer.name] = vim.current.window.cursor
  def ocaml_restore_position():
      try:
          vim.current.window.cursor = positions[vim.current.buffer.name]
      except KeyError:
          pass
  EOF
    endfun
    call OCaml_switch_pynit()
    fun OCaml_switch_switch()
      if (match(bufname(""), "\\.mli$") &gt;= 0)
        python ocaml_save_position()
        exec "edit " . substitute(bufname(""), "\\.mli$", ".ml", "")
        python ocaml_restore_position()
      elseif (match(bufname(""), "\\.ml$") &gt;= 0)
        python ocaml_save_position()
        exec "edit " . bufname("") . "i"
        python ocaml_restore_position()
      endif
    endfun
    fun OCaml_switch_switch_new()  " as above but in a new window
      if (match(bufname(""), "\\.mli$") &gt;= 0)
        python ocaml_save_position()
        exec "new " . substitute(bufname(""), "\\.mli$", ".ml", "")
        python ocaml_restore_position()
      elseif (match(bufname(""), "\\.ml$") &gt;= 0)
        python ocaml_save_position()
        exec "new " . bufname("") . "i"
        python ocaml_restore_position()
      endif
    endfun
  endif

-- 
^Stefano Zacchiroli -- Master in Computer Science @ Uni. Bologna, Italy$
^zack@{cs.unibo.it,debian.org,bononia.it} -- http://www.bononia.it/zack$
^Frequentando il mio maestro mi ero reso conto [.] che la logica poteva$
^servire a molto a condizione di entrarci dentro e poi di uscirne -Adso$

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

