【发布时间】:2014-03-13 22:28:21
【问题描述】:
我希望能够切换点下字母的大小写。为此,我写了这个:
(defun toggle-case-next-letter ()
"Toggles the case of the next letter, then moves the point forward one character"
(interactive)
(let* ((p (point))
(upcased (upcasep (char-after)))
(f (if upcased 'downcase-region 'upcase-region)))
(progn
(f p (+ 1 p))
(forward-char))))
但是,当我运行它时(我已将其绑定到 M-#),我得到了 progn: Symbol's function definition is void: f。我认为这意味着f 没有被绑定,但我不确定。
Upcasep 定义为:
(defun upcasep (c) (eq c (upcase c)))
是 let 绑定的问题,还是其他问题? (另外,如果有更好的方法来做到这一点,那也很好)。
请注意,最初我有 (upcased (upcasep (buffer-substring-no-properties p (+ 1 p)))),我已将其更正为 (upcased (upcasep (char-after)),因为使用上面定义的 upcasep 始终是 nil 字符串(所以我不能再次小写)。
【问题讨论】: