我有许多方便的功能,可以在当前单词或区域上操作,由于懒惰等原因,我将它们构建成了一个模板...
例如,
有效地说,除了这一行之外,这都是标准模板内容。
定义
我得到的错误信息是:Symbol's function definition is void: fn。
我是不是傻傻地以为在Emacs Lisp中可以进行柯里化?还是我做错了什么?
例如,
(defun lower-camelcase-at-point-or-region ()
"lowerCamelCaseTheCurrent dashed or snake_case word or any words in text selection."
(interactive)
(let (pos1 pos2 meat)
(if (and transient-mark-mode mark-active)
(setq pos1 (region-beginning)
pos2 (region-end))
(setq pos1 (car (bounds-of-thing-at-point 'symbol))
pos2 (cdr (bounds-of-thing-at-point 'symbol))))
(setq meat (s-lower-camel-case (buffer-substring-no-properties pos1 pos2)))
(delete-region pos1 pos2)
(insert meat)
)
)
有效地说,除了这一行之外,这都是标准模板内容。
(setq meat (s-lower-camel-case (buffer-substring-no-properties pos1 pos2)))
在缓冲区子字符串上调用s-lower-camel-case
的位置。我想重复使用点或区域的东西,但不是到处复制它(因为那很愚蠢,而且难以维护)。
所以我真正想知道的是,我能否在Emacs Lisp中进行函数柯里化?
当我尝试这样做时...
(defun do-stuff-on-point-or-region ()
"Do stuff."
(interactive)
(operate-on-point-or-region 's-lower-camel-case)
)
定义
operate-on-point-or-region
为...:(defun operate-on-point-or-region (fn)
"Pick the substring at point, or region
and replace it with the output of fn"
(let (pos1 pos2 meat)
(if (and transient-mark-mode mark-active)
(setq pos1 (region-beginning)
pos2 (region-end))
(setq pos1 (car (bounds-of-thing-at-point 'symbol))
pos2 (cdr (bounds-of-thing-at-point 'symbol))))
(setq meat (fn (buffer-substring-no-properties pos1 pos2)))
(delete-region pos1 pos2)
(insert meat)
)
)
我得到的错误信息是:Symbol's function definition is void: fn。
我是不是傻傻地以为在Emacs Lisp中可以进行柯里化?还是我做错了什么?