Error detected while processing /home/ming/.vim/bundle/vim-copycat/plugin/copycat.vim: line23: E319: Sorry, the commandis not available in this version: python << EOF line24: E492: Not an editor command: import sys line25: E492: Not an editor command: import vim line26: E492: Not an editor command: sys.path.append(vim.eval('expand("<sfile>:p:h:h")')) line27: E492: Not an editor command: import copycat_plugin line28: E492: Not an editor command: EOF
Error detected while processing /home/ming/.vim/bundle/vim-copycat/plugin/copycat.vim: line 28: Traceback (most recent call last): File"<string>", line 4, in <module> File"/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line 11, in <module> import copycat File"/usr/local/lib/python3.6/dist-packages/copycat.py", line 73 print 'noreg {}'.format(name) ^ SyntaxError: invalid syntax
Error detected while processing function <SNR>36_push_into_clip: line 4: Traceback (most recent call last): File"<string>", line 1, in <module> File"/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line 37, indeco result = func(*args, **kwargs) File"/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line 53, incopy copycat.copy(name=name, value=value) File"/usr/local/lib/python3.6/dist-packages/copycat.py", line 96, incopy value = smart_str(value) File"/usr/local/lib/python3.6/dist-packages/copycat.py", line 20, in smart_str if not isinstance(s, basestring): NameError: name 'basestring' is not defined
Error detected while processing function <SNR>36_push_into_clip: line 4: Traceback (most recent call last): File"<string>", line 1, in <module> File"/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line 37, indeco result = func(*args, **kwargs) File"/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line 53, incopy copycat.copy(name=name, value=value) File"/usr/local/lib/python3.6/dist-packages/copycat.py", line 100, incopy clipboard.copy(value) File"/usr/local/lib/python3.6/dist-packages/clipboard.py", line 31, incopy pipe.communicate(text) File"/usr/lib/python3.6/subprocess.py", line 828, in communicate self._stdin_write(input) File"/usr/lib/python3.6/subprocess.py", line 781, in _stdin_write self.stdin.write(input) TypeError: a bytes-like object is required, not 'str'
將 copycat.py 中的 copy 函數改成:
1 2 3 4 5 6 7 8
def copy(value=None, name=None): value = value or not sys.stdin.isatty() and sys.stdin.read()
#value = smart_str(value) with Storage() as storage: storage.save(value, name=name) if not name: clipboard.copy(value.encode('utf-8'))
copy 函數正常後,現在已經可以正常複製,接下來 paste 錯誤訊息:
1 2 3 4 5 6 7 8 9 10 11 12
Error detected while processing function<SNR>36_pop_from_clip: line3: Traceback (most recent calllast): File "<string>", line1, in <module> File "/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line39, in deco set_to_vim(result_reg, result) File "/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line25, in set_to_vim if not isinstance(name, basestring): NameError: name 'basestring'is not defined line4: E121: Undefined variable: l:result E15: Invalid expression: l:result
將 copycat.py 中的 paste 函數修改為:
1 2 3 4 5 6 7 8 9
def paste(name=None): with Storage() as storage: if not name: data = clipboard.paste() or storage.get() else: data = storage.get(name) #data = smart_str(data) clipboard.copy(data) return data
打開 copycat_plugin.py 將 set_to_vim 函數改成:
1 2 3 4 5 6 7 8 9 10
defset_to_vim(name, value): #if not isinstance(name, basestring): # return False
n == len(slice), f 有點類似 C++ STL std::find_if 的 Predicate。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
funcSearch(n int, f func(int)bool) int { // Define f(-1) == false and f(n) == true. // Invariant: f(i-1) == false, f(j) == true. i, j := 0, n for i < j { h := int(uint(i+j) >> 1) // avoid overflow when computing h // i ≤ h < j if !f(h) { i = h + 1// preserves f(i-1) == false } else { j = h // preserves f(j) == true } } // i == j, f(i-1) == false, and f(j) (= f(i)) == true => answer is i. return i }
1 2 3
funcSearchInts(a []int, x int)int { return Search(len(a), func(i int)bool { return a[i] >= x }) }
Hexo uses directly js-yaml (after some tabulator escaping).
var yaml = require(‘js-yaml’), escape = require(‘../../util’).escape.yaml;
module.exports = function(data){ return yaml.load(escape(data.text)); }; In my eyes, you have two choices:
a) use quotation marks, as in title: “my title : with colon” to simply escape the title. There are some more to find in the YAML specs
b) extend the js-yaml library
You wrote “He tried escaping the colon within the title, but doing so had no effect.”… hmm what exactly have you tried? For me option a) worked in a quick test. Following the specs “title: my title : with colon” should work, too, but I didn’t test this one.