Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removed support for metadata (which was broken anyway)

  • Loading branch information...
commit 97a119b3052d160237ee529802971429754a2427 1 parent 9051916
Tom Link authored July 18, 2012

Showing 1 changed file with 23 additions and 85 deletions. Show diff stats Hide diff stats

  1. 108  plugin/tmru.vim
108  plugin/tmru.vim
@@ -3,8 +3,8 @@
3 3
 " @Website:     http://www.vim.org/account/profile.php?user_id=4037
4 4
 " @License:     GPL (see http://www.gnu.org/licenses/gpl.txt)
5 5
 " @Created:     2007-04-13.
6  
-" @Last Change: 2012-06-21.
7  
-" @Revision:    508
  6
+" @Last Change: 2012-07-18.
  7
+" @Revision:    517
8 8
 " GetLatestVimScripts: 1864 1 tmru.vim
9 9
 
10 10
 if &cp || exists("loaded_tmru")
@@ -159,15 +159,12 @@ if !exists('g:tmru_check_disk')
159 159
 endif
160 160
 
161 161
 
162  
-" let s:did_increase_sessions = 0
163  
-
164  
-
165 162
 function! s:BuildMenu(initial) "{{{3
166 163
     if !empty(g:tmruMenu)
167 164
         if !a:initial
168 165
             silent! exec 'aunmenu '. g:tmruMenu
169 166
         endif
170  
-        let [mru, metadata] = s:MruRetrieve()
  167
+        let mru = s:MruRetrieve()
171 168
         if g:tmruMenuSize > 0 && len(mru) > g:tmruMenuSize
172 169
             let mru = mru[0 : g:tmruMenuSize - 1]
173 170
         endif
@@ -183,7 +180,7 @@ endf
183 180
 function! s:MruRetrieve(...)
184 181
     let read_data = a:0 >= 1 ? a:1 : 0
185 182
     if empty(g:tmru_file)
186  
-        if read_data && exists("g:TMRU") && exists("g:TMRU_METADATA")
  183
+        if read_data && exists("g:TMRU")
187 184
             if g:tmru_update_viminfo
188 185
                 rviminfo
189 186
             endif
@@ -191,45 +188,21 @@ function! s:MruRetrieve(...)
191 188
         if !exists("g:TMRU")
192 189
             let g:TMRU = ''
193 190
         endif
194  
-        if !exists("g:TMRU_METADATA")
195  
-            let g:TMRU_METADATA = ''
196  
-        endif
197 191
     else
198 192
         if read_data
199 193
             if exists('s:tmru_mtime') && getftime(g:tmru_file) == s:tmru_mtime
200 194
                 let read_data = 0
201 195
             endif
202  
-        elseif !exists("g:TMRU") || !exists("g:TMRU_METADATA")
  196
+        elseif !exists("g:TMRU")
203 197
             let read_data = 1
204 198
         endif
205 199
         if read_data
206 200
             let data = tlib#persistent#Get(g:tmru_file)
207 201
             let g:TMRU = get(data, 'tmru', '')
208  
-            let g:TMRU_METADATA = get(data, 'metadata', '')
209 202
             let s:tmru_mtime = getftime(g:tmru_file)
210 203
         endif
211 204
     endif
212 205
     let mru = split(g:TMRU, '\n')
213  
-    if empty(g:TMRU_METADATA)
214  
-        let g:TMRU_METADATA = join(repeat(['{}'], len(mru)), "\n")
215  
-    endif
216  
-    let metadata = map(split(g:TMRU_METADATA, '\n'), 'eval(v:val)')
217  
-    " if !s:did_increase_sessions
218  
-    "     for metaidx in range(len(metadata))
219  
-    "         let metaitem = metadata[metaidx]
220  
-    "         if type(metaitem) != 4
221  
-    "             echohl ErrorMsg
222  
-    "             echom "TMRU: metaitem is not a dictionary" string(metaitem)
223  
-    "             echohl NONE
224  
-    "             unlet metaitem
225  
-    "             let metaitem = {}
226  
-    "         endif
227  
-    "         let metaitem.sessions = get(metaitem, 'sessions', -1) + 1
228  
-    "         let metadata[metaidx] = metaitem
229  
-    "     endfor
230  
-    "     let s:did_increase_sessions = 1
231  
-    "     " echom "DBG s:MruStore" string(metadata)
232  
-    " endif
233 206
 
234 207
     " Canonicalize filename when using &shellslash (Windows)
235 208
     if exists('+shellslash')
@@ -240,19 +213,14 @@ function! s:MruRetrieve(...)
240 213
         endif
241 214
     endif
242 215
 
243  
-    " make it relative to $HOME internally
244  
-    " let mru = map(mru, 'fnamemodify(v:val, ":~")')
245  
-
246 216
     " TLogVAR mru
