public
Description: hax0r vim script to give you a tree explorer
Clone URL: git://github.com/scrooloose/nerdtree.git
Search Repo:
improve invalid bookmarks handling

invalid bookmarks now placed after a blank line at the bottom of the
bookmarks file

if invalid bookmarks are detected, an error is outputted which directs
the user to :help NERDTreeInvalidBookmarks, which had been added to the
help file in this commit
scrooloose (author)
Wed Jul 16 03:46:46 -0700 2008
commit  5c95fbda65dd5e42ff87a606dde86ad14da74090
tree    b2683c221330ab2e349a3a8a90ecd184f4b3dbbc
parent  3e217115bc467f1298ef7880fbe7fe74f75d5f8e
...
25
26
27
 
28
29
30
...
158
159
160
 
 
 
161
162
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
165
166
...
25
26
27
28
29
30
31
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
0
@@ -25,6 +25,7 @@ CONTENTS *NERDTree-contents*
0
         2.2 Bookmarks.........................|NERDTreeBookmarks|
0
             2.2.1 The bookmark table..........|NERDTreeBookmarkTable|
0
             2.2.2 Bookmark commands...........|NERDTreeBookmarkCommands|
0
+ 2.2.3 Invalid bookmarks...........|NERDTreeInvalidBookmarks|
0
         2.3 NERD tree mappings................|NERDTreeMappings|
0
         2.4 The filesystem menu...............|NERDTreeFilesysMenu|
0
     3.Options.................................|NERDTreeOptions|
0
@@ -158,9 +159,28 @@ Note that the following commands are only available in the NERD tree buffer.
0
 :ClearAllBookmarks
0
     Remove all bookmarks.
0
 
0
+:ReadBookmarks
0
+ Re-read the bookmarks in the |NERDTreeBookmarksFile|.
0
+
0
 See also |:NERDTree| and |:NERDTreeFromBookmark|.
0
 
0
 ------------------------------------------------------------------------------
0
+2.2.3. Invalid Bookmarks *NERDTreeInvalidBookmarks*
0
+
0
+If invalid bookmarks are detected, the script will issue an error message and
0
+the invalid bookmarks will become unavailable for use.
0
+
0
+These bookmarks will still be stored in the bookmarks file (see
0
+|NERDTreeBookmarksFile|), down the bottom. There will always be a blank line
0
+after the valid bookmarks but before the invalid ones.
0
+
0
+Each line in the bookmarks file represents one bookmark. The proper format is:
0
+<bookmark name><space><full path to the bookmark location>
0
+
0
+After you have corrected any invalid bookmarks, either restart vim, or go
0
+:ReadBookmarks from the NERD tree window.
0
+
0
+------------------------------------------------------------------------------
0
 2.3. NERD tree Mappings *NERDTreeMappings*
0
 
0
 Default Description~ help-tag~
...
221
222
223
224
225
226
227
228
229
230
231
232
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
235
236
237
238
239
240
 
241
242
 
243
244
245
...
352
353
354
 
 
 
 
355
356
357
...
2809
2810
2811
2812
2813
 
2814
2815
2816
...
221
222
223
 
 
224
 
 
 
 
 
 
 
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
 
 
 
243
244
245
246
247
248
249
...
356
357
358
359
360
361
362
363
364
365
...
2817
2818
2819
 
 
2820
2821
2822
2823
0
@@ -221,25 +221,29 @@ function! s:oBookmark.CacheBookmarks(silent) dict
0
         let bookmarkStrings = readfile(g:NERDTreeBookmarksFile)
0
         let invalidBookmarksFound = 0
0
         for i in bookmarkStrings
0
- let name = substitute(i, '^\(.\{-}\) .*$', '\1', '')
0
- let path = substitute(i, '^.\{-} \(.*\)$', '\1', '')
0
 
0
- try
0
- let bookmark = s:oBookmark.New(name, s:oPath.New(path))
0
- call add(g:NERDTreeBookmarks, bookmark)
0
- catch /NERDTree.Path.InvalidArguments/
0
- call add(g:NERDTreeInvalidBookmarks, i)
0
- let invalidBookmarksFound += 1
0
- endtry
0
+ "ignore blank lines
0
+ if i != ''
0
+
0
+ let name = substitute(i, '^\(.\{-}\) .*$', '\1', '')
0
+ let path = substitute(i, '^.\{-} \(.*\)$', '\1', '')
0
+
0
+ try
0
+ let bookmark = s:oBookmark.New(name, s:oPath.New(path))
0
+ call add(g:NERDTreeBookmarks, bookmark)
0
+ catch /NERDTree.Path.InvalidArguments/
0
+ call add(g:NERDTreeInvalidBookmarks, i)
0
+ let invalidBookmarksFound += 1
0
+ endtry
0
+ endif
0
         endfor
0
         if invalidBookmarksFound
0
             call s:oBookmark.Write()
0
             if !a:silent
0
- call s:Echo(invalidBookmarksFound .
0
- \ " invalid bookmarks were read. They have been moved to the bottom of ".
0
- \ g:NERDTreeBookmarksFile. " please edit or remove them.")
0
+ call s:Echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.")
0
             endif
0
         endif
0
+ call s:oBookmark.Sort()
0
     endif
0
 endfunction
0
 " FUNCTION: oBookmark.CompareTo(otherbookmark) {{{3
0
@@ -352,6 +356,10 @@ function! s:oBookmark.Write() dict
0
     for i in s:oBookmark.Bookmarks()
0
         call add(bookmarkStrings, i.name . ' ' . i.path.StrForOS(0))
0
     endfor
0
+
0
+ "add a blank line before the invalid ones
0
+ call add(bookmarkStrings, "")
0
+
0
     for j in s:oBookmark.InvalidBookmarks()
0
         call add(bookmarkStrings, j)
0
     endfor
0
@@ -2809,8 +2817,7 @@ function! s:ValidateBookmark(bookmark)
0
         return 1
0
     catch /NERDTree.BookmarkPointsToInvalidLocation/
0
         call s:RenderView()
0
- echo a:bookmark.name . " now points to an invalid location. It has been moved to the bottom of ".
0
- \ g:NERDTreeBookmarksFile . " please edit or remove it"
0
+ call s:Echo(a:bookmark.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.")
0
     endtry
0
 endfunction
0
 

Comments

    No one has commented yet.