Copy/Yank entire Lisp form in Slime

▼魔方 西西 提交于 2019-12-07 04:57:25

问题


Is there a way to copy/yank a whole a form in Slime/Emacs?

For instance, if I have the following function:

(myfunc (lst)
    (myotherfunc lst))

I'd like to yank/copy:

(myotherfunc lst)

by issuing a keyboard shortcut when my cursor is at the opening or closing parenthesis for that form (at the point where Slime/Emacs does parenthesis matching).


回答1:


In my Emacs, function kill-sexp is bound to C-M-k. That is, assuming the point is just before an opening delimiter of a balanced expression, press Control, Meta, and k at the same time.

This same command works in various other non-Lisp modes, such as killing brace-delimited blocks in a C-style mode, though the kill-sexp command may not be bound to the same keys.




回答2:


  • C-M-SPC (mark-sexp) to put the mark at the end of the sexp, then copy/yank

  • C-M-f (forward-sexp) and C-M-b (backward-sexp) are useful to move forward and backward over a balanced expression

http://www.emacswiki.org/emacs/ParenthesisMatching#toc2




回答3:


The emacs minor mode ParEdit does this on normal kills 'C-k' by default. I would certainly recommend it to any emacs+slime users.




回答4:


You can use lispy and then you can press n which runs lispy-new-copy to copy

(myotherfunc lst)


来源:https://stackoverflow.com/questions/4657798/copy-yank-entire-lisp-form-in-slime

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!