Greg Hurrell [Fri, 12 Jun 2020 15:37:33 +0000 (17:37 +0200)]
Merge branch 'pull/11'
Closes: https://github.com/wincent/scalpel/pull/11
* pull/11:
doc: update AUTHORS and HISTORY sections
refactor: replace hard-coded "$" with "very magic" list
Escape '$' when launching Scalpel
Greg Hurrell [Fri, 12 Jun 2020 15:22:06 +0000 (17:22 +0200)]
refactor: replace hard-coded "$" with "very magic" list
As the PR duly notes, it's hard to imagine an obvious use case where
some "special" character other than "$" is part of a Vim "word", but if
we're going to do this, we might as well work for all possible
definitions of `'iskeyword'`.
I was originally thinking we should do this based on what is in
`'iskeyword'`, but we can just do a blanket rule and escape literally
everything that might have "very magic" significance. Note that in
preparing the list of characters to be escaped, we have to double escape
the following to produce a valid `:execute` string:
- '"' because the list itself is double-quoted.
- '\' because it is in the list and we need to preserve it.
- '|' because otherwise it will terminate the command.
Test plan:
Set a bizarre `'iskeyword'` like:
:set iskeyword=@,34,39,41,47-57,92,_,124,192-255
ie. in additional to the typical 48-57,192-255 range, also add:
34 = "
39 = '
41 = )
47 = /
92 = \
124 = |
and then hit the mapping with the cursor over a "word" like this one:
'"/\|')
(That example chosen simply because it appears in the source.)
Greg Hurrell [Thu, 3 Jan 2019 01:14:46 +0000 (02:14 +0100)]
Take into account 'gdefault' setting
If the user has 'gdefault' set (not the default), then the "g" flag
actually turns *off* global replacement instead of turning it on. So,
check for 'gdefault' in order to decide whether or not to pass the "g"
(we always want to do global replacements).
Looks like the tokenizer in older Vim such as 7.4.629 barfs on list
sublist syntax involving variables with the `l:` qualifier. Provide it
some parens to help it avoid getting confused.
Fix problem with replacement sequences containing the number "1"
`\1` in a `[]` collection was equivalent to literal "1" instead of the
intended back-reference to the delimiter. This meant that `[^\1]` was
equivalent to `[^1]`, and when embedded in the larger expression meant
that a pattern like `/a2/a1/` was failing to match.
Greg Hurrell [Wed, 12 Oct 2016 01:07:19 +0000 (18:07 -0700)]
Add empty .watchmanconfig
Allows a Watchman instance configured with `enforce_root_files` to watch
this directory even if `root_files` does not contain any of the files in
the directory. (Necessary to get around undesired corporate
`/etc/watchman.json` config.)
Greg Hurrell [Thu, 26 May 2016 15:20:48 +0000 (08:20 -0700)]
Attempt fix for <cword> not being useful in VISUAL mode
Don't get too excited, as this doesn't actually work. I thought it would, but
`getcurpos` is always returning top/left in multi-line visual mode. Showing my
work here anyway. May have to revert it.
- VISUAL: works
- VISUAL BLOCK:
- works if block spans only single line
- returns top/left word otherwise
- VISUAL LINE: always returns top/left word, even when block spans only single
line
In short, I think this behaves exactly like `<cword>` and with exactly the same
limitations.
Greg Hurrell [Thu, 26 May 2016 14:08:30 +0000 (07:08 -0700)]
Work in VISUAL mode
This mostly works pretty well. One gotcha is that `<cword>` expands to the first
word of the selection in VISUAL mode, not the word under the cursor. I think
this is technically because VIM actually does move the cursor to the top before
calling any function.
There may be a workaround, but it will be pretty involved, so I will save it for
another commit (IFF I can get it working).
Carry "a" flag around when looping back to top of buffer
In an utterly bizarre VimL gotcha, the `&` last flags argument has to go away at
the end because otherwise Vim will use the flags from inside the `if l:last ==#
'a'` loop body, even if the body wasn't evaluated. This is presumably because it
really is evaluated (everything is "eval"), except without side-effects, other
than clobbering the last-flags state, that is.