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

RE: Loading a header directly from a C module

Expand Messages
  • Michael Geddes
    This is my stuff to do it.. it does some buffer smarts, and allows for ugly microsoftish things (like not differentiating btwn c & c++ headers. ...
    Message 1 of 4 , Jan 31, 2001
    • 0 Attachment
      This is my stuff to do it.. it does some buffer smarts, and allows for ugly
      microsoftish things (like not differentiating btwn c & c++ headers.


      "
      ----------------------------------------------------------------------------
      ------
      " Source code extensions
      "
      ----------------------------------------------------------------------------
      ------


      "Hpp and Cpp browse
      function! Open_header(Extension)
      let fileName=expand("%:p:r").".".a:Extension
      if !file_readable(fileName)
      if a:Extension=='hpp'
      let ff=expand("%:p:r").".h"
      elseif a:Extension=='c'
      let ff=expand("%:p:r").".cpp"
      endif
      if exists("ff")
      if file_readable(ff)
      let fileName=ff
      endif
      endif
      endif
      if buffer_exists(fileName)
      exec "buf ".fileName
      else
      exec "e ".fileName
      endif
      endfunction
      aug toHeader
      au!
      au BufEnter * map gh :echo 'None defined'<cr>
      au BufEnter * map gc :echo 'None defined'<cr>
      au BufEnter *.cpp map gh :call Open_header('hpp')<cr>
      au BufEnter *.c map gh :call Open_header('h')<cr>
      au BufEnter *.hpp map gc :call Open_header('cpp')<cr>
      au BufEnter *.h map gc :call Open_header('c')<cr>
      au BufEnter *.rc map gh :call Open_header('rh')<cr>
      au BufEnter *.rh map gc :call Open_header('rc')<cr>
      au BufEnter *.cpp,*.rc,*.c map gc :echo 'Already here'<CR>
      au BufEnter *.hpp,*.h,*.rh map gh :echo 'Already here'<CR>
      aug END



      -----Original Message-----
      From: James, Scott [SMTP:scott.james@...]
      Sent: Wednesday, 31 January 2001 23:41
      To: 'vim@...'
      Subject: Loading a header directly from a C module

      I seem to remember seeing a module that would allow me to load the
      header
      directly from a C module by deriving its name from the C modules
      name. I
      have written a cut down version:

      fu! LoadHeader()
      let incPath="../include/"
      let bufferName=bufname("%")
      let headerName=incPath . substitute(bufferName,"\.C$","\.H","")
      if (filereadable(headerName))
      exe "normal :edit ".l:headerName"\<CR>"
      else
      echo "Unable to locate header file"
      endif
      endf

      but I really want to be able to then bounce back and load the C
      module from
      the header. I could mod my code to do this but IIRC someone has
      already
      done this. I have had a quick look but could find nothing. Any
      ideas
      people?
      --

      Scott James

      Rape my mind and destroy my feelings, dont tell me what to do. I
      dont care
      now, 'cause I'm on my side and I can see through you. Feed my brain
      with
      your so called standards. Who says that I ain't right. Break away
      from
      your common fashion see through your blurry sight.
      >>>> END OF USEFUL CONTENT <<<<


      This message is for the named person's use only. It may contain
      confidential, proprietary or legally privileged information. No
      confidentiality or privilege is waived or lost by any
      mistransmission.
      If you receive this message in error, please immediately delete it
      and all
      copies of it from your system, destroy any hard copies of it and
      notify the
      sender. You must not, directly or indirectly, use, disclose,
      distribute,
      print, or copy any part of this message if you are not the intended
      recipient. CREDIT SUISSE GROUP and each of its subsidiaries each
      reserve
      the right to monitor all e-mail communications through its networks.
      Any
      views expressed in this message are those of the individual sender,
      except
      where the message states otherwise and the sender is authorised to
      state
      them to be the views of any such entity.
      Unless otherwise stated, any pricing information given in this
      message is
      indicative only, is subject to change and does not constitute an
      offer to
      deal at any price quoted.
      Any reference to the terms of executed transactions should be
      treated as
      preliminary only and subject to our formal written confirmation.
    Your message has been successfully submitted and would be delivered to recipients shortly.