Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

update configs

  • Loading branch information...
commit de2d5fc69fe100eef07499b619839eefac62f093 1 parent ed7e25a
Vincent Wang authored June 08, 2007
4  .bitlbee/bitlbee.conf
@@ -58,14 +58,14 @@ DaemonPort = 16667
58 58
 ## Specify an alternative MOTD (Message Of The Day) file. Default value depends
59 59
 ## on the --etcdir argument to configure.
60 60
 ##
61  
-MotdFile = /Users/linsong/.bitlbee/motd.txt
  61
+MotdFile = /home/vincent/.bitlbee/motd.txt
62 62
 
63 63
 ## ConfigDir
64 64
 ##
65 65
 ## Specify an alternative directory to store all the per-user configuration
66 66
 ## files. (.nicks/.accounts)
67 67
 ##
68  
-ConfigDir = /Users/linsong/.bitlbee/data
  68
+ConfigDir = /home/vincent/.bitlbee/data
69 69
 
70 70
 ## Ping settings
71 71
 ##
1  .mutt/mailboxes
@@ -8,3 +8,4 @@
8 8
 mailboxes !
9 9
 #mailboxes imaps://imap.exoweb.net/INBOX
10 10
 mailboxes `for file in $HOME/Mail/maillists/*; do echo -n "=maillists/$(basename $file) "; done `
  11
+mailboxes `for file in $HOME/Mail/rss/*; do echo -n "=rss/$(basename $file) "; done `
10  .procmailrc
@@ -485,6 +485,16 @@ maillists/macports-users@lists.macosforge.org
485 485
 * ^TOlaszlo-dev@openlaszlo.org
486 486
 maillists/laszlo-dev@openlaszlo.org
487 487
 
  488
+### start to dispatch rss mails from rss3email 
  489
+:0:
  490
+* ^From robg@macosxhints.com
  491
+rss/macosxhints
  492
+
  493
+:0:
  494
+* ^User-Agent: rss2email$
  495
+rss/others
  496
+### end
  497
+
488 498
 :0:
489 499
 * ^TOlinsong.qizi@gmail.com
490 500
 vincent
2  .screenrc
@@ -50,7 +50,9 @@ bind O login off
50 50
 bind } history
51 51
 
52 52
 bind j focus down
  53
+bind ^j focus down
53 54
 bind k focus up
  55
+bind ^k focus up
54 56
 bind t focus top
55 57
 bind b focus bottom
56 58
 
26  .vim/AsNeeded/a.vim
@@ -118,6 +118,16 @@ if (!exists('g:alternateNoDefaultAlternate'))
118 118
    let g:alternateNoDefaultAlternate = 0
119 119
 endif
120 120
 
  121
+" If this variable is true then a.vim will convert the alternate filename to a
  122
+" filename relative to the current working directory.
  123
+" Feature by Nathan Huizinga
  124
+if (!exists('g:alternateRelativeFiles'))                                        
  125
+   " by default a.vim will not convert the filename to one relative to the
  126
+   " current working directory
  127
+   let g:alternateRelativeFiles = 0
  128
+endif
  129
+
  130
+
121 131
 " Function : GetNthItemFromList (PRIVATE)
122 132
 " Purpose  : Support reading items from a comma seperated list
123 133
 "            Used to iterate all the extensions in an extension spec
@@ -296,14 +306,14 @@ endfunction
296 306
 function! EnumerateFilesByExtension(path, baseName, extension)
297 307
    let enumeration = ""
298 308
    let extSpec = ""
299  
-   if (has_key(g:alternateExtensionsDict, a:extension))
300  
-      let extSpec = g:alternateExtensionsDict[a:extension]
  309
+   let v:errmsg = ""
  310
+   silent! echo g:alternateExtensions_{a:extension}
  311
+   if (v:errmsg == "")
  312
+      let extSpec = g:alternateExtensions_{a:extension}
301 313
    endif
302 314
    if (extSpec == "")
303  
-      let v:errmsg = ""
304  
-      silent! echo g:alternateExtensions_{a:extension}
305  
-      if (v:errmsg == "")
306  
-         let extSpec = g:alternateExtensions_{a:extension}
  315
+      if (has_key(g:alternateExtensionsDict, a:extension))
  316
+         let extSpec = g:alternateExtensionsDict[a:extension]
307 317
       endif
308 318
    endif
309 319
    if (extSpec != "") 
@@ -722,6 +732,10 @@ function! <SID>FindOrCreateBuffer(fileName, doSplit, findSimilar)
722 732
      endif
723 733
   endif
724 734
 
  735
+  if (g:alternateRelativeFiles == 1)                                            
  736
+        let FILENAME = fnamemodify(FILENAME, ":p:.")
  737
+  endif
  738
+
725 739
   let splitType = a:doSplit[0]
726 740
   let bang = a:doSplit[1]
727 741
   if (bufNr == -1)
88  .vim/AsNeeded/writebackup.vim
... ...
@@ -0,0 +1,88 @@
  1
+" writebackup.vim: Write backups of current file with date file extension in the
  2
+" same directory. 
  3
+"
  4
+" DESCRIPTION:
  5
+"   This is the poor man's revision control system, a primitive alternative to
  6
+"   CVS, RCS, Subversion, etc., which works with no additional software and
  7
+"   almost any file system. 
  8
+"   The ':WriteBackup' command writes subsequent backups of the current file
  9
+"   with a current date file extension (format '.YYYYMMDD[a-z]') in the same
  10
+"   directory as the file itself. The first backup of a day has letter 'a'
  11
+"   appended, the next 'b', and so on. (Which means that a file can be backed up
  12
+"   up to 26 times on any given day.) 
  13
+"
  14
+" USAGE:
  15
