From bc7d1987d389d3a7870e620ecba25970fac437e2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 13 Jun 2019 14:13:06 +1200 Subject: Add version number tag reference links to vimrc --- vim/vimrc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 629ab631..5bb0602d 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -135,6 +135,8 @@ endif " It should rename the buffer as "foo bar aaz"; note the change in the first " letter of the last word of the filename. " +" +" if $MYVIM =~# '\\' \ && (v:version < 701 || v:version == 701 && !has('patch55')) echoerr 'Illegal backslash in user runtime path on Vim < v7.1.055' @@ -209,6 +211,8 @@ augroup vimrc " invocations of :source of either vimrc file, and translate that into " reloading the stub vimrc. " + " + " if exists('##SourceCmd') autocmd SourceCmd $MYVIMRC,$MYVIM/vimrc \ ReloadVimrc @@ -235,6 +239,8 @@ augroup END " with restrictive permissions, too. Who knows what secrets are in your file " buffers? " +" +" function! s:Establish(path) abort let path = expand(a:path) if !isdirectory(path) && exists('*mkdir') @@ -274,6 +280,8 @@ Establish $MYVIM " Vim v8.1.716 introduced a nicer way to set this with an option named " 'viminfofile', which is too new for us to use just yet. " +" +" Establish $MYVIM/cache set viminfo+=n$MYVIM/cache/viminfo @@ -314,6 +322,8 @@ set backup " value in older versions of Vim where they don't do anything, so we'll check " the version ourselves to see if there's any point in including them. " +" +" " It's all so awkward. Surely separate options named something like " 'backupfullname', 'swapfilefullname' would have been clearer. " @@ -482,6 +492,8 @@ set shiftwidth=4 " Indent command like < and > use four-space indents " Vim is new enough to support it (v7.3.693), apply a negative value to do " this dynamically if 'shiftwidth' changes. " +" +" if v:version > 730 || v:version == 730 && has('patch693') set softtabstop=-1 else @@ -532,6 +544,8 @@ endif " The 'breakindent' option wasn't added until v7.4.338, so we need to check it " exists before we set it. " +" +" if exists('+breakindent') set breakindent endif @@ -606,6 +620,8 @@ set formatoptions+=1 " suppress errors for this sort of thing when I can reasonably avoid it, even " if the tests are somewhat more verbose. " +" +" if v:version > 730 || v:version == 730 && has('patch541') set formatoptions+=j endif @@ -644,7 +660,7 @@ set cpoptions+=J " does. I wrote the patch that added it, after becoming envious of an " analogous feature during an ill-fated foray into GNU Emacs usage. " -" +" " if has('patch-8.1.728') set formatoptions+=p @@ -911,6 +927,8 @@ set wildignore=*~,#*#,*.7z,.DS_Store,.git,.hg,.svn,*.a,*.adf,*.asc,*.au,*.aup " The option wasn't added until v7.3.72, so we need to check it exists before " we try to set it. " +" +" if exists('+wildignorecase') set wildignorecase endif -- cgit v1.2.3 From 7811f4e088e4beeae8d9aac6063e00b3df77cdd0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 13 Jun 2019 14:13:32 +1200 Subject: Spruce up and comment on ext-counting shell --- vim/vimrc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 5bb0602d..4dca01c5 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -888,19 +888,27 @@ set wildmode=list:longest,full " giving patterns for the top 100 alphanumeric extensions for files from the " running user's home directory: " -" $ find "$HOME" ! -type d -name '*.?*' -exec \ +" $ (LC_ALL=C find "$HOME" ! -type d -name '*.?*' -exec \ " sh -c 'for fn ; do " ext=${fn##*.} " case $ext in -" *[![:alnum:]]*) continue ;; -" ?*) printf "%s\n" "$ext" ;; +" (*[![:alnum:]]*) continue ;; +" (?*) printf "%s\n" "$ext" ;; " esac " done' _ {} + | -" tr '[:upper:]' '[:lower:]' | sort | uniq -c | -" sort -k1,1nr | awk 'NR <= 100 {print "*." $2}' +" tr '[[:upper:]]' '[[:lower:]]' | sort | uniq -c | +" sort -k1,1nr | awk 'NR <= 100 {print "*." $2}') " " I turned out to have rather a lot of .html and .vim files. " +" If you're scoffing at that and thinking "I could write a much simpler one", +" please do so, and send it to me at to have yours put +" in here instead, with appropriate credit. Don't forget to handle more than +" ARG_MAX files, include filenames with newlines, and that the -z or -0 null +" separator extensions are not standardised in POSIX. +" +" +" " It's tempting to put the list of patterns here into a separate file--or at " least into a more readily editable intermediate list variable--rather than " the minor maintenance hassle it presently constitutes in this compact form. -- cgit v1.2.3 From 8111865db690475a81e6596fc262090d42fd1ebc Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 13 Jun 2019 14:13:45 +1200 Subject: More comment cleanup for vimrc --- vim/vimrc | 116 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 4dca01c5..57a92a11 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -18,8 +18,8 @@ " This file should be saved as "vimrc" in the user runtime directory. On " Unix-like operating systems, this is ~/.vim; on Windows, it's ~/vimfiles. " It requires Vim 7.0 or newer with +eval, with 'nocompatible'. The vimrc -" stub at ~/.vimrc on Unix or ~/_vimrc on Windows checks that these conditions -" are met before loading this file. +" stub at ~/.vimrc on Unix or ~/_vimrc on Windows should checks that these +" conditions are met before loading this file with `:runtime vimrc`. " " > And I was lifted up in heart, and thought " > Of all my late-shown prowess in the lists, @@ -88,8 +88,8 @@ scriptencoding utf-8 " source code and test it with some values of your own if you want to " understand why. " -" For the edge case of a blank &runtimepath, MYVIM will here be set to the -" empty string, due to the way that split() works by default without its third +" For the edge case of a blank 'runtimepath', MYVIM will be set to the empty +" string, due to the way that split() works by default without its third " parameter {keepempty} set to false. " " Vim, I love you, but you are really weird. @@ -100,9 +100,9 @@ endif " Having either imported or defined a value for the MYVIM environment " variable, we now need to ensure it's not going to cause problems for the -" rest of this file. If any of those conditions are met, throw an explanatory -" error and stop reading this file. Most of the file doesn't depend on MYVIM, -" but there's no point catering to these edge cases. +" rest of this file. If any of those conditions are met, we'll throw an +" explanatory error and stop reading this file. Most of the file doesn't +" depend on MYVIM, but there's not much point accommodating these edge cases. " " Firstly, MYVIM can't be an empty string. We need a real path. @@ -114,19 +114,20 @@ endif " Secondly, if MYVIM's value contains a comma, its use in comma-separated " option values will confuse Vim into thinking more than one directory is -" being specified, per normal :set semantics. It's possible to work around -" this with some careful escaping or :execute abstraction, but it's not really -" worth the extra complexity for such a niche situation. +" being specified, splitting our value into parts. This is normal :set +" behaviour. It's possible to work around this with some careful escaping or +" :execute abstraction, but it's not really worth the extra complexity for +" such a niche situation. " if $MYVIM =~# ',' echoerr 'Illegal comma in user runtime path' finish endif -" Thirdly, Vim v7 prior to v7.1.055 had a nasty bug with escaping with the -" backslash character on the command line, and so on these older versions of -" Vim, we'll need to forbid that character in the value of MYVIM in order to -" be confident that we're stashing files in the correct path. +" Thirdly, Vim v7 prior to v7.1.055 had a nasty bug with escaping with +" multiple backslash characters on the command line, and so on these older +" versions of Vim, we'll need to forbid that character in the value of MYVIM +" in order to be confident that we're stashing files in the correct path. " " To reproduce this bug on these older versions, try this command: " @@ -227,32 +228,27 @@ augroup END " " We also need to check whether the directory already exists, even if we " specify the special 'p' value for its optional {path} argument. This is -" because the meaning of mkdir(..., 'p') is not the same as `mkdir -p` in -" shell script, or at least, it isn't in versions of Vim before v8.0.1708. -" These versions throw errors if the directory already exists, even with 'p', -" contrary to what someone familiar with `mkdir -p`'s behaviour in shell -" script might expect. -" -" So, let's wrap all that in a script-local function, and then hide it behind -" a user command, to keep the commands required to establishing a path is in -" place nice and simple. We'll lock down all the directories that we create -" with restrictive permissions, too. Who knows what secrets are in your file -" buffers? +" because until v8.0.1708, mkdir() raises an error if the directory to be +" created already exists, even with a {path} of 'p', where the analogous +" `mkdir` shell command does not do so with its -p option included. " " " +" So, let's wrap that logic in a script-local function s:Establish(), and then +" hide it behind a user command :Establish. We'll lock down all the +" directories that we create with restrictive permissions, too. Who knows +" what secrets are in your file buffers? + +" We set the command's tab completion to provide directory names as +" candidates, and specify that there must be only one argument, which we'll +" provide as a quoted parameter to the function. +" function! s:Establish(path) abort let path = expand(a:path) if !isdirectory(path) && exists('*mkdir') call mkdir(path, 'p', 0700) endif endfunction - -" Now we define the :Establish command for user-level access to the -" s:Establish() function. We set the tab completion to provide directory -" names as candidates, and specify that there must be only one argument, which -" we'll provide as a quoted parameter to the function. -" command! -bar -complete=dir -nargs=1 Establish \ call s:Establish() @@ -264,16 +260,16 @@ command! -bar -complete=dir -nargs=1 Establish " Establish $MYVIM -" Our next application of the :Establish command is to configure the path for -" the viminfo metadata file, putting it in a cache subdirectory of the user -" runtime directory. +" Our next application of our new :Establish command is to configure the path +" for the viminfo metadata file, putting it in a cache subdirectory of the +" user runtime directory set in MYVIM. " " Using this non-default location for viminfo has the nice benefit of " preventing command and search history from getting clobbered when something " runs Vim without using this vimrc, because such an instance will safely " write its history to the default viminfo path instead. It also contributes -" to our aim of having everything related to the Vim runtime process somewhere -" within the MYVIM directory. +" to our aim of having everything related to the Vim runtime process in one +" dedicated directory tree. " " The normal method of specifying the path to the viminfo file, as applied " here, is an addendum of the path to the 'viminfo' option with an "n" prefix. @@ -285,15 +281,15 @@ Establish $MYVIM Establish $MYVIM/cache set viminfo+=n$MYVIM/cache/viminfo -" Speaking of recorded data in viminfo files, the command and search history -" count default limit of 50 is pretty restrictive. Because I don't think I'm -" ever likely to be in a situation where remembering several thousand Vim -" commands and search patterns is going to severely tax memory, let alone disk -" space, I'd rather this limit were much higher; it's sometimes really handy -" to dig up commands from many days ago. +" Speaking of recorded data in viminfo files, the default Vim limit of a mere +" 50 entries for command and search history is pretty mean. Because I don't +" think I'm ever likely to be in a situation where remembering several +" thousand Vim commands and search patterns is going to severely tax memory, +" let alone disk space, I'd rather this limit were much higher. It's +" sometimes really handy to dig up commands from many days ago. " -" The maximum value for the 'history' option is documented in :help as 10000, -" so let's just use that, and see if anything breaks. +" The maximum value for the 'history' option is documented in `:help +" 'history'` as 10000, so let's just use that, and see if anything breaks. " set history=10000 @@ -308,9 +304,9 @@ set backup " directory, to stop them popping up next to the file to which they " correspond, and getting committed to version control. " -" If Vim is new enough (v8.1.251), we'll add two trailing slashes to the path -" we're inserting, which prompts Vim to incorporate the full escaped path of -" the relevant buffer in the backup filename, avoiding collisions. +" If Vim is new enough, we'll add two trailing slashes to the path we're +" inserting, which prompts Vim to incorporate the full escaped path of the +" relevant buffer in the backup filename, avoiding collisions. " " As a historical note, other similar directory path list options supported " this trailing slashes hint for a long time before 'backupdir' caught up to @@ -318,7 +314,7 @@ set backup " far back as v5.8.0 (2001), and 'undodir' appears to have supported it since " its creation in v7.2.438. Even though the :help for 'backupdir' didn't say " so, people assumed it would work the same way, when in fact Vim simply -" ignored it until v8.1.251. I don't want to add the slashes to the option +" ignored it until v8.1.0251. I don't want to add the slashes to the option " value in older versions of Vim where they don't do anything, so we'll check " the version ourselves to see if there's any point in including them. " @@ -376,8 +372,8 @@ set directory^=$MYVIM/cache/swap// " directory, so that the u/:undo and CTRL-R/:redo commands will work between " Vim invocations. " -" Support for persistent undo file caches was not added until v7.2.438, so we -" need to check for the feature's presence before we enable it. +" Support for these persistent undo file caches was not released until v7.3.0, +" so we need to check for the feature's presence before we enable it. " if has('persistent_undo') @@ -419,7 +415,7 @@ endif " `install-vim-thesaurus`. " " I got the thesaurus itself from the link in the :help for 'thesaurus' in -" v8.1.1487. It's from WordNet and MyThes-1. I maintain a mirror on my own +" v8.1. It's from WordNet and MyThes-1. I maintain a mirror on my own " website that the Makefile recipe attempts to retrieve. I had to remove the " first two metadata lines from thesaurus.txt, as Vim appeared to interpret " them as part of the body data. @@ -516,13 +512,16 @@ set backspace+=start " Text before the start of the current insertion set linebreak " Similarly, show that the screen line is a trailing part of a wrapped line by -" prefixing it with an ellipsis. If we have a multi-byte encoding, use U+2026 -" HORIZONTAL ELLIPSIS to save a couple of columns, but otherwise three periods -" will do just fine. +" prefixing it with an ellipsis. If we have a multi-byte encoding, use +" a proper ellipsis character to save a couple of columns, but otherwise three +" periods will do just fine. +" +" … U+2026 HORIZONTAL ELLIPSIS " " Note that we test for the presence of a multi-byte encoding with a special -" feature from `:help feature-list`, as recommended by `:help encoding`; -" checking that `&encoding ==# 'utf-8'` is not quite the same thing. +" feature from `:help feature-list`, as recommended by `:help encoding`. +" Checking that `&encoding ==# 'utf-8'` is not quite the same thing, though +" it's unlikely I'll ever use a different Unicode encoding by choice. " if has('multi_byte_encoding') set showbreak=… @@ -551,9 +550,8 @@ if exists('+breakindent') endif " Rather than rejecting operations like :write or :saveas when 'readonly' is -" set, and other situations in which data might be lost or I'm acting against -" an option, Vim should give me a prompt to allow me to confirm that I know -" what I'm doing. +" set or in other situations in which data might be lost, Vim should give me +" a prompt to allow me to confirm that I know what I'm doing. " set confirm -- cgit v1.2.3 From 025eabd9fcbb64f9633b46eefeb75fcfb816c163 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 13 Jun 2019 14:13:50 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 9735aa91..9d8ecbdc 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v5.44.0 -Wed Jun 12 23:54:33 UTC 2019 +tejr dotfiles v5.45.0 +Thu Jun 13 02:13:50 UTC 2019 -- cgit v1.2.3