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

(Qt Users) Using qmake project knowledge to start (g)vim

Expand Messages
  • bsergean
    I find this script handy. Benjamin. [bsergean@marge1 bin]$ cat work.sh #!/bin/sh # $Id: work.sh 150 2007-07-25 18:22:06Z bsergean $ # Author:
    Message 1 of 1 , Jul 25, 2007
      I find this script handy.
      Benjamin.

      [bsergean@marge1 bin]$ cat work.sh
      #!/bin/sh
      # $Id: work.sh 150 2007-07-25 18:22:06Z bsergean $
      # Author: bsergean@...
      #
      # Open your favorite editor (vi) using relevant information from the
      current folder Qt project file
      # - Passing the list of source and header files, plus the .pro project
      file as args
      # - Listing the includes list and setting vim path to find those
      include file using vim 'gf'
      #
      # The magic number 21 and 26 might depends on your qmake version
      (works fine with QMake version 2.01a (4.3.0))
      #
      # TODO: Maybe extract the sources dir from SOURCES (and HEADERS) and
      run ctags on it
      # Open the resource file ?
      #
      # If you have shell variables evaluated within qmake variables,
      # it won't work.
      # Replace
      # SOURCES = $HOME/foo.c
      # with:
      # HOME=$$system(echo $HOME)
      # SOURCES = $${HOME}/foo.c
      #

      tmp=/tmp/work.$$
      qmake -d -d -d > $tmp 2>&1

      # DEBUG 1: SOURCES ===
      getVar()
      {
      egrep 'DEBUG 1: SOURCES' $tmp | tail -n 1 | cut -c 21- | tr -d ':'
      egrep 'DEBUG 1: HEADERS' $tmp | tail -n 1 | cut -c 21- | tr -d ':'

      # Project file
      echo `basename $PWD`.pro
      }

      getInc()
      {
      egrep 'DEBUG 1: INCLUDEPATH' $tmp | tail -n 1 | cut -c 26- | tr -d ':'
      }
      files=`getVar`
      incs=`getInc | sed 's/ /,/g'`

      rm -f $tmp
      gvim --cmd "set path=$incs" $files


      --~--~---------~--~----~------------~-------~--~----~
      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.