+"   :WriteBackup
  16
+"
  17
+" INSTALLATION:
  18
+"   Put the script into your user or system VIM plugin directory (e.g.
  19
+"   ~/.vim/plugin). 
  20
+"
  21
+" DEPENDENCIES:
  22
+"   - Requires VIM 6.2. 
  23
+"
  24
+" CONFIGURATION:
  25
+"   In case you already have other custom VIM commands starting with W, you can
  26
+"   define a shorter command alias ':W' in your .vimrc to save some keystrokes.
  27
+"   I like the parallelism between ':w' for a normal write and ':W' for a backup
  28
+"   write. 
  29
+"	command W :WriteBackup
  30
+"
  31
+" Copyright: (C) 2007 by Ingo Karkat
  32
+"   The VIM LICENSE applies to this script; see ':help copyright'. 
  33
+"
  34
+" Maintainer:	Ingo Karkat <ingo@karkat.de>
  35
+" REVISION	DATE		REMARKS 
  36
+"   1.00.004	07-Mar-2007	Added documentation. 
  37
+"	0.03	06-Dec-2006	Factored out WriteBackup_GetBackupFilename() to
  38
+"				use in :WriteBackupOfSavedOriginal. 
  39
+"	0.02	14-May-2004	Avoid that the written file becomes the
  40
+"				alternate file (via set cpo-=A)
  41
+"	0.01	15-Nov-2002	file creation
  42
+
  43
+" Avoid installing twice or when in compatible mode
  44
+if exists("g:loaded_writebackup") || (v:version < 602)
  45
+    finish
  46
+endif
  47
+let g:loaded_writebackup = 1
  48
+
  49
+function! WriteBackup_GetBackupFilename()
  50
+    let l:date = strftime( "%Y%m%d" )
  51
+    let l:nr = 'a'
  52
+    while( l:nr <= 'z' )
  53
+	let l:backupfilename = expand("%").'.'.l:date.l:nr
  54
+	if( filereadable( l:backupfilename ) )
  55
+	    " Current backup letter already exists, try next one. 
  56
+	    " Vim script cannot increment characters; so convert to number for increment. 
  57
+	    let l:nr = nr2char( char2nr(l:nr) + 1 )
  58
+	    continue
  59
+	endif
  60
+	" Found unused backup letter. 
  61
+	return l:backupfilename
  62
+    endwhile
  63
+
  64
+    " All backup letters a-z are already used; report error. 
  65
+    throw 'WriteBackup: Ran out of backup file names'
  66
+endfunction
  67
+
  68
+function! s:WriteBackup()
  69
+    try
  70
+	let l:saved_cpo = &cpo
  71
+	set cpo-=A
  72
+	execute 'write ' . WriteBackup_GetBackupFilename()
  73
+    catch /^WriteBackup:/
  74
+	" All backup letters a-z are already used; report error. 
  75
+	echohl Error
  76
+	echomsg "Ran out of backup file names"
  77
+	echohl None
  78
+    catch /^Vim\%((\a\+)\)\=:E/
  79
+	echohl Error
  80
+	echomsg substitute( v:exception, '^Vim\%((\a\+)\)\=:', '', '' )
  81
+	echohl None
  82
+    finally
  83
+	let &cpo = l:saved_cpo
  84
+    endtry
  85
+endfunction
  86
+
  87
+command! WriteBackup :call <SID>WriteBackup()
  88
+
589  .vim/AsNeeded/writebackupVersionControl.vim
... ...
@@ -0,0 +1,589 @@
  1
+" writebackupVersionControl.vim: Version control functions (diff, restore) for
  2
+" writebackup.vim backups with date file extension (format '.YYYYMMDD[a-z]'). 
  3
+"
  4
+" DESCRIPTION:
  5
+"   This script enhances the primitive file backup mechanism provided by
  6
+"   writebackup.vim with some functions of real revision control systems like
  7
+"   CVS, RCS or Subversion - without additional software. 
  8
+"   Via VIM commands, you can list all backup versions that exist for the
  9
+"   current file, check whether you have a current backup, backup the saved
  10
+"   version of the buffer even after you've made unsaved changes in the buffer
  11
+"   (which is useful for after-the-fact backups). 
  12
+"   Within VIM, you can create a diff with the previous version, restore the
  13
+"   current file from its predecessor or any other backed-up version. 
  14
+"
  15
+" USAGE:
  16
+"   :WriteBackupDiffWithPred
  17
+"	Performs a diff of the current file (which may be the current version or
  18
+"	an older backup) with the previous version. The diff is done inside VIM,
  19
+"	with a new diffsplit being opened. 
  20
+"
  21
+"   :WriteBackupListVersions
  22
+"	List all backup versions that exist for the current file. If the file
  23
+"	isn't the current version, it is marked in the version list. If the file
  24
+"	is the current version, the time that has passed since the last backup
  25
+"	is printed, too. 
  26
+"
  27
+"   :WriteBackupIsBackedUp
  28
+"	Checks whether the latest backup is identical to the (saved version of
  29
+"	the) current file (which must be the latest version). 
  30
+"
  31
+"   :WriteBackupRestoreFromPred
  32
+"	Overwrites the current file (which must be the latest version) with its
  33
+"	latest backup. 
  34
+"
  35
+"   :WriteBackupRestoreThisBackup
  36
+"	Restores the current file as the latest version, which will be
  37
+"	overwritten. 
  38
+"
  39
+"   :WriteBackupOfSavedOriginal
  40
+"	Instead of backing up the current buffer, back up the saved version of
  41
+"	the buffer. This comes handy when you realize you need a backup only
  42
+"	after you've made changes to the buffer. 
  43
+"
  44
+" INSTALLATION:
  45