247  
-    return [mru, metadata]
  217
+    return mru
248 218
 endf
249 219
 
250 220
 
251  
-function! s:MruStore(mru, metadata, save)
  221
+function! s:MruStore(mru, save)
252 222
     " TLogVAR a:save, g:tmru_file
253 223
     let g:TMRU = join(a:mru, "\n")
254  
-    let metadata = a:metadata
255  
-    let g:TMRU_METADATA = join(map(metadata, 'string(v:val)'), "\n")
256 224
     " TLogVAR g:TMRU
257 225
     " echom "DBG s:MruStore" g:tmru_file
258 226
     call s:BuildMenu(0)
@@ -262,20 +230,12 @@ function! s:MruStore(mru, metadata, save)
262 230
                 wviminfo
263 231
             endif
264 232
         else
265  
-            call tlib#persistent#Save(g:tmru_file, {'tmru': g:TMRU, 'metadata': g:TMRU_METADATA})
  233
+            call tlib#persistent#Save(g:tmru_file, {'tmru': g:TMRU})
266 234
         endif
267 235
     endif
268 236
 endf
269 237
 
270 238
 
271  
-function! s:Metadata(filename, metadata) "{{{3
272  
-    if !empty(a:filename)
273  
-        let a:metadata.timestamp = localtime()
274  
-    endif
275  
-    return a:metadata
276  
-endf
277  
-
278  
-
279 239
 " Return 0 if the file isn't readable/doesn't exist.
280 240
 " Otherwise return 1.
281 241
 function! TmruEdit(filename) "{{{3
@@ -312,7 +272,7 @@ endf
312 272
 
313 273
 function! s:SelectMRU()
314 274
     " TLogDBG "SelectMRU#1"
315  
-    let [tmru, metadata] = s:MruRetrieve()
  275
+    let tmru = s:MruRetrieve()
316 276
     if !empty(tmru)
317 277
         " TLogDBG "SelectMRU#2"
318 278
         " TLogVAR tmru
@@ -332,8 +292,7 @@ function! s:SelectMRU()
332 292
                     let bi = index(tmru, bf)
333 293
                     " TLogVAR bi
334 294
                     call remove(tmru, bi)
335  
-                    call remove(metadata, bi)
336  
-                    call s:MruStore(tmru, metadata, 1)
  295
+                    call s:MruStore(tmru, 1)
337 296
                 endif
338 297
             endfor
339 298
             return 1
@@ -344,28 +303,18 @@ endf
344 303
 
345 304
 
346 305
 function! s:EditMRU()
347  
-    let [tmru, metadata] = s:MruRetrieve()
  306
+    let tmru = s:MruRetrieve()
348 307
     let tmru1 = tlib#input#EditList('Edit MRU', tmru)
349 308
     if tmru != tmru1
350  
-        let metadata1 = []
351  
-        for fname in tmru1
352  
-            let idx = index(tmru, fname)
353  
-            if idx == -1
354  
-                call add(metadata1, s:Metadata(fname, {}))
355  
-            else
356  
-                call add(metadata1, metadata[idx])
357  
-            endif
358  
-        endfor
359  
-        call s:MruStore(tmru1, metadata1, 1)
  309
+        call s:MruStore(tmru1, 1)
360 310
     endif
361 311
 endf
362 312
 
363 313
 
364 314
 function! s:AutoMRU(filename, event, props) "{{{3
365  
-    " if &buftype !~ 'nofile' && fnamemodify(a:filename, ":t") != '' && filereadable(fnamemodify(a:filename, ":t"))
366 315
     " TLogVAR a:filename, a:event, a:props, &buftype
367 316
     if g:tmru_debug
368  
-        let [mru, metadata] = s:MruRetrieve(a:props.load)
  317
+        let mru = s:MruRetrieve(a:props.load)
369 318
         call tmru#DisplayUnreadableFiles(mru)
370 319
     endif
371 320
     if a:props.load
@@ -375,17 +324,16 @@ function! s:AutoMRU(filename, event, props) "{{{3
375 324
         if &buflisted && &buftype !~ 'nofile' && fnamemodify(a:filename, ":t") != ''
376 325
                     \ && (!g:tmru_check_disk || (filereadable(a:filename) && !isdirectory(a:filename)))
377 326
             if a:event == 'BufDelete'
378  
-                let [mru, metadata] = s:MruRetrieve()
  327
+                let mru = s:MruRetrieve()
379 328
                 let fidx = index(mru, a:filename)
380 329
                 " TLogVAR fidx
381  
-                " let metadata[fidx].sessions = get(metadata[fidx], 'sessions', -1) + 1
382  
-                call s:MruStore(mru, metadata, 0)
  330
+                call s:MruStore(mru, 0)
383 331
             endif
