Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3444044
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:51:58+00:00 2026-05-18T08:51:58+00:00

When editing Lisp code, occasionally it’s useful to entirely comment out a top-level definition,

  • 0

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)
;  ...)

… or comment out only part of an s-expression, like this:

(foo x
;    y
     z)

… and then recompile the file and test something in the REPL, etc.

With paredit-mode enabled, this doesn’t work. Here’s what happens, if the point is right before the first paren below:

(defun some-fn (x)
  ...)

and you type a semicolon, what is entered is a semicolon and a newline:

;
(defun some-fn (x)
  ...)

Same with commenting out part of the s-expression:

(foo x
;    
     y
     z)

I think that if the definition is all on one line, this works:

;(defparameter *foo* 10)

… but otherwise I can’t find out how to do this. Paredit is great, I would really like to keep using it. Are there any Lispers who know a way around this, or Emacs-wizards who can whip up a bit of Emacs Lisp to bind to something like paredit-comment-out-s-expr?

If there is a more Lispy or Emacsy way of accomplishing essentially the same thing, commenting out parts of source to recompile, please, don’t hesitate to suggest them!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:51:59+00:00Added an answer on May 18, 2026 at 8:51 am

    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)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When editing javascript, if I need to comment out a large section of code
ess-mode is Emacs speaks statistics. This mode is useful for editing programs for R
Editing some legacy code that populates a datagrid entirely in code. I need to
So Emacs is pretty good at editing Scheme/Racket/Lisp code. One good thing it does
I've recently had a need to do a bit of lisp editing and I
I've editing this original question as I think I've narrowed down the problem... I
Editing because the initial code was confusing. I would assume these two things to
I'm editing some code which wasn't written by myself but someone who's no longer
Once I start editing my code and adding for loops or if then statements
When editing Java code in Eclipse I can modify the code while it's running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.