From: Nicolas Boisselier Date: Sun, 16 Aug 2015 16:27:12 +0000 (+0100) Subject: vim, templates, nb.py X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=d0ab7158eeb0b643e7cc022ef0cd4c66ce6c819d;p=nb.git vim, templates, nb.py --- diff --git a/etc/vim/source/functions.vim b/etc/vim/source/functions.vim index d190251b..c32fe7b3 100644 --- a/etc/vim/source/functions.vim +++ b/etc/vim/source/functions.vim @@ -1,6 +1,7 @@ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " " Functions +" See: http://learnvimscriptthehardway.stevelosh.com/chapters/27.html " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let $VIMHOME = $HOME.'/.vim' @@ -34,7 +35,11 @@ func! FileVimplate() setloc nomore setloc textwidth=0 - let fname = &filetype.'.tt' + let ftype = FileGet('type') + if $VIMFILE =~ 'init\.d' + let ftype = 'daemon' + endif + let fname = ftype.'.tt' let ffind = findfile(fname,$VIMPLATE_DIR) if ffind == '' " if ffind != $VIMPLATE_DIR . '/' . fname @@ -42,12 +47,7 @@ func! FileVimplate() return endif - let cmd = $VIMPLATE . ' -template '.&filetype -" NB 29.12.12 let cmd = cmd . ' -listtemplates' - " let cmd = 'vimplate -user nico -dir '.$VIMHOME.'/vimplaterc -template '.&filetype - " let cmd = 'vimplate -user nico' . -dir '.$VIMHOME.'/vimplaterc -template '.&filetype -" NB 29.12.12 echo '>>'.cmd -" NB 29.12.12 execute "!" . cmd . ' && echo OK' + let cmd = $VIMPLATE . ' -template '.ftype let bashenv = $BASH_ENV let $BASH_ENV = "" execute "r!" . cmd diff --git a/etc/vim/templates/daemon.tt b/etc/vim/templates/daemon.tt index 14515028..e355946f 100644 --- a/etc/vim/templates/daemon.tt +++ b/etc/vim/templates/daemon.tt @@ -9,10 +9,6 @@ # Short-Description: [% var.filename %] # Description: [% user.me_now %] - [% user.copyright %] ### END INIT INFO -################################################################################# -# -# -################################################################################# PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin @@ -27,11 +23,16 @@ test -x $DAEMON || exit 0 . /lib/lsb/init-functions +START="yes" # Source defaults file; edit that file to configure this script. if test -e /etc/default/$NAME ; then . /etc/default/$NAME fi +if [ "$START" != "yes" ]; then + echo "$NAME not configured to start, please edit /etc/default/$NAME to enable (START=yes)" +fi + case "$1" in start) log_daemon_msg "Starting" "${NAME}" diff --git a/lib/python/nb.py b/lib/python/nb.py index 222fbfe7..6c9161c4 100644 --- a/lib/python/nb.py +++ b/lib/python/nb.py @@ -2,9 +2,13 @@ import sys import os import re #INCLUDE_LINES = re.sub('\.py$','-lines.py',os.path.realpath(__file__)) +import pprint +PP = pprint.PrettyPrinter(indent=4) # Debug message def debug(msg): + if (type(msg)) != 'str': + msg = PP.pformat(msg) print >> sys.stderr, msg # Return first and last line from a file diff --git a/lib/python/nb.pyc b/lib/python/nb.pyc index c3109167..6f3d4bd2 100644 Binary files a/lib/python/nb.pyc and b/lib/python/nb.pyc differ