+"   Put the script into your user or system VIM plugin directory (e.g.
  46
+"   ~/.vim/plugin). 
  47
+"
  48
+" DEPENDENCIES:
  49
+"   - Requires VIM 7.0. 
  50
+"   - Requires writebackup.vim for :WriteBackupOfSavedOriginal command. 
  51
+"   - External commands 'diff', 'cp' (Unix), 'copy' (Windows). 
  52
+"
  53
+" CONFIGURATION:
  54
+"   To change the default diffsplit from vertical to horizontal, use: 
  55
+"	let g:writebackup_DiffVertSplit = 0
  56
+"
  57
+" Copyright: (C) 2007 by Ingo Karkat
  58
+"   The VIM LICENSE applies to this script; see ':help copyright'. 
  59
+"
  60
+" Maintainer:	Ingo Karkat <ingo@karkat.de>
  61
+" REVISION	DATE		REMARKS 
  62
+"   1.00.006	07-Mar-2007	Added documentation. 
  63
+"	0.05	06-Dec-2006	Factored out Copy() function. 
  64
+"				Implemented :WriteBackupOfSavedOriginal command. 
  65
+"	0.04	16-Nov-2006	BF: '%' and '#' must also be escaped for VIM. 
  66
+"	0.03	02-Nov-2006	ENH: Added user information that IsBackedUp()
  67
+"				compares with saved version, not modified
  68
+"				buffer. 
  69
+"				BF: In Restore() and IsBackedUp(), expand
  70
+"				filespecs to absolute paths to avoid problems
  71
+"				with cwd, especially on Windows systems with UNC
  72
+"				paths. 
  73
+"				BF: In DiffWithPred() and RestoreThisBackup(),
  74
+"				convert the filespec to VIM syntax. 
  75
+"	0.02	31-Oct-2006	Added WriteBackupListVersions. 
  76
+"				Added EchoElapsedTimeSinceVersion as an add-on
  77
+"				to WriteBackupListVersions. 
  78
+"				Added WriteBackupIsBackedUp. 
  79
+"				Added RestoreFromPred and RestoreThisBackup. 
  80
+"				Optimized away actual diff invocation in
  81
+"				IsBackedUp() for most cases. 
  82
+"				cases
  83
+"	0.01	30-Oct-2006	file creation
  84
+
  85
+" Avoid installing twice or when in compatible mode
  86
+if exists("g:loaded_writebackupVersionControl") || (v:version < 700)
  87
+    finish
  88
+endif
  89
+let g:loaded_writebackupVersionControl = 1
  90
+
  91
+" Allow user to specify diffsplit of horiz. or vert.
  92
+if !exists('g:writebackup_DiffVertSplit')
  93
+    let g:writebackup_DiffVertSplit = 1  " Default to split for diff vertically. 
  94
+endif
  95
+
  96
+let s:versionRegexp = '\.[12]\d\d\d\d\d\d\d[a-z]$'
  97
+let s:versionFileGlob = '.[12][0-9][0-9][0-9][0-9][0-9][0-9][0-9][a-z]'
  98
+let s:versionLength = 10 " 1 dot + 4 year + 2 month + 2 day + 1 letter
  99
+
  100
+"- conversion functions -------------------------------------------------------
  101
+function! s:GetOriginalFilespec( filespec )
  102
+    if a:filespec =~ s:versionRegexp
  103
+	return strpart( a:filespec, 0, len( a:filespec ) - s:versionLength )
  104
+    else
  105
+	return a:filespec
  106
+    endif
  107
+endfunction
  108
+
  109
+function! s:GetVersion( filespec )
  110
+    if a:filespec =~ s:versionRegexp
  111
+	return strpart( a:filespec, len( a:filespec ) - s:versionLength + 1 )
  112
+    else
  113
+	return ''
  114
+    endif
  115
+endfunction
  116
+
  117
+"------------------------------------------------------------------------------
  118
+function! s:VerifyIsOriginalFileAndHasPredecessor( filespec, notOriginalMessage )
  119
+"*******************************************************************************
  120
+"* PURPOSE:
  121
+"   Checks that a:filespec is not a backup file and that at least one backup for
  122
+"   this file exists. If not, an error message is echoed; in the latter case,
  123
+"   the passed a:notOriginalMessage is used. 
  124
+"* ASSUMPTIONS / PRECONDITIONS:
  125
+"   none
  126
+"* EFFECTS / POSTCONDITIONS:
  127
+"   none
  128
+"* INPUTS:
  129
+"   a:filespec
  130
+"   a:notOriginalMessage
  131
+"* RETURN VALUES: 
  132
+"   empty string if verification failed; filespec of predecessor othewise. 
  133
+"*******************************************************************************
  134
+    if ! empty( s:GetVersion( a:filespec ) )
  135
+	echohl Error
  136
+	echomsg a:notOriginalMessage
  137
+	echohl None
  138
+	return ''
  139
+    endif
  140
+
  141
+    let l:predecessor = s:GetPredecessorForFile( a:filespec )
  142
+    if empty( l:predecessor )
  143
+	echohl Error
  144
+	echomsg "No predecessor found for file '" . a:filespec . "'."
  145
+	echohl None
  146
+	return ''
  147
+    endif
  148
+
  149
+    return l:predecessor
  150
+endfunction
  151
+
  152
+"------------------------------------------------------------------------------
  153
+function! s:GetAllBackupsForFile( originalFilespec )
  154
+"*******************************************************************************
  155
+"* PURPOSE:
  156
+"   Retrieves a list of all filespecs of backup files for a:originalFilespec. 
  157
+"   The list is sorted from oldest to newest backup. The original filespec is
  158
+"   not part of the list. 
  159
