aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-06-14 12:39:47 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-06-14 12:39:47 +1200
commit3f78aa7247cdcd1d4815f82ff01bcba87f37b6b6 (patch)
tree6b24c4c9ccb22ef1364690a65e723cf2b561dc8d
parente65d1e0790768fdf265650f5b12880805ce601f1 (diff)
parent15b8a1c7ef155dfd081c286e79379bacecd5cb0d (diff)
downloaddotfiles-3f78aa7247cdcd1d4815f82ff01bcba87f37b6b6.tar.gz
Merge branch 'release/v0.53.0'v0.53.0
* release/v0.53.0: Bump VERSION Correct comment on 'shm' i Remove redundant NR==1 in awk(1) call Refactor tilde and extension stripping
-rw-r--r--VERSION4
-rw-r--r--sh/profile.d/editor.sh2
-rw-r--r--vim/filetype.vim80
-rw-r--r--vim/vimrc2
4 files changed, 48 insertions, 40 deletions
diff --git a/VERSION b/VERSION
index 195b26e6..849846ff 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v0.52.0
-Tue Jun 12 22:59:10 UTC 2018
+tejr dotfiles v0.53.0
+Thu Jun 14 00:39:32 UTC 2018
diff --git a/sh/profile.d/editor.sh b/sh/profile.d/editor.sh
index d8d13e0a..6e202e26 100644
--- a/sh/profile.d/editor.sh
+++ b/sh/profile.d/editor.sh
@@ -9,7 +9,7 @@ if command -v ed >/dev/null 2>&1 ; then
elif (
command -v ex >/dev/null 2>&1 || exit 1
command -v exm >/dev/null 2>&1 || exit 1
- ver=$(ex --version 2>/dev/null | awk 'NR==1{print $1;exit}')
+ ver=$(ex --version 2>/dev/null | awk '{print $1;exit}')
case $ver in
(VIM) exit 0 ;;
(*) exit 1 ;;
diff --git a/vim/filetype.vim b/vim/filetype.vim
index 09f9fcb6..2dc44889 100644
--- a/vim/filetype.vim
+++ b/vim/filetype.vim
@@ -7,40 +7,51 @@ if !has('autocmd') || &compatible
finish
endif
-" Use our own filetype detection rules
-augroup filetypedetect
- autocmd!
+" Run the 'filetypedetect' group on a file with its extension stripped off
+function! s:StripRepeat()
+
+ " Check we have the fnameescape() function
+ if !exists('*fnameescape')
+ return
+ endif
- " Check whether fnameescape() exists to do some basic surgery on the
- " filename being matched
- if exists('*fnameescape')
+ " Expand the match result
+ let l:fn = expand('<afile>')
- " Chop tildes
- autocmd BufNewFile,BufRead
- \ ?*~
- \ execute 'doautocmd filetypedetect BufRead '
- \ . fnameescape(substitute(expand('<afile>'), '\~$', '', ''))
+ " Strip leading and trailing #hashes#
+ if l:fn =~# '\m^#\+.*#\+$'
+ let l:fn = substitute(l:fn, '\m^#\+\(.\+\)#\+$', '\1', '')
- " Chop some generic extensions
- autocmd BufNewFile,BufRead
- \ ?*.bak
- \,?*.in
- \,?*.new
- \,?*.old
- \,?*.orig
- \ execute 'doautocmd filetypedetect BufRead '
- \ . fnameescape(expand('<afile>:r'))
+ " Strip trailing tilde~
+ elseif l:fn =~# '\m\~$'
+ let l:fn = substitute(l:fn, '\~$', '', '')
- " Chop some Debian working extensions
- autocmd BufNewFile,BufRead
- \ ?*.dpkg-bak
- \,?*.dpkg-dist
- \,?*.dpkg-new
- \,?*.dpkg-old
- \ execute 'doautocmd filetypedetect BufRead '
- \ . fnameescape(expand('<afile>:r'))
+ " Strip generic .extension
+ else
+ let l:fn = expand('<afile>:r')
endif
+ " Re-run the group if there's anything left
+ if strlen(l:fn)
+ execute 'doautocmd filetypedetect BufRead ' . fnameescape(l:fn)
+ endif
+
+endfunction
+
+" Use our own filetype detection rules
+augroup filetypedetect
+ autocmd!
+
+ " Unwrap hashes, tildes, generic extensions, and Debian packaging working
+ " extensions (if we can do so safely), and repeat the filetype detection to
+ " see if there's a match beneath them
+ autocmd BufNewFile,BufRead
+ \ #?*#
+ \,?*~
+ \,?*.{bak,example,in,new,old,orig,sample,test}
+ \,?*.dpkg-{bak,dist,new,old}
+ \ call s:StripRepeat()
+
" Stuff Tom cares about enough and edits often enough to type based on
" filename patterns follows.
@@ -458,14 +469,11 @@ augroup filetypedetect
" Clumsy attempt at typing files in `sudo -e` if a filename hasn't already
" been found; strip temporary extension and re-run
- if exists('*fnameescape')
- autocmd BufNewFile,BufRead
- \ /var/tmp/?*.????????
- \ if !did_filetype()
- \ | execute 'doautocmd filetypedetect BufRead '
- \ . fnameescape(expand('<afile>:r'))
- \ | endif
- endif
+ autocmd BufNewFile,BufRead
+ \ /var/tmp/?*.????????
+ \ if !did_filetype()
+ \ | call s:StripRepeat()
+ \ | endif
" If we *still* don't have a filetype, run the scripts.vim file that will
" examine actual file contents--but only the first one; don't load the
diff --git a/vim/vimrc b/vim/vimrc
index 185df60d..c268582c 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -132,7 +132,7 @@ endif
" Set up short message settings
set shortmess=
set shortmess+=f " (file 3 of 5) -> (3 of 5)
-set shortmess+=i " [Incomplete last line] -> [eol]
+set shortmess+=i " [Incomplete last line] -> [noeol]
set shortmess+=I " I donated to Uganda, thanks Bram
set shortmess+=l " 999 lines, 888 characters -> 999L, 888C
set shortmess+=m " [Modified] -> [+]