diff options
-rw-r--r-- | vim/autoload/argument.vim | 4 | ||||
-rw-r--r-- | vim/autoload/html/timestamp.vim | 4 | ||||
-rw-r--r-- | vim/autoload/mail/header.vim | 5 | ||||
-rw-r--r-- | vim/autoload/mail/header/field.vim | 6 | ||||
-rw-r--r-- | vim/autoload/mail/importance.vim | 2 | ||||
-rw-r--r-- | vim/autoload/option.vim | 3 | ||||
-rw-r--r-- | vim/autoload/option/item.vim | 3 | ||||
-rw-r--r-- | vim/autoload/path.vim | 2 | ||||
-rw-r--r-- | vim/autoload/put_date.vim | 5 |
9 files changed, 30 insertions, 4 deletions
diff --git a/vim/autoload/argument.vim b/vim/autoload/argument.vim index 9e381000..85d75eb1 100644 --- a/vim/autoload/argument.vim +++ b/vim/autoload/argument.vim @@ -1,6 +1,8 @@ +" Escape a single argument for use on an Ex command line; essentially +" a backport of fnameescape() for versions before v7.1.299 +" function! argument#Escape(argument) abort return exists('*fnameescape') \ ? fnameescape(a:argument) \ : escape(a:argument, "\n\r\t".' *?[{`$\%#''"|!<') endfunction - diff --git a/vim/autoload/html/timestamp.vim b/vim/autoload/html/timestamp.vim index af74d815..ad79ad23 100644 --- a/vim/autoload/html/timestamp.vim +++ b/vim/autoload/html/timestamp.vim @@ -1,5 +1,3 @@ -scriptencoding utf-8 - " Keys and date formats for return value of s:Timestamp() let s:formats = { \ 'human': '%a, %d %b %Y %T %Z', @@ -38,7 +36,7 @@ endfunction " Define timestamp prefix string let s:prefix = 'Last updated: ' -" Define pattern to match date timestamps; no Z̷͖̟̩͕̊̇̈ͬ̆̄Á̩̺͙̫͇͔̓͛ͭ̓̈́L̟͘G̤̣̳̊̌O̻̝̣̠͇̥̠͗ͤ͐͘ please +" Define pattern to match date timestamps; no ZALGO, please let s:pattern = '\m\C' \.s:prefix \.'<time datetime="[^"]\+">' diff --git a/vim/autoload/mail/header.vim b/vim/autoload/mail/header.vim index 8495a721..7a360a2c 100644 --- a/vim/autoload/mail/header.vim +++ b/vim/autoload/mail/header.vim @@ -1,3 +1,6 @@ +" Parse a mail header into a list of dictionaries with 'name' and 'body' keys; +" preserve case of the name and whitespace in body, including leading space +" function! mail#header#Read() abort let fields = [] for lnum in range(1, line('$')) @@ -26,6 +29,7 @@ function! mail#header#Read() abort return header endfunction +" Flatten a header data structure into a string function! mail#header#String(header) abort let fields = copy(a:header['fields']) return join( @@ -36,6 +40,7 @@ function! mail#header#String(header) abort \) endfunction +" Replace existing mail header with the provided one function! mail#header#Write(header) abort let start = 1 for lnum in range(1, line('$')) diff --git a/vim/autoload/mail/header/field.vim b/vim/autoload/mail/header/field.vim index ab3d405a..e27d13c0 100644 --- a/vim/autoload/mail/header/field.vim +++ b/vim/autoload/mail/header/field.vim @@ -1,3 +1,5 @@ +" Add a field to a header, regardless of whether a field by the same name is +" already present function! mail#header#field#Add(header, name, body) abort let new = { \ 'name': a:name, @@ -6,6 +8,9 @@ function! mail#header#field#Add(header, name, body) abort call add(a:header['fields'], new) endfunction +" Set a field in a header, replacing the first one with the same name (if +" any), and and removing any others +" function! mail#header#field#Set(header, name, body) abort let fields = [] let new = { @@ -28,6 +33,7 @@ function! mail#header#field#Set(header, name, body) abort let a:header['fields'] = fields endfunction +" Remove a header field function! mail#header#field#Clear(header, name) abort let fields = [] for field in a:header['fields'] diff --git a/vim/autoload/mail/importance.vim b/vim/autoload/mail/importance.vim index 6a5ed096..78fb53ac 100644 --- a/vim/autoload/mail/importance.vim +++ b/vim/autoload/mail/importance.vim @@ -1,3 +1,4 @@ +" Define header fields for high, low, and normal priorities let s:fields = { \ 'high': { \ 'Importance': 'High', @@ -10,6 +11,7 @@ let s:fields = { \ 'normal': {}, \} +" Set the priority headers; pass in "high", "low", or "normal" function! mail#importance#Set(level) abort let header = mail#header#Read() let fields = s:fields[a:level] diff --git a/vim/autoload/option.vim b/vim/autoload/option.vim index a71503e1..5ff44ced 100644 --- a/vim/autoload/option.vim +++ b/vim/autoload/option.vim @@ -1,3 +1,6 @@ +" Split a comma-separated option value into parts, accounting for escaped +" commas and leading whitespace as Vim itself does internally +" function! option#Split(expr, ...) abort if a:0 > 1 echoerr 'Too many arguments' diff --git a/vim/autoload/option/item.vim b/vim/autoload/option/item.vim index b3e9f0a7..ee92101f 100644 --- a/vim/autoload/option/item.vim +++ b/vim/autoload/option/item.vim @@ -1,3 +1,6 @@ +" Escape a single item for a comma-separated list, optionally escaping any +" filename wildcards +" function! option#item#Escape(item, ...) abort if a:0 > 1 echoerr 'Too many arguments' diff --git a/vim/autoload/path.vim b/vim/autoload/path.vim index 83102138..e230cab2 100644 --- a/vim/autoload/path.vim +++ b/vim/autoload/path.vim @@ -1,3 +1,5 @@ +" Create all the directories needed for a path, with optional flag for +" owner-only permissions function! path#Create(name, ...) abort if a:0 > 2 echoerr 'Too many arguments' diff --git a/vim/autoload/put_date.vim b/vim/autoload/put_date.vim index c9f52c12..b0b0b548 100644 --- a/vim/autoload/put_date.vim +++ b/vim/autoload/put_date.vim @@ -1,5 +1,10 @@ +" RFC2822 format string for strftime() let s:rfc_2822 = '%a, %d %b %Y %T %z' +" Write a date to the buffer, UTC or local, in the specified format, +" defaulting to RFC2822; formats are provided without the leading % signs +" before each letter, like PHP date() +" function! put_date#(line, utc, format) abort let line = a:line let utc = a:utc |