My dotfiles. Period.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. "=============================================================================
  2. " $Id: env.vim 520 2012-03-19 18:09:15Z luc.hermitte $
  3. " File: autoload/lh/env.vim {{{1
  4. " Author: Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
  5. " <URL:http://code.google.com/p/lh-vim/>
  6. " License: GPLv3 with exceptions
  7. " <URL:http://code.google.com/p/lh-vim/wiki/License>
  8. " Version: 3.0.0
  9. " Created: 19th Jul 2010
  10. " Last Update: $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
  11. "------------------------------------------------------------------------
  12. " Description:
  13. " Functions related to environment (variables)
  14. "
  15. "------------------------------------------------------------------------
  16. " Installation:
  17. " Drop this file into {rtp}/autoload/lh
  18. " Requires Vim7+
  19. " History:
  20. " v2.2.1: First Version
  21. " v3.0.0: GPLv3
  22. " TODO: «missing features»
  23. " }}}1
  24. "=============================================================================
  25. let s:cpo_save=&cpo
  26. set cpo&vim
  27. "------------------------------------------------------------------------
  28. " ## Misc Functions {{{1
  29. " # Version {{{2
  30. let s:k_version = 300
  31. function! lh#env#version()
  32. return s:k_version
  33. endfunction
  34. " # Debug {{{2
  35. let s:verbose = 0
  36. function! lh#env#verbose(...)
  37. if a:0 > 0 | let s:verbose = a:1 | endif
  38. return s:verbose
  39. endfunction
  40. function! s:Verbose(expr)
  41. if s:verbose
  42. echomsg a:expr
  43. endif
  44. endfunction
  45. function! lh#env#debug(expr)
  46. return eval(a:expr)
  47. endfunction
  48. "------------------------------------------------------------------------
  49. " ## Exported functions {{{1
  50. function! lh#env#expand_all(string)
  51. let res = ''
  52. let tail = a:string
  53. while !empty(tail)
  54. let [ all, head, var, tail; dummy ] = matchlist(tail, '\(.\{-}\)\%(${\(.\{-}\)}\)\=\(.*\)')
  55. if empty(var)
  56. let res .= tail
  57. break
  58. else
  59. let res .= head
  60. let val = eval('$'.var)
  61. let res .= val
  62. endif
  63. endwhile
  64. return res
  65. endfunction
  66. "------------------------------------------------------------------------
  67. " ## Internal functions {{{1
  68. "------------------------------------------------------------------------
  69. let &cpo=s:cpo_save
  70. "=============================================================================
  71. " vim600: set fdm=marker: