这是另一个定义。注释是正确的,您需要通过
let
。请注意,如果此版本处于活动状态,则使用该区域,否则使用
bounds-of-thing-at-point
如果没有区域处于活动状态,则获取单词:
(defun word-or-region-to-lcc ()
"Convert word at point (or selected region) to lower camel case."
(interactive)
(let* ((bounds (if (use-region-p)
(cons (region-beginning) (region-end))
(bounds-of-thing-at-point 'symbol)))
(text (buffer-substring-no-properties (car bounds) (cdr bounds))))
(when bounds
(delete-region (car bounds) (cdr bounds))
(insert (s-lower-camel-case text)))))
如果您不关心使用区域的选项,您可以绑定
text
本地到
(thing-at-point 'symbol)
而不是呼叫
buffer-substring-no-properties
.
更新。
事实证明,你可以使用
(点上的东西符号)
而不是
(thing-at-point 'word)
获取蛇案的完整符号。