+"* ASSUMPTIONS / PRECONDITIONS:
  160
+"   none
  161
+"* EFFECTS / POSTCONDITIONS:
  162
+"   none
  163
+"* INPUTS:
  164
+"   a:originalFilespec
  165
+"* RETURN VALUES: 
  166
+"   sorted list of backup filespecs
  167
+"*******************************************************************************
  168
+    let l:backupfiles = split( glob( a:originalFilespec . s:versionFileGlob ), "\n" )
  169
+    " Although the glob should already be sorted alphabetically in ascending
  170
+    " order, we'd better be sure and sort the list on our own, too. 
  171
+    let l:backupfiles = sort( l:backupfiles )
  172
+"****D echo '**** backupfiles: ' . l:backupfiles
  173
+    return l:backupfiles
  174
+endfunction
  175
+
  176
+function! s:RemoveNewerBackupsFrom( backupfiles, currentVersion )
  177
+"*******************************************************************************
  178
+"* PURPOSE:
  179
+"   Removes files from the passed list that are newer or equal to a:currentVersion. 
  180
+"* ASSUMPTIONS / PRECONDITIONS:
  181
+"   none
  182
+"* EFFECTS / POSTCONDITIONS:
  183
+"   Truncates a:backupfiles so that any file version contained is older than a:currentVersion. 
  184
+"* INPUTS:
  185
+"   a:backupfiles: sorted list of filespecs. 
  186
+"   a:currentVersion: version number used as the exclusion criterium. 
  187
+"* RETURN VALUES: 
  188
+"   none
  189
+"*******************************************************************************
  190
+    let l:fileCnt = 0
  191
+    while l:fileCnt < len( a:backupfiles )
  192
+	if s:GetVersion( a:backupfiles[ l:fileCnt ] ) >= a:currentVersion 
  193
+"****D echo '**** removing indexes ' . l:fileCnt . ' to ' . (len( a:backupfiles ) - 1)
  194
+	    call remove( a:backupfiles, l:fileCnt, len( a:backupfiles ) - 1 )
  195
+"****D call confirm('debug')
  196
+	    break
  197
+	endif
  198
+	let l:fileCnt += 1
  199
+    endwhile
  200
+endfunction
  201
+
  202
+function! s:GetPredecessorForFile( filespec )
  203
+"*******************************************************************************
  204
+"* PURPOSE:
  205
+"   Gets the filespec of the predecessor of the passed filespec, regardless of
  206
+"   whether the passed filespec is the current file (without a version
  207
+"   extension), or a versioned backup. 
  208
+"* ASSUMPTIONS / PRECONDITIONS:
  209
+"   a:filespec is a valid file. 
  210
+"* EFFECTS / POSTCONDITIONS:
  211
+"   none
  212
+"* INPUTS:
  213
+"   a:filespec
  214
+"* RETURN VALUES: 
  215
+"   filespec to the predecessor version. 
  216
+"*******************************************************************************
  217
+    let l:originalFilespec = s:GetOriginalFilespec( a:filespec )
  218
+    let l:currentVersion = s:GetVersion( a:filespec )
  219
+
  220
+    let l:backupfiles = s:GetAllBackupsForFile( l:originalFilespec )
  221
+    if ! empty( l:currentVersion )
  222
+	call s:RemoveNewerBackupsFrom( l:backupfiles, l:currentVersion )
  223
+    endif
  224
+
  225
+    if empty( l:backupfiles )
  226
+	return ''
  227
+    else
  228
+	let l:predecessor = l:backupfiles[ len( l:backupfiles ) - 1 ]
  229
+	return l:predecessor
  230
+    endif
  231
+endfunction
  232
+
  233
+function! s:DiffWithPred( filespec )
  234
+"*******************************************************************************
  235
+"* PURPOSE:
  236
+"   Creates a diff with the predecessor of the passed a:filespec. 
  237
+"* ASSUMPTIONS / PRECONDITIONS:
  238
+"	? List of any external variable, control, or other element whose state affects this procedure.
  239
+"* EFFECTS / POSTCONDITIONS:
  240
+"	? List of the procedure's effect on each external variable, control, or other element.
  241
+"* INPUTS:
  242
+"   a:filespec
  243
+"* RETURN VALUES: 
  244
+"   none
  245
+"*******************************************************************************
  246
+    let l:predecessor = s:GetPredecessorForFile( a:filespec )
  247
+    if empty( l:predecessor )
  248
+	echohl Error
  249
+	echomsg "No predecessor found for file '" . expand('%') . "'."
  250
+	echohl None
  251
+    else
  252
+"****D echo '**** predecessor is ' . l:predecessor
  253
+	if g:writebackup_DiffVertSplit == 1
  254
+	    let l:splittype=':vert diffsplit '
  255
+	else
  256
+	    let l:splittype=':diffsplit '
  257
+	endif
  258
