我想要添加/删除“..”(有一个空格 - 但我不能使它更明显)在上面的每一行(点)前面的字符串。这是我最好的选择:自定义切换器?
(defun rst-comment-above (Point)
(interactive "d")
(save-excursion
(goto-char 1)
(cond
((numberp (get this-command 'state))
((replace-regexp "^\\.\\. " "" nil (point) (get this-command 'state)))
(put this-command 'state ""))
(t
(replace-regexp "^" ".. " nil (point) Point)
(put this-command 'state Point))
)))
它的工作原理是第一次,但第二,它说:
(invalid-function
(replace-regexp "^\\.\\. " "" nil (point) (get this-command (quote state))))
编辑:
@ user4815162342:
所以我评论以上内容:
然后我插入新行:
然后我想取消对的事情,我也得到:
,不过也许它不是那么重要。我通常不会在评论区域输入任何内容。我只是注意到这个问题。什么是更重要的 - 在会话中存储给定文件的'state
。难以实施吗?
而不是(goto-char 1)我推荐'(goto-char(point-min))'。 – Stefan
@Stefan:好的。虽然我现在不使用缩小。 – Adobe
我现在明白你的意思了。我已经更新了我的答案来处理这个案例,并修复了另一个错误。请尝试新版本。 – user4815162342