aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/mail/header/field.vim
blob: ab3d405adb64134998f9bdc1406335561ae8fc40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function! mail#header#field#Add(header, name, body) abort
  let new = {
        \ 'name': a:name,
        \ 'body': a:body,
        \}
  call add(a:header['fields'], new)
endfunction

function! mail#header#field#Set(header, name, body) abort
  let fields = []
  let new = {
        \ 'name': a:name,
        \ 'body': a:body,
        \}
  for field in a:header['fields']
    if field['name'] ==? a:name
      if exists('new')
        let field = new | unlet new
      else
        continue
      endif
    endif
    call add(fields, field)
  endfor
  if exists('new')
    call add(fields, new) | unlet new
  endif
  let a:header['fields'] = fields
endfunction

function! mail#header#field#Clear(header, name) abort
  let fields = []
  for field in a:header['fields']
    if field['name'] !=? a:name
      call add(fields, field)
    endif
  endfor
  let a:header['fields'] = fields
endfunction