+	execute l:splittype . escape( tr( l:predecessor, '\', '/'), ' \%#' )
  259
+    endif
  260
+endfunction
  261
+
  262
+function! s:DualDigit( number )
  263
+"*******************************************************************************
  264
+"* PURPOSE:
  265
+"   Formats the passed number as a dual-digit string. 
  266
+"* ASSUMPTIONS / PRECONDITIONS:
  267
+"	? List of any external variable, control, or other element whose state affects this procedure.
  268
+"* EFFECTS / POSTCONDITIONS:
  269
+"	? List of the procedure's effect on each external variable, control, or other element.
  270
+"* INPUTS:
  271
+"	? Explanation of each argument that isn't obvious.
  272
+"* RETURN VALUES: 
  273
+"	? Explanation of the value returned.
  274
+"*******************************************************************************
  275
+    let l:digits = a:number + ''
  276
+    while len( l:digits ) < 2
  277
+	let l:digits = '0' . l:digits
  278
+    endwhile
  279
+    return strpart( l:digits, 0, 2 )
  280
+endfunction
  281
+
  282
+function! s:EchoElapsedTimeSinceVersion( backupFile )
  283
+"*******************************************************************************
  284
+"* PURPOSE:
  285
+"   Informs the user about the elapsed time since the passed a:backupFile has
  286
+"   been modified. 
  287
+"* ASSUMPTIONS / PRECONDITIONS:
  288
+"	? List of any external variable, control, or other element whose state affects this procedure.
  289
+"* EFFECTS / POSTCONDITIONS:
  290
+"	? List of the procedure's effect on each external variable, control, or other element.
  291
+"* INPUTS:
  292
+"	? Explanation of each argument that isn't obvious.
  293
+"* RETURN VALUES: 
  294
+"   none
  295
+"*******************************************************************************
  296
+    let l:timeElapsed = localtime() - getftime( a:backupFile )
  297
+    let l:secondsElapsed = l:timeElapsed % 60
  298
+    let l:minutesElapsed = (l:timeElapsed / 60) % 60
  299
+    let l:hoursElapsed = (l:timeElapsed / 3600) % 24
  300
+    let l:daysElapsed = (l:timeElapsed / (3600 * 24))
  301
+    let l:message = 'The last backup was done '
  302
+    if l:daysElapsed > 0
  303
+	let l:message .= l:daysElapsed . ' days, '
  304
+    endif
  305
+    let l:message .= s:DualDigit(l:hoursElapsed) . ':' . s:DualDigit(l:minutesElapsed) . ':' . s:DualDigit(l:secondsElapsed) . ' ago.'
  306
+
  307
+    echomsg l:message
  308
+endfunction
  309
+
  310
+function! s:ListVersions( filespec )
  311
+"*******************************************************************************
  312
+"* PURPOSE:
  313
+"   Shows the user a list of all available versions for a:filespec. 
  314
+"* ASSUMPTIONS / PRECONDITIONS:
  315
+"	? List of any external variable, control, or other element whose state affects this procedure.
  316
+"* EFFECTS / POSTCONDITIONS:
  317
+"	? List of the procedure's effect on each external variable, control, or other element.
  318
+"* INPUTS:
  319
+"	? Explanation of each argument that isn't obvious.
  320
+"* RETURN VALUES: 
  321
+"   none
  322
+"*******************************************************************************
  323
+    let l:originalFilespec = s:GetOriginalFilespec( a:filespec )
  324
+    let l:currentVersion = s:GetVersion( a:filespec )
  325
+    let l:backupfiles = s:GetAllBackupsForFile( l:originalFilespec )
  326
+    if empty( l:backupfiles )
  327
+	echomsg "No backups exist for file '" . s:GetOriginalFilespec( l:originalFilespec ) . "'. "
  328
+	return
  329
+    endif
  330
+
  331
+    let l:versionMessageHeader = "These backups exist for file '" . s:GetOriginalFilespec( l:originalFilespec ) . "'"
  332
+    let l:versionMessageHeader .= ( empty(l:currentVersion) ? ': ' : ' (current version is marked >x<): ')
  333
+    echomsg l:versionMessageHeader
  334
+    let l:versionMessage = ''
  335
+    let l:backupVersion = ''
  336
+    for l:backupfile in l:backupfiles
  337
+	let l:previousVersion = l:backupVersion
  338
+	let l:backupVersion = s:GetVersion( l:backupfile )
  339
+	if strpart( l:backupVersion, 0, len(l:backupVersion) - 1 ) == strpart( l:previousVersion, 0, len(l:previousVersion) - 1 )
  340
+	    let l:versionMessageAddition = strpart( l:backupVersion, len(l:backupVersion) - 1 )
  341
+	    if l:backupVersion == l:currentVersion
  342
+		let l:versionMessageAddition = '>' . l:versionMessageAddition . '<'
  343
+	    endif
  344
+	    let l:versionMessage .= l:versionMessageAddition
  345
+	else
  346
+	    echomsg l:versionMessage 
  347
+	    let l:versionMessage = l:backupVersion
  348
+	    if l:backupVersion == l:currentVersion
  349
+		let l:versionMessage= strpart( l:versionMessage, 0, len(l:versionMessage) - 1 ). '>' . strpart( l:versionMessage, len(l:versionMessage) - 1 ) . '<'
  350
+	    endif
  351
+	endif
  352
+    endfor
  353
+    echomsg l:versionMessage
  354
+
  355
+    if empty( l:currentVersion )
  356
+	let l:lastBackupFile = l:backupfiles[ len( l:backupfiles ) - 1 ]
  357
+	call s:EchoElapsedTimeSinceVersion( l:lastBackupFile )
  358
+    endif
  359
+endfunction
  360
+
  361
+function! s:IsBackedUp( filespec )
  362
+"*******************************************************************************
  363
+"* PURPOSE:
  364
+"   Informs the user whether there exists a backup for the passed a:filespec file. 
  365
+"* ASSUMPTIONS / PRECONDITIONS:
  366
+"	? List of any external variable, control, or other element whose state affects this procedure.
  367
+"* EFFECTS / POSTCONDITIONS:
  368
+"	? List of the procedure's effect on each external variable, control, or other element.
  369
+"* INPUTS:
  370
+"	? Explanation of each argument that isn't obvious.
  371
+"* RETURN VALUES: 
  372
+"   none
  373
+"*******************************************************************************
  374
+    let l:predecessor = s:VerifyIsOriginalFileAndHasPredecessor( a:filespec, 'You can only check the backup status of the original file, not of backups!' )
  375
+    if empty( l:predecessor )
  376
+	return
  377
+    endif
  378
+
  379
+    " As we compare the predecessor with the saved original file, not the actual
  380
+    " buffer contents (and this is what the user typically wants; checking
  381
+    " whether it is save to write this buffer because an update exists), we add
  382
+    " a hint to the user message if the buffer is indeed modified. 
  383
+    let l:savedMsg = (&l:modified ? 'saved ' : '') 
  384
+
  385
+    " Optimization: First compare the file sizes, as this is much faster than
  386
+    " performing an actual diff; we're not interested in the differences,
  387
+    " anyway, only if there *are* any!
  388
+    if getfsize( l:predecessor ) != getfsize( a:filespec )
  389
+	echohl WarningMsg
  390
+	echomsg "The current " . l:savedMsg . "version of '" . a:filespec . "' is different from the latest backup version '" . s:GetVersion( l:predecessor ) . "'. "
  391
+	echohl None
  392
+	return
  393
+    endif
  394
+
  395
+    " Expand filespecs to absolute paths to avoid problems with cwd, especially
  396
+    " on Windows systems with UNC paths. 
  397
+    let l:predecessorFilespec = fnamemodify( l:predecessor, ':p' )
  398
+    let l:originalFilespec = fnamemodify( a:filespec, ':p' )
  399
+
  400
+    " Note: We could save the effort of outputting the diff output to the
  401
+    " console if that didn't introduce platform-dependent code (NUL vs.
  402
+    " /dev/null) and meddling with the 'shellredir' setting. 
  403
+    let l:diffCmd = 'silent !diff "' . l:predecessorFilespec . '" "' . l:originalFilespec . '"'
  404
+    execute l:diffCmd
  405
+"****D echo '**** diff return code=' . v:shell_error
  406
+
  407
+    if v:shell_error == 0
  408
+	echomsg "The current " . l:savedMsg . "version of '" . a:filespec . "' is identical with the latest backup version '" . s:GetVersion( l:predecessor ) . "'. "
  409
+    elseif v:shell_error == 1
  410
+	echohl WarningMsg
  411
+	echomsg "The current " . l:savedMsg . "version of '" . a:filespec . "' is different from the latest backup version '" . s:GetVersion( l:predecessor ) . "'. "
  412
+	echohl None
  413
+    elseif v:shell_error >= 2
  414
+	echohl Error
  415
+	echomsg "Encountered problems with the 'diff' tool. Unable to compare with latest backup. "
  416
+	echohl None
  417
+    endif
  418
+endfunction
  419
+
  420
+function! s:Copy( source, target )
  421
+"*******************************************************************************
  422
+"* PURPOSE:
  423
+"   Copies a:source to a:target. If a:target exists, it is overwritten. 
  424
+"* ASSUMPTIONS / PRECONDITIONS:
  425
+"   none
  426
+"* EFFECTS / POSTCONDITIONS:
  427
+"   Creates / modifies a:target on the file system. 
  428
+"* INPUTS:
  429
+"   a:source filespec
  430
+"   a:target filespec
  431
+"* RETURN VALUES: 
  432
+"   none
  433
+"   throws 'WriteBackupVersionControl: Unsupported operating system type.'
  434
+"   throws copy command output if shell copy command failed
  435
+"*******************************************************************************
  436
+    " Expand filespecs to absolute paths to avoid problems with cwd, especially
  437
+    " on Windows systems with UNC paths. 
  438
+    let l:sourceFilespec = fnamemodify( a:source, ':p' )
  439
+    let l:targetFilespec = fnamemodify( a:target, ':p' )
  440
+
  441
+    if has('win32')
  442
+	let l:copyCmd = 'copy /Y "' . l:sourceFilespec . '" "' . l:targetFilespec . '"'
  443
+    elseif has('unix')
  444
+	let l:copyCmd = 'cp "' . l:sourceFilespec . '" "' . l:targetFilespec . '"'
  445
+    else
  446
+	throw 'WriteBackupVersionControl: Unsupported operating system type.'
  447
+    endif
  448
+
  449
+    let l:cmdOutput = system( l:copyCmd )
  450
+    if v:shell_error != 0
  451
+	throw l:cmdOutput
  452
+    endif
  453
+endfunction
  454
+
  455
+function! s:Restore( source, target, confirmationMessage )
  456
+"*******************************************************************************
  457
+"* PURPOSE:
  458
+"   Restores a:source over an existing a:target. The user is asked to confirm
  459
+"   this destructive operation, using the passed a:confirmationMessage. 
  460
+"* ASSUMPTIONS / PRECONDITIONS:
  461
+"   none
  462
+"* EFFECTS / POSTCONDITIONS:
  463
+"   Modifies a:target on the file system. 
  464
+"* INPUTS:
  465
+"   a:source filespec
  466
+"   a:target filespec
  467
+"   a:confirmationMessage
  468
+"* RETURN VALUES: 
  469
+"   boolean indicating whether the file has actually been restored. 
  470
+"*******************************************************************************
  471
+    let l:response = confirm( a:confirmationMessage, "&No\n&Yes", 1, 'Question' )
  472
+    if l:response != 2
  473
+	echomsg 'Restore canceled. '
  474
+	return 0
  475
+    endif
  476
+
  477
+    " We could restore using only VIM functionality:
  478
+    "	edit! a:target
  479
+    " 	normal ggdG
  480
+    " 	0read a:source
  481
+    " 	write
  482
+    " But that would make the target's modification date different from the one
  483
+    " of the source, which would fool superficial synchronization tools. 
  484
+    " In addition, there's the (small) risk that VIM autocmds or settings like
  485
+    " 'fileencoding' or 'fileformat' are now different from when the backup was
  486
+    " written, and may thus lead to conversion errors or different file
  487
+    " contents. 
  488
+    " Thus, we invoke an external command to create a perfect copy.
  489
+    " Unfortunately, this introduces platform-specific code. 
  490
+    try
  491
+	call s:Copy( a:source, a:target )
  492
+    catch
  493
+	echohl Error
  494
+	echomsg 'Failed to restore file: ' . v:exception
  495
+	echohl None
  496
+	return 0
  497
+    endtry
  498
+    return 1
  499
+endfunction
  500
+
  501
+function! s:RestoreFromPred( originalFilespec )
  502
+"*******************************************************************************
  503
+"* PURPOSE:
  504
+"   Restores the passed original file with its latest backup. 
  505
+"* ASSUMPTIONS / PRECONDITIONS:
  506
+"	? List of any external variable, control, or other element whose state affects this procedure.
  507
+"* EFFECTS / POSTCONDITIONS:
  508
+"	? List of the procedure's effect on each external variable, control, or other element.
  509
+"* INPUTS:
  510
+"	? Explanation of each argument that isn't obvious.
  511
+"* RETURN VALUES: 
  512
+"   none
  513
+"*******************************************************************************
  514
+    let l:predecessor = s:VerifyIsOriginalFileAndHasPredecessor( a:originalFilespec, 'You can only restore the original file, not a backup!' )
  515
+    if empty( l:predecessor )
  516
+	return
  517
+    endif
  518
+
  519
+    if s:Restore( l:predecessor, a:originalFilespec, "Really override this file with backup '" . s:GetVersion( l:predecessor ) . "'?" )
  520
+	edit!
  521
+    endif
  522
+endfunction
  523
+
  524
+function! s:RestoreThisBackup( filespec )
  525
+"*******************************************************************************
  526
+"* PURPOSE:
  527
+"   Restores the passed file as the original file. 
  528
+"* ASSUMPTIONS / PRECONDITIONS:
  529
+"	? List of any external variable, control, or other element whose state affects this procedure.
  530
+"* EFFECTS / POSTCONDITIONS:
  531
+"	? List of the procedure's effect on each external variable, control, or other element.
  532
+"* INPUTS:
  533
+"	? Explanation of each argument that isn't obvious.
  534
+"* RETURN VALUES: 
  535
+"   none
  536
+"*******************************************************************************
  537
+    let l:currentVersion = s:GetVersion( a:filespec )
  538
+    let l:originalFilespec = s:GetOriginalFilespec( a:filespec )
  539
+    if empty( l:currentVersion )
  540
+	echohl Error
  541
+	echomsg 'You can only restore backup files!'
  542
+	echohl None
  543
+	return
  544
+    endif
  545
+
  546
+    if s:Restore( a:filespec, l:originalFilespec, "Really override '" . l:originalFilespec . "' with this backup '" . l:currentVersion . "'?" )
  547
+	execute 'edit! ' . escape( tr( l:originalFilespec, '\', '/'), ' \%#' )
  548
+    endif
  549
+endfunction
  550
+
  551
+function! s:WriteBackupOfSavedOriginal()
  552
+"*******************************************************************************
  553
+"* PURPOSE:
  554
+"   Instead of backing up the current buffer, back up the saved version of the
  555
+"   buffer. 
  556
+"* ASSUMPTIONS / PRECONDITIONS:
  557
+"	? List of any external variable, control, or other element whose state affects this procedure.
  558
+"* EFFECTS / POSTCONDITIONS:
  559
+"	? List of the procedure's effect on each external variable, control, or other element.
  560
+"* INPUTS:
  561
+"   none
  562
+"* RETURN VALUES: 
  563
+"   none
  564
+"*******************************************************************************
  565
+    try
  566
+	let l:backupfilename = WriteBackup_GetBackupFilename()
  567
+	call s:Copy( expand('%'), l:backupfilename )
  568
+	echomsg '"' . l:backupfilename . '" written'
  569
+    catch /^WriteBackup:/
  570
+	" All backup letters a-z are already used; report error. 
  571
+	echohl Error
  572
+	echomsg "Ran out of backup file names"
  573
+	echohl None
  574
+    catch
  575
+	echohl Error
  576
+	echomsg 'Failed to backup file: ' . v:exception
  577
+	echohl None
  578
+    endtry
  579
+endfunction
  580
+
  581
+"- commands -------------------------------------------------------------------
  582
+command! WriteBackupDiffWithPred	:call <SID>DiffWithPred(expand('%'))
  583
+command! WriteBackupListVersions	:call <SID>ListVersions(expand('%'))
  584
+command! WriteBackupIsBackedUp		:call <SID>IsBackedUp(expand('%'))
  585
+command! WriteBackupRestoreFromPred	:call <SID>RestoreFromPred(expand('%'))
  586
+command! WriteBackupRestoreThisBackup	:call <SID>RestoreThisBackup(expand('%'))
  587
+"command! WriteBackupDeleteLastBackup
  588
+command! WriteBackupOfSavedOriginal	:call <SID>WriteBackupOfSavedOriginal()
  589
+
BIN  .vim/bitmaps/Preview.bmp
Binary file not shown
28  .vim/bitmaps/Preview.xpm
... ...
@@ -0,0 +1,28 @@
  1
+/* XPM */
  2
+static char * Preview_xpm[] = {
  3
+"24 20 5 1",
  4
+" 	c None",
  5
+".	c #000000",
  6
+"+	c #7B7B7B",
  7
+"@	c #BDBDBD",
  8
+"#	c #FFFFFF",
  9
+"                        ",
  10
+"                        ",
  11
+"        .......         ",
  12
+"      ...........       ",
  13
+"     .............      ",
  14
+"    .........+++...     ",
  15
+"   ......###..@@+...    ",
  16
+"  .......###...@@++..   ",
  17
+" ...........#...#@@+..  ",
  18
+"............#...@#@@+.. ",
  19
+"............#...#@#@+...",
  20
+"....#.......#...@#@@+.. ",
  21
+" ...#......#....#@@+..  ",
  22
+"  ...#....#....@@@+..   ",
  23
+"   ...####....@@@+..    ",
  24
+"    .........@@++..     ",
  25
+"     .......+++...      ",
  26
+"       ..........       ",
  27
+"                        ",
  28
+"                        "};
BIN  .vim/bitmaps/w3m.bmp
Binary file not shown
33  .vim/bitmaps/w3m.xpm
... ...
@@ -0,0 +1,33 @@
  1
+/* XPM */
  2
+static char * W3m_xpm[] = {
  3
+"20 20 10 1",
  4
+" 	c None",
  5
+".	c #FF0000",
  6
+"+	c #00FF00",
  7
+"@	c #679900",
  8
+"#	c #FB0400",
  9
+"$	c #0300FC",
  10
+"%	c #0600F9",
  11
+"&	c #0000FF",
  12
+"*	c #009F60",
  13
+"=	c #0005FA",
  14
+"         .          ",
  15
+"         ..         ",
  16
+"        ... ..      ",
  17
+"        .. ....     ",
  18
+"        .......     ",
  19
+" ++++   ....... ..  ",
  20
+" ++++++@#.. ......  ",
  21
+"    ++++ .  .....   ",
  22
+"  ++++++    ....    ",
  23
+" ++++        ..     ",
  24
+" +++++       $%     ",
  25
+"  ++++++    &&&&    ",
  26
+"    ++++ &  &&&&&   ",
  27
+" ++++++*=&& &&&&&&  ",
  28
+" ++++   &&&&&& &&&  ",
  29
+"        &&&&&&&     ",
  30
+"        && &&&&     ",
  31
+"        &&  &&      ",
  32
+"         &&         ",
  33
+"         &          "};
29  .vimrc
@@ -129,6 +129,7 @@
129 129
     " set tags 
130 130
     :set tags+=../tags,../../tags
131 131
 
  132
+    :set number
132 133
 "### }}}1
133 134
 
134 135
 "### Encodings {{{1
@@ -322,6 +323,34 @@
322 323
 
323 324
 "### }}}1
324 325
 
  326
+"### general function defination {{{1
  327
+    function! MyFoldText()
  328
+      let line = getline(v:foldstart)
  329
+      let nnum = nextnonblank(v:foldstart + 1)
  330
+      let nextline = getline(nnum)
  331
+      if nextline =~ '^\s\+"""$'
  332
+        let line = line . getline(nnum + 1)
  333
+      elseif nextline =~ '^\s\+"""'
  334
+        let line = line . ' ' . matchstr(nextline, '"""\zs.\{-}\ze\("""\)\?$')
  335
+      elseif nextline =~ '^\s\+"[^"]\+"$'
  336
+        let line = line . ' ' . matchstr(nextline, '"\zs.*\ze"')
  337
+      elseif nextline =~ '^\s\+pass\s*$'
  338
+        let line = line . ' pass'
  339
+      endif
  340
+      let size = 1 + v:foldend - v:foldstart
  341
+      if size < 10
  342
+        let size = " " . size
  343
+      endif
  344
+      if size < 100
  345
+        let size = " " . size
  346
+      endif
  347
+      if size < 1000
  348
+        let size = " " . size
  349
+      endif
  350
+      return "[" . size . "] " . line
  351
+    endfunction
  352
+"}}}1
  353
+    
325 354
 "### Platform dependent Setting {{{1
326 355
     "if has("vms")
327 356
       "set nobackup      " do not keep a backup file, use versions instead
18  mytools/netgrowl.py
... ...
@@ -1,5 +1,11 @@
1 1
 #!/usr/bin/env python
2 2
 
  3
+"""
  4
+TODO: 
  5
+    1. add config for which notify-client is used. options are:
  6
+        gnome-osd-client, notify-send, growl  etc
  7
+"""
  8
+
3 9
 # URL for this script: http://the.taoofmac.com/space/Projects/netgrowl.py
4 10
 """Growl 0.6 Network Protocol Client for Python"""
5 11
 __version__ = "0.6" # will always match Growl version
@@ -7,6 +13,7 @@
7 13
 __copyright__ = "(C) 2004 Rui Carmo. Code under BSD License."
8 14
 __contributors__ = "Ingmar J Stein (Growl Team)"
9 15
 
  16
+
10 17
 import os
11 18
 import sys
12 19
 import optparse
@@ -157,7 +164,16 @@ def _send_notify_by_notifydaemon(name, message, icon, time):
157 164
     message = message.replace('>', '&gt;')
158 165
     message = message.replace("'", '&apos;')
159 166
 
160  
-    cmd = "notify-send -i %s -t %s '%s' '%s'" % (icon, time, name, message)
  167
+    #cmd = "notify-send -i %s -t %s '%s' '%s'" % (icon, time, name, message)
  168
+
  169
+    cmd = 'gnome-osd-client "(%s): %s"' % (name, message)
  170
+
  171
+    # the following command is very slow 
  172
+    #cmd = """
  173
+    #gnome-osd-client -f "<message id='notification' osd_fake_translucent_bg='on'
  174
+    #hide_timeout='5000' osd_halignment='right'>From (%s): %s </message>"
  175
+    #""" % (name, message)
  176
+
161 177
     os.system(cmd)
162 178
 
163 179
 def send_notify(options):

0 notes on commit de2d5fc

Please sign in to comment.
Something went wrong with that request. Please try again.