<commit_before>let b:mto_open_tag = "<?php "
let b:mto_close_tag = "?>"

" Stolen from https://stackoverflow.com/a/1534347/1824895
function! s:get_visual_selection()
  normal! gv"zy
  return @z
endfunction

function! s:_one_arg(prompt, php_func_name, add_dollar=0)
  let z_old = @z

  " grab the thing, ask for new one
  let selected = s:get_visual_selection()
  let varname = input(a:prompt . " (" . selected . "): ")

  " probably, hit escape. don't blat the selection
  if varname ==# ''
    return
  endif

  let subbed = substitute(varname, " ", "_", "")

  " put it there
  let bits = [
    \ b:mto_open_tag, a:php_func_name, '(',
    \ (a:add_dollar ? '$' : ''), subbed,
    \ ')', b:mto_close_tag
  \ ]
  let @z = join(bits, '')
  normal! gv"zp

  let @z = z_old
  redraw
endfunction

function s:_citeone(php_func_name)
  call s:_one_arg('Variable name', a:php_func_name, 1)
endfunction

" I am ignoring, in the translation to vimscript, the two-arg functions,
" because mostly I have stopped using them.

function! s:cite()
  call s:_citeone('cite')
endfunction

function! s:cite_year()
  call s:_citeone('cite_year')
endfunction

function! s:sharp()
  call s:_one_arg('Note name', 'sharp')
endfunction

function! s:flat()
  call s:_one_arg('Note name', 'flat')
endfunction

function! s:natural()
  call s:_one_arg('Note name', 'natural')
endfunction

function! s:activate()
  let is_fn = input("Is this a footnotes file? [y/n] ") ==# "y"
  if is_fn
      let b:mto_open_tag = '".fn_'
      let b:mto_close_tag = '."'
  else
      let b:mto_open_tag = '<?php '
      let b:mto_close_tag = '?>'
  endif

  if exists('b:mto_activated') && b:mto_activated
    redraw
    return
  endif

  " load mappings
  xmap <buffer><nowait> <LocalLeader>c <Plug>MTOCite
  xmap <buffer> <LocalLeader>y <Plug>MTOCiteYear
  xmap <buffer> <LocalLeader>s <Plug>MTOSharp
  xmap <buffer> <LocalLeader>f <Plug>MTOFlat
  xmap <buffer> <LocalLeader>n <Plug>MTONatural

  " random shit
  nnoremap <buffer> j gj
  nnoremap <buffer> k gk
  nnoremap <buffer> 0 g0
  vmap ,i S<i>
  vmap ,b S<b>
  vmap ,s S<sub>

  hi link htmlSpecialChar Comment

  setl nolist
  setl linebreak
  setl textwidth=0<commit_msg>mto.vim: use colemak bindings<commit_after>let b:mto_open_tag = "<?php "
let b:mto_close_tag = "?>"

" Stolen from https://stackoverflow.com/a/1534347/1824895
function! s:get_visual_selection()
  normal! gv"zy
  return @z
endfunction

function! s:_one_arg(prompt, php_func_name, add_dollar=0)
  let z_old = @z

  " grab the thing, ask for new one
  let selected = s:get_visual_selection()
  let varname = input(a:prompt . " (" . selected . "): ")

  " probably, hit escape. don't blat the selection
  if varname ==# ''
    return
  endif

  let subbed = substitute(varname, " ", "_", "")

  " put it there
  let bits = [
    \ b:mto_open_tag, a:php_func_name, '(',
    \ (a:add_dollar ? '$' : ''), subbed,
    \ ')', b:mto_close_tag
  \ ]
  let @z = join(bits, '')
  normal! gv"zp

  let @z = z_old
  redraw
endfunction

function s:_citeone(php_func_name)
  call s:_one_arg('Variable name', a:php_func_name, 1)
endfunction

" I am ignoring, in the translation to vimscript, the two-arg functions,
" because mostly I have stopped using them.

function! s:cite()
  call s:_citeone('cite')
endfunction

function! s:cite_year()
  call s:_citeone('cite_year')
endfunction

function! s:sharp()
  call s:_one_arg('Note name', 'sharp')
endfunction

function! s:flat()
  call s:_one_arg('Note name', 'flat')
endfunction

function! s:natural()
  call s:_one_arg('Note name', 'natural')
endfunction

function! s:activate()
  let is_fn = input("Is this a footnotes file? [y/n] ") ==# "y"
  if is_fn
      let b:mto_open_tag = '".fn_'
      let b:mto_close_tag = '."'
  else
      let b:mto_open_tag = '<?php '
      let b:mto_close_tag = '?>'
  endif

  if exists('b:mto_activated') && b:mto_activated
    redraw
    return
  endif

  " load mappings
  xmap <buffer><nowait> <LocalLeader>c <Plug>MTOCite
  xmap <buffer> <LocalLeader>y <Plug>MTOCiteYear
  xmap <buffer> <LocalLeader>s <Plug>MTOSharp
  xmap <buffer> <LocalLeader>f <Plug>MTOFlat
  xmap <buffer> <LocalLeader>n <Plug>MTONatural

  " random shit
  noremap <buffer> n gj
  noremap <buffer> e gk
  noremap <buffer> 0 g0
  vmap ,i S<i>
  vmap ,b S<b>
  vmap ,s S<sub>

  hi link htmlSpecialChar Comment

  setl nolist
  setl linebreak
  setl textwidth=0
{'fraction_non_alphanumeric': 0.13533834586466165, 'fraction_numerical': 0.008658008658008658, 'mean_word_length': 3.883203559510567, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3651823', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1698, 'n_words': 428}