From 463cab0af26022d8c2cad3760383bcc6f41dd57f Mon Sep 17 00:00:00 2001
From: Max Christian Pohle
Date: Fri, 17 Jul 2020 00:28:51 +0200
Subject: Improved README and code comments

---
 plugin/vim-recently-used.vim | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

(limited to 'plugin')

diff --git a/plugin/vim-recently-used.vim b/plugin/vim-recently-used.vim
index 48bb5d6..971d592 100644
--- a/plugin/vim-recently-used.vim
+++ b/plugin/vim-recently-used.vim
@@ -1,16 +1,18 @@
 "=======================================================================================================================
-" MAX_SPLASH:
+" vim-recently-used
 " Shows recently used files from the current directory in a location list
 "=======================================================================================================================
 
-command RecentlyUsed call setloclist(0, [])
-    \ | :lopen
-    \ | setlocal nospell
-    \ | setlocal signcolumn=yes
-    \ | setfiletype qf
-    \ | call setloclist(0, [], 'r', {
-    \ 'title':'Recently used files in directory: '.getcwd(),
-    \ 'items':sort(map(filter(filter(map(copy(v:oldfiles[:100]),
+" from the list of recent files: make absolute paths, filter out files not
+" contained in cwd and finally filter out directories and non-files...
+command! RecentlyUsed call setloclist(0, [])
+    \  | :lopen
+    \  | setlocal nospell
+    \  | setlocal signcolumn=yes
+    \  | setfiletype qf
+    \  | call setloclist(0, [], 'r', {
+    \  'title':'Recently used files in directory: '.getcwd(),
+    \  'items':sort(map(filter(filter(map(copy(v:oldfiles[:100]),
     \                                    {_, p->expand(p)}),
     \                                'v:val =~ "'.getcwd().'/"'),
     \                         'filereadable(v:val)'),
@@ -22,20 +24,14 @@ command RecentlyUsed call setloclist(0, [])
     \                                           fnamemodify(p, ':.')
     \                                          )}}),
     \              {a1, a2 -> a1.module < a2.module})
-    \ })
+    \    })
 
-" autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val}))
-" from the list of recent files: make absolute paths, filter out files not
-" contained in cwd and finally filter out directories and non-files...
+" if we have Vim receiving input from a pipe, this VimEnter command would
+" trigger an error. Also when calling Vim with other arguments. In both cases
+" we know what we want and that is not the list with recently opened files.
 autocmd StdinReadPre * let s:std_in=1
-autocmd VimEnter * 
+autocmd VimEnter *
     \ if !exists("s:std_in") && empty(argv())
     \ |     execute ':RecentlyUsed"
     \ |     wincmd w'
     \ | endif
-
-" http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:caddexpr
-" for c in range(char2nr('a'), char2nr('z')) + range(char2nr('A'), char2nr('Z')) +  range(0,9) | let p = getpos("'".nr2char(c)) | if (p[1] > 0) | exec "sign define mark_".nr2char(c)." text=".nr2char(c)." linehl=linenr" | exec "sign place ".c." name=mark_".nr2char(c)." line=".p[1] | endif  | endfor
-" for c in range(char2nr('a'), char2nr('z')) + range(char2nr('A'), char2nr('Z')) +  range(0,9) | let p = line("'".nr2char(c)) | if (p > 0) | exec "sign define mark_".nr2char(c)." text=".nr2char(c)." linehl=linenr" | exec "sign place ".c." name=mark_".nr2char(c)." line=".p | endif  | endfor 
-" call sign_unplace('marks') | for c in range(char2nr('a'), char2nr('z')) + range(char2nr('A'), char2nr('Z')) +  range(0,9) | let p = line("'".nr2char(c)) | if (p > 0) | call sign_define("mark_".nr2char(c), { "text" : nr2char(c), "linehl": "linenr"}) | call sign_place(c, 'marks', "mark_".nr2char(c), '', {'lnum': p}) | endif  | endfor 
-" call sign_unplace('marks') | for c in range(char2nr('a'), char2nr('z')) + range(char2nr('A'), char2nr('Z')) +  range(char2nr('0'), char2nr('9')) | let p = line("'".nr2char(c)) | if (p > 0) | call sign_define("mark_".nr2char(c), { "text" : nr2char(c), "texthl": "linenr"}) | call sign_place(c, 'marks', "mark_".nr2char(c), '', {'lnum': p}) | endif  | endfor 
-- 
cgit v1.2.3