How do you comment out all or part of a Lisp s-exp using Paredit?

后端 未结 4 1948
伪装坚强ぢ
伪装坚强ぢ 2020-12-29 09:30

When editing Lisp code, occasionally it\'s useful to entirely comment out a top-level definition, like this:

;(defun some-fn-which-is-broken (x)
;  ...)
         


        
4条回答
  •  悲&欢浪女
    2020-12-29 09:32

    Position the point on the first character of the whole sexp, mark the whole sexp with C-M-space, and issue M-; to do the commenting. If it is necessary to do so, your source code will also be re-formatted so that only the sexp you marked, and nothing that was also on the same line, is in a comment.

    You can very easily make a simple command or even a macro to do that:

    (defun comment-sexp ()
      "Comment out the sexp at point."
      (interactive)
      (save-excursion
        (mark-sexp)
        (paredit-comment-dwim)))
    

提交回复
热议问题