384 332
             call s:MruRegister(a:filename, a:props.save)
385 333
         endif
386 334
     endif
387 335
     if g:tmru_debug
388  
-        let [mru, metadata] = s:MruRetrieve()
  336
+        let mru = s:MruRetrieve()
389 337
         call tmru#DisplayUnreadableFiles(mru)
390 338
     endif
391 339
     " TLogVAR "exit"
@@ -402,28 +350,24 @@ function! s:MruRegister(fname, save)
402 350
     if exists('b:tmruExclude') && b:tmruExclude
403 351
         return
404 352
     endif
405  
-    let [tmru0, metadata0] = s:MruRetrieve()
  353
+    let tmru0 = s:MruRetrieve()
406 354
     let tmru = copy(tmru0)
407  
-    let metadata = copy(metadata0)
408 355
     let imru = index(tmru, fname, 0, g:tmru_ignorecase)
409 356
     if imru == -1 && len(tmru) >= g:tmruSize
410 357
         let imru = g:tmruSize - 1
411 358
     endif
412  
-    let fmeta = {}
413 359
     if imru != -1
414 360
         call remove(tmru, imru)
415  
-        call remove(metadata, imru)
416 361
     endif
417 362
     call insert(tmru, fname)
418  
-    call insert(metadata, s:Metadata(fname, fmeta))
419 363
     if tmru != tmru0
420  
-        call s:MruStore(tmru, metadata, a:save)
  364
+        call s:MruStore(tmru, a:save)
421 365
     endif
422 366
 endf
423 367
 
424 368
 
425 369
 function! s:RemoveItem(world, selected) "{{{3
426  
-    let [mru, metadata] = s:MruRetrieve()
  370
+    let mru = s:MruRetrieve()
427 371
     " TLogVAR a:selected
428 372
     let idx = -1
429 373
     for filename in a:selected
@@ -434,10 +378,9 @@ function! s:RemoveItem(world, selected) "{{{3
434 378
         " TLogVAR filename, fidx
435 379
         if fidx >= 0
436 380
             call remove(mru, fidx)
437  
-            call remove(metadata, fidx)
438 381
         endif
439 382
     endfor
440  
-    call s:MruStore(mru, metadata, 1)
  383
+    call s:MruStore(mru, 1)
441 384
     call a:world.ResetSelected()
442 385
     let a:world.base = copy(mru)
443 386
     if idx > len(mru)
@@ -455,7 +398,7 @@ endf
455 398
 " This checks that files are readable and removes any (canonicalized)
456 399
 " duplicates.
457 400
 function! s:CheckFilenames(world, selected) "{{{3
458  
-    let [mru, metadata] = s:MruRetrieve()
  401
+    let mru = s:MruRetrieve()
459 402
     let idx = len(mru) - 1
460 403
     let uniqdict = {} " used to remove duplicates
461 404
     let unreadable = 0
@@ -467,13 +410,11 @@ function! s:CheckFilenames(world, selected) "{{{3
467 410
         if !filereadable(file)
468 411
             " TLogVAR file
469 412
             call remove(mru, idx)
470  
-            call remove(metadata, idx)
471 413
             let unreadable += 1
472 414
         elseif get(uniqdict, file)
473 415
             " file is a dupe
474 416
             let dupes += 1
475 417
             call remove(mru, idx)
476  
-            call remove(metadata, idx)
477 418
         else
478 419
             " file is OK, add it to dictionary for dupe checking
479 420
             let uniqdict[file] = 1
@@ -485,7 +426,7 @@ function! s:CheckFilenames(world, selected) "{{{3
485 426
         let idx -= 1
486 427
     endwh
487 428
     if unreadable > 0 || dupes > 0 || normalized > 0
488  
-        call s:MruStore(mru, metadata, 1)
  429
+        call s:MruStore(mru, 1)
489 430
         echom "TMRU: Removed" unreadable "unreadable and" dupes "duplicate"
490 431
                     \ "files from mru list, and normalized" normalized "entries."
491 432
     endif
@@ -504,6 +445,7 @@ augroup tmru
504 445
     unlet! s:event s:props
505 446
 augroup END
506 447
 
  448
+
507 449
 " Display the MRU list.
508 450
 command! TRecentlyUsedFiles call s:SelectMRU()
509 451
 
@@ -513,7 +455,3 @@ command! TMRU TRecentlyUsedFiles
513 455
 " Edit the MRU list.
514 456
 command! TRecentlyUsedFilesEdit call s:EditMRU()
515 457
 
516  
-" :display: :{count}TMRUSession
517  
-" Open files from a previous session. By default, use the last session.
518  
-" command! -count TMRUSession call tmru#Session(s:MruRetrieve(), <count>)
519  
-

0 notes on commit 97a119b

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