{"action":"created","comment":{"url":"https://api.github.com/repos/ledger/vim-ledger/pulls/comments/42859530","id":42859530,"diff_hunk":"@@ -400,3 +401,231 @@ func! ledger#entry()\n   normal \"_dd\n   exec l . 'read !' g:ledger_bin '-f' shellescape(expand('%')) 'entry' shellescape(query)\n endfunc\n+\n+\" Report generation {{{1\n+\n+\" Helper functions and variables {{{2\n+\" Position of report windows\n+let s:winpos_map = {\n+      \\ \"T\": \"to new\",  \"t\": \"abo new\", \"B\": \"bo new\",  \"b\": \"bel new\",\n+      \\ \"L\": \"to vnew\", \"l\": \"abo vnew\", \"R\": \"bo vnew\", \"r\": \"bel vnew\"\n+      \\ }\n+\n+function! s:error_message(msg)\n+  redraw  \" See h:echo-redraw\n+  echohl ErrorMsg\n+  echo \"\\r\"\n+  echomsg a:msg\n+  echohl NONE\n+endf\n+\n+function! s:warning_message(msg)\n+  redraw  \" See h:echo-redraw\n+  echohl WarningMsg\n+  echo \"\\r\"\n+  echomsg a:msg\n+  echohl NONE\n+endf\n+\n+\" Open the quickfix/location window when it is not empty,\n+\" closes it if it is empty.\n+\"\n+\" Optional parameters:\n+\" a:1  Quickfix window title.\n+\" a:2  Message to show when the window is empty.\n+\"\n+\" Returns 0 if the quickfix window is empty, 1 otherwise.\n+function! s:quickfix_toggle(...)\n+  if g:ledger_use_location_list\n+    let l:list = 'l'\n+    let l:open = (len(getloclist(winnr())) > 0)\n+  else\n+    let l:list = 'c'\n+    let l:open = (len(getqflist()) > 0)\n+  endif\n+\n+  if l:open\n+    execute (g:ledger_qf_vertical ? 'vert' : 'botright') l:list.'open' g:ledger_qf_size\n+    \" Note that the following settings do not persist (e.g., when you close and re-open the quickfix window).\n+    \" See: http://superuser.com/questions/356912/how-do-i-change-the-quickix-title-status-bar-in-vim\n+    if g:ledger_qf_hide_file\n+      set conceallevel=2\n+      set concealcursor=nc\n+      syntax match qfFile /^[^|]*/ transparent conceal\n+    endif\n+    if a:0 > 0\n+      let w:quickfix_title = a:1\n+    endif\n+    return 1\n+  endif\n+\n+  execute l:list.'close'\n+  call s:warning_message((a:0 > 1) ? a:2 : 'No results')\n+  return 0\n+endf\n+\n+\" Populate a quickfix/location window with data. The argument must be a String\n+\" or a List.\n+function! s:quickfix_populate(data)\n+  \" Note that cexpr/lexpr always uses the global value of errorformat\n+  let l:efm = &errorformat  \" Save global errorformat\n+  set errorformat=%EWhile\\ parsing\\ file\\ \\\"%f\\\"\\\\,\\ line\\ %l:,%ZError:\\ %m,%-C%.%#\n+  set errorformat+=%tarning:\\ \\\"%f\\\"\\\\,\\ line\\ %l:\\ %m\n+  \" Format to parse command-line errors:\n+  set errorformat+=Error:\\ %m\n+  set errorformat+=%f:%l\\ %m\n+  set errorformat+=%-G%.%#\n+  execute (g:ledger_use_location_list ? 'l' : 'c').'getexpr' 'a:data'\n+  let &errorformat = l:efm  \" Restore global errorformat\n+  return\n+endf\n+\n+\" Parse a list of ledger arguments and build a ledger command ready to be\n+\" executed.\n+\"\n+\" Note that %, # and < *at the start* of an item are expanded by Vim. If you\n+\" want to pass such characters to Ledger, escape them with a backslash.\n+\"\n+\" See also http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window\n+\" See also https://groups.google.com/forum/#!topic/vim_use/4ZejMpt7TeU\n+function! s:ledger_cmd(arglist)\n+  let l:cmd = g:ledger_bin\n+  for l:part in a:arglist\n+    if l:part =~ '\\v^[%#<]'\n+      let l:expanded_part = expand(l:part)\n+      let l:cmd .= ' ' . (l:expanded_part == \"\" ? l:part : shellescape(l:expanded_part))\n+    else\n+      let l:cmd .= ' ' . l:part\n+    endif\n+  endfor\n+  return l:cmd\n+endf\n+\n+function! s:is_ledger_buffer()\n+  if getbufvar(winbufnr(winnr()), \"&ft\") !=# \"ledger\"\n+    call s:error_message(\"Please switch to a Ledger buffer first.\")\n+    return 0\n+  endif\n+  return 1\n+endf\n+\" }}}\n+\n+\" Run an arbitrary ledger command to process the current buffer, and show the\n+\" output in a new buffer. If there are errors, no new buffer is opened: the\n+\" errors are displayed in a quickfix window instead.\n+\"\n+\" Parameters:\n+\" args  A string of Ledger arguments.\n+function! ledger#report(args)\n+  if !s:is_ledger_buffer() | return | endif\n+  let l:cmd = s:ledger_cmd(['-f', '%'] + split(a:args, ' '))\n+  if g:ledger_debug | return l:cmd | endif\n+  \" Run Ledger\n+  let l:output = systemlist(l:cmd)\n+  if v:shell_error  \" If there are errors, show them in a quickfix/location list.\n+    call s:quickfix_populate(l:output)\n+    call s:quickfix_toggle('Errors', 'Unable to parse errors')\n+    return\n+  endif\n+  if empty(l:output)\n+    call s:warning_message('No results')\n+    return\n+  endif\n+  \" Open a new buffer to show Ledger's output.\n+  execute get(s:winpos_map, g:ledger_winpos, \"bo new\")\n+  setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap\n+  call append(0, l:output)\n+  setlocal nomodifiable\n+  \" Set local mappings to quit window or lose focus.\n+  nnoremap <silent> <buffer> <tab> <c-w><c-w>\n+  nnoremap <silent> <buffer> q <c-w>c","path":"autoload/ledger.vim","position":146,"original_position":146,"commit_id":"614e84dd41a1dd5c197d852436360c82ca19612e","original_commit_id":"614e84dd41a1dd5c197d852436360c82ca19612e","user":{"login":"kljohann","id":67211,"avatar_url":"https://avatars.githubusercontent.com/u/67211?v=3","gravatar_id":"","url":"https://api.github.com/users/kljohann","html_url":"https://github.com/kljohann","followers_url":"https://api.github.com/users/kljohann/followers","following_url":"https://api.github.com/users/kljohann/following{/other_user}","gists_url":"https://api.github.com/users/kljohann/gists{/gist_id}","starred_url":"https://api.github.com/users/kljohann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kljohann/subscriptions","organizations_url":"https://api.github.com/users/kljohann/orgs","repos_url":"https://api.github.com/users/kljohann/repos","events_url":"https://api.github.com/users/kljohann/events{/privacy}","received_events_url":"https://api.github.com/users/kljohann/received_events","type":"User","site_admin":false},"body":"After using the `:Ledger` command I also expected these mappings to work in the `:Register` window. What do you think?","created_at":"2015-10-23T12:35:08Z","updated_at":"2015-10-23T12:35:08Z","html_url":"https://github.com/ledger/vim-ledger/pull/28#discussion_r42859530","pull_request_url":"https://api.github.com/repos/ledger/vim-ledger/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/ledger/vim-ledger/pulls/comments/42859530"},"html":{"href":"https://github.com/ledger/vim-ledger/pull/28#discussion_r42859530"},"pull_request":{"href":"https://api.github.com/repos/ledger/vim-ledger/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/ledger/vim-ledger/pulls/28","id":48017436,"html_url":"https://github.com/ledger/vim-ledger/pull/28","diff_url":"https://github.com/ledger/vim-ledger/pull/28.diff","patch_url":"https://github.com/ledger/vim-ledger/pull/28.patch","issue_url":"https://api.github.com/repos/ledger/vim-ledger/issues/28","number":28,"state":"open","locked":false,"title":"Reports and reconciling","user":{"login":"lifepillar","id":1193314,"avatar_url":"https://avatars.githubusercontent.com/u/1193314?v=3","gravatar_id":"","url":"https://api.github.com/users/lifepillar","html_url":"https://github.com/lifepillar","followers_url":"https://api.github.com/users/lifepillar/followers","following_url":"https://api.github.com/users/lifepillar/following{/other_user}","gists_url":"https://api.github.com/users/lifepillar/gists{/gist_id}","starred_url":"https://api.github.com/users/lifepillar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lifepillar/subscriptions","organizations_url":"https://api.github.com/users/lifepillar/orgs","repos_url":"https://api.github.com/users/lifepillar/repos","events_url":"https://api.github.com/users/lifepillar/events{/privacy}","received_events_url":"https://api.github.com/users/lifepillar/received_events","type":"User","site_admin":false},"body":"This set of commits adds the following functionality:\r\n\r\n- generate any kind of report inside Vim (sent to a new buffer);\r\n- generate a register report in the quickfix window, so that it is synchronized with the source code;\r\n- show an account's pending/cleared balance at the bottom of the screen (the account may be given explicitly or taken from the current line);\r\n- reconcile an account (similar to the Ledger plugin for Emacs) using the quickfix window..\r\n\r\nThis is the last of the pull requests I wanted to submit. I hope that they will be accepted so I can prune my vim configuration :)\r\n","created_at":"2015-10-18T20:47:11Z","updated_at":"2015-10-23T12:35:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"126447303a108f0007dd6073a66979e2ca584dbd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ledger/vim-ledger/pulls/28/commits","review_comments_url":"https://api.github.com/repos/ledger/vim-ledger/pulls/28/comments","review_comment_url":"https://api.github.com/repos/ledger/vim-ledger/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ledger/vim-ledger/issues/28/comments","statuses_url":"https://api.github.com/repos/ledger/vim-ledger/statuses/614e84dd41a1dd5c197d852436360c82ca19612e","head":{"label":"lifepillar:reports","ref":"reports","sha":"614e84dd41a1dd5c197d852436360c82ca19612e","user":{"login":"lifepillar","id":1193314,"avatar_url":"https://avatars.githubusercontent.com/u/1193314?v=3","gravatar_id":"","url":"https://api.github.com/users/lifepillar","html_url":"https://github.com/lifepillar","followers_url":"https://api.github.com/users/lifepillar/followers","following_url":"https://api.github.com/users/lifepillar/following{/other_user}","gists_url":"https://api.github.com/users/lifepillar/gists{/gist_id}","starred_url":"https://api.github.com/users/lifepillar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lifepillar/subscriptions","organizations_url":"https://api.github.com/users/lifepillar/orgs","repos_url":"https://api.github.com/users/lifepillar/repos","events_url":"https://api.github.com/users/lifepillar/events{/privacy}","received_events_url":"https://api.github.com/users/lifepillar/received_events","type":"User","site_admin":false},"repo":{"id":44066069,"name":"vim-ledger","full_name":"lifepillar/vim-ledger","owner":{"login":"lifepillar","id":1193314,"avatar_url":"https://avatars.githubusercontent.com/u/1193314?v=3","gravatar_id":"","url":"https://api.github.com/users/lifepillar","html_url":"https://github.com/lifepillar","followers_url":"https://api.github.com/users/lifepillar/followers","following_url":"https://api.github.com/users/lifepillar/following{/other_user}","gists_url":"https://api.github.com/users/lifepillar/gists{/gist_id}","starred_url":"https://api.github.com/users/lifepillar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lifepillar/subscriptions","organizations_url":"https://api.github.com/users/lifepillar/orgs","repos_url":"https://api.github.com/users/lifepillar/repos","events_url":"https://api.github.com/users/lifepillar/events{/privacy}","received_events_url":"https://api.github.com/users/lifepillar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lifepillar/vim-ledger","description":"Vim plugin for Ledger","fork":true,"url":"https://api.github.com/repos/lifepillar/vim-ledger","forks_url":"https://api.github.com/repos/lifepillar/vim-ledger/forks","keys_url":"https://api.github.com/repos/lifepillar/vim-ledger/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lifepillar/vim-ledger/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lifepillar/vim-ledger/teams","hooks_url":"https://api.github.com/repos/lifepillar/vim-ledger/hooks","issue_events_url":"https://api.github.com/repos/lifepillar/vim-ledger/issues/events{/number}","events_url":"https://api.github.com/repos/lifepillar/vim-ledger/events","assignees_url":"https://api.github.com/repos/lifepillar/vim-ledger/assignees{/user}","branches_url":"https://api.github.com/repos/lifepillar/vim-ledger/branches{/branch}","tags_url":"https://api.github.com/repos/lifepillar/vim-ledger/tags","blobs_url":"https://api.github.com/repos/lifepillar/vim-ledger/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lifepillar/vim-ledger/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lifepillar/vim-ledger/git/refs{/sha}","trees_url":"https://api.github.com/repos/lifepillar/vim-ledger/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lifepillar/vim-ledger/statuses/{sha}","languages_url":"https://api.github.com/repos/lifepillar/vim-ledger/languages","stargazers_url":"https://api.github.com/repos/lifepillar/vim-ledger/stargazers","contributors_url":"https://api.github.com/repos/lifepillar/vim-ledger/contributors","subscribers_url":"https://api.github.com/repos/lifepillar/vim-ledger/subscribers","subscription_url":"https://api.github.com/repos/lifepillar/vim-ledger/subscription","commits_url":"https://api.github.com/repos/lifepillar/vim-ledger/commits{/sha}","git_commits_url":"https://api.github.com/repos/lifepillar/vim-ledger/git/commits{/sha}","comments_url":"https://api.github.com/repos/lifepillar/vim-ledger/comments{/number}","issue_comment_url":"https://api.github.com/repos/lifepillar/vim-ledger/issues/comments{/number}","contents_url":"https://api.github.com/repos/lifepillar/vim-ledger/contents/{+path}","compare_url":"https://api.github.com/repos/lifepillar/vim-ledger/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lifepillar/vim-ledger/merges","archive_url":"https://api.github.com/repos/lifepillar/vim-ledger/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lifepillar/vim-ledger/downloads","issues_url":"https://api.github.com/repos/lifepillar/vim-ledger/issues{/number}","pulls_url":"https://api.github.com/repos/lifepillar/vim-ledger/pulls{/number}","milestones_url":"https://api.github.com/repos/lifepillar/vim-ledger/milestones{/number}","notifications_url":"https://api.github.com/repos/lifepillar/vim-ledger/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lifepillar/vim-ledger/labels{/name}","releases_url":"https://api.github.com/repos/lifepillar/vim-ledger/releases{/id}","created_at":"2015-10-11T19:21:56Z","updated_at":"2015-10-11T19:21:56Z","pushed_at":"2015-10-18T21:16:07Z","git_url":"git://github.com/lifepillar/vim-ledger.git","ssh_url":"git@github.com:lifepillar/vim-ledger.git","clone_url":"https://github.com/lifepillar/vim-ledger.git","svn_url":"https://github.com/lifepillar/vim-ledger","homepage":null,"size":163,"stargazers_count":0,"watchers_count":0,"language":"VimL","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ledger:master","ref":"master","sha":"97fa935d8f644c69506ad69cc3db84d9ac328f30","user":{"login":"ledger","id":2710687,"avatar_url":"https://avatars.githubusercontent.com/u/2710687?v=3","gravatar_id":"","url":"https://api.github.com/users/ledger","html_url":"https://github.com/ledger","followers_url":"https://api.github.com/users/ledger/followers","following_url":"https://api.github.com/users/ledger/following{/other_user}","gists_url":"https://api.github.com/users/ledger/gists{/gist_id}","starred_url":"https://api.github.com/users/ledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ledger/subscriptions","organizations_url":"https://api.github.com/users/ledger/orgs","repos_url":"https://api.github.com/users/ledger/repos","events_url":"https://api.github.com/users/ledger/events{/privacy}","received_events_url":"https://api.github.com/users/ledger/received_events","type":"Organization","site_admin":false},"repo":{"id":6658755,"name":"vim-ledger","full_name":"ledger/vim-ledger","owner":{"login":"ledger","id":2710687,"avatar_url":"https://avatars.githubusercontent.com/u/2710687?v=3","gravatar_id":"","url":"https://api.github.com/users/ledger","html_url":"https://github.com/ledger","followers_url":"https://api.github.com/users/ledger/followers","following_url":"https://api.github.com/users/ledger/following{/other_user}","gists_url":"https://api.github.com/users/ledger/gists{/gist_id}","starred_url":"https://api.github.com/users/ledger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ledger/subscriptions","organizations_url":"https://api.github.com/users/ledger/orgs","repos_url":"https://api.github.com/users/ledger/repos","events_url":"https://api.github.com/users/ledger/events{/privacy}","received_events_url":"https://api.github.com/users/ledger/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ledger/vim-ledger","description":"Vim plugin for Ledger","fork":false,"url":"https://api.github.com/repos/ledger/vim-ledger","forks_url":"https://api.github.com/repos/ledger/vim-ledger/forks","keys_url":"https://api.github.com/repos/ledger/vim-ledger/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ledger/vim-ledger/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ledger/vim-ledger/teams","hooks_url":"https://api.github.com/repos/ledger/vim-ledger/hooks","issue_events_url":"https://api.github.com/repos/ledger/vim-ledger/issues/events{/number}","events_url":"https://api.github.com/repos/ledger/vim-ledger/events","assignees_url":"https://api.github.com/repos/ledger/vim-ledger/assignees{/user}","branches_url":"https://api.github.com/repos/ledger/vim-ledger/branches{/branch}","tags_url":"https://api.github.com/repos/ledger/vim-ledger/tags","blobs_url":"https://api.github.com/repos/ledger/vim-ledger/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ledger/vim-ledger/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ledger/vim-ledger/git/refs{/sha}","trees_url":"https://api.github.com/repos/ledger/vim-ledger/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ledger/vim-ledger/statuses/{sha}","languages_url":"https://api.github.com/repos/ledger/vim-ledger/languages","stargazers_url":"https://api.github.com/repos/ledger/vim-ledger/stargazers","contributors_url":"https://api.github.com/repos/ledger/vim-ledger/contributors","subscribers_url":"https://api.github.com/repos/ledger/vim-ledger/subscribers","subscription_url":"https://api.github.com/repos/ledger/vim-ledger/subscription","commits_url":"https://api.github.com/repos/ledger/vim-ledger/commits{/sha}","git_commits_url":"https://api.github.com/repos/ledger/vim-ledger/git/commits{/sha}","comments_url":"https://api.github.com/repos/ledger/vim-ledger/comments{/number}","issue_comment_url":"https://api.github.com/repos/ledger/vim-ledger/issues/comments{/number}","contents_url":"https://api.github.com/repos/ledger/vim-ledger/contents/{+path}","compare_url":"https://api.github.com/repos/ledger/vim-ledger/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ledger/vim-ledger/merges","archive_url":"https://api.github.com/repos/ledger/vim-ledger/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ledger/vim-ledger/downloads","issues_url":"https://api.github.com/repos/ledger/vim-ledger/issues{/number}","pulls_url":"https://api.github.com/repos/ledger/vim-ledger/pulls{/number}","milestones_url":"https://api.github.com/repos/ledger/vim-ledger/milestones{/number}","notifications_url":"https://api.github.com/repos/ledger/vim-ledger/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ledger/vim-ledger/labels{/name}","releases_url":"https://api.github.com/repos/ledger/vim-ledger/releases{/id}","created_at":"2012-11-12T19:01:20Z","updated_at":"2015-09-28T06:55:54Z","pushed_at":"2015-10-19T20:14:02Z","git_url":"git://github.com/ledger/vim-ledger.git","ssh_url":"git@github.com:ledger/vim-ledger.git","clone_url":"https://github.com/ledger/vim-ledger.git","svn_url":"https://github.com/ledger/vim-ledger","homepage":null,"size":367,"stargazers_count":63,"watchers_count":63,"language":"VimL","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":11,"forks":17,"open_issues":11,"watchers":63,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ledger/vim-ledger/pulls/28"},"html":{"href":"https://github.com/ledger/vim-ledger/pull/28"},"issue":{"href":"https://api.github.com/repos/ledger/vim-ledger/issues/28"},"comments":{"href":"https://api.github.com/repos/ledger/vim-ledger/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/ledger/vim-ledger/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/ledger/vim-ledger/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ledger/vim-ledger/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/ledger/vim-ledger/statuses/614e84dd41a1dd5c197d852436360c82ca19612e"}}}}