假设我有这个代码
(hello world) (hi world)
然后我想到我应该用以下形式包装它:
(let (acc) <> (nreverse acc))
导致此代码:
(let (acc) (hello world) (hi world) (nreverse acc))
这是我通常做包装的方式.首先,我在待包装的表单之前写一个不完整的外部表单,如下所示:
(let (acc)) (hello world) (hi world)
然后我按两次C-)(paredit-forward-slurp-sexp)来啜饮东西:
(let (acc) (hello world) (hi world))
然后我在最后添加(nreverse acc)完成.
现在我想知道如果我开始首先编写这样的完整外部表单模板?
(let (acc) (nreverse acc)) (hello world) (hi world)
或者像这样
(hello world) (hi world) (let (acc) (nreverse acc))
是否有一个简短的paredit或非paredit命令序列,我可以按此完成从那开始的工作?
我可以移动点,剪切两个待包装的表格,移动点,粘贴表格.但我想知道是否有更方便的方式.
我对如何进行包装感到满意,但感觉我可能会错过一些其他整齐的编辑技巧,这些技巧可以从不同的开始找到.
解决方法
@H_502_39@ 而不是重复使用paredit-forward-slurp-sexp或kill-yank’ing the region,你可以标记性别区域以封闭并使用paredit-wrap-round M-(如果我输入你的例子,我会从最后一个表达开始:
(hello world) (hi world) (nreverse acc)_
C-SPC C-M-a C-M-a C-M-a M-(产率:
(_(hello world) (hi world) (nreverse acc))
插入let(acc)并使用RET C-M-h TAB完成重新识别.
可能有更好的方法=),但即使你不使用瞬态标记模式,你也可以提供其他包装选项:
> C-u包装到缓冲区或封闭列表的末尾
> C-u#包含以下#表达式
请参阅paredit-wrap-sexp的docstring