0

In Common Lisp you can define multiline comments with #| \n\n\n |#.

However when I press Return with cursor above such comment, each line of the comment is appended with ' ;' and pressing Return multiple time can result in many ; ; ; ;.

;; aaa.lisp

(warn "beginning")






#|
                    ; ; ; ; ;
ala ma              ; ; ; ; ;
kota                ; ; ; ; ;
                    ; ; ; ; ;
|#

(warn "end")

That is very annoying.

I suspect the culprit is the code indicated below, but I do not know how to fix it. If there is no easy fix, do you suggest any alternatives?

emacs-31/lisp/newcomment.el::1117

(defun comment-add (arg)
  "Compute the number of extra comment starter characters.
\(Extra semicolons in Lisp mode, extra stars in C mode, etc.)
If ARG is non-nil, just follow ARG.
If the comment starter is multi-char, just follow ARG.
Otherwise obey `comment-add'."
  (if (and (null arg) (= (string-match "[ \t]*\\'" comment-start) 1))
      (* comment-add 1)
    (1- (prefix-numeric-value arg))))

Alternative

I can select a region and then press C-x r t for the command string-rectangle. The command asks me for the character, so I enter the comment characters ';;'. That gives me the same as the multiline comment but without the problem with garbling by adding the ; at column 40.

It's Paredit related problem

Commenting out these two lines hides the problem https://github.com/bigos/prelude/blob/c4a2e859fe11a0d5731d2109ecf253d51b0301d0/personal/organised.el#L845

Minimal configuration

Starting Emacs with minimal configuration https://github.com/bigos/Pyrulis/blob/master/Emacs/problem-with-paredit-garbling-multiline-comments.org#replicating-minimal-config

and trying to edit example Common Lisp file with multi line comment, still shows the problem.

(require 'package)

(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)

(unless (package-installed-p 'paredit)
  (package-install 'paredit))

(add-hook 'lisp-mode-hook 'enable-paredit-mode)

;; end of init.el -----------------------------
13
  • 1
    What do I have to do to try to reproduce the problem you are describing? Can you provide a recipe starting from emacs -Q?
    – NickD
    Commented Nov 30 at 2:00
  • 1
    If it works fine with emacs -Q and it does not work fine when you load your init file, then bisect your init file to find the breakage.
    – NickD
    Commented Nov 30 at 3:07
  • 1
    The multi-line comment problem is annoying. But I may find a solution that will help others. I just needed a break, but I will keep looking. I may try to recreate a minimal config that illustrates the problem. Commented Nov 30 at 17:08
  • 1
    github.com/bigos/Pyrulis/blob/master/Emacs/… I was able to replicate the problem with minimal configuaration, how do I turn it into a useful question? Commented Nov 30 at 17:39
  • 1
    Add the minimal configuration to your question so that the question becomes self-contained: that and the example file plus your description of what happens should be enough. I won't be able to do anything in the next week, but I'll try your instructions the week after and let you know. You might want to move your possible fix to an answer: if somebody provides a better answer, you can always accept the better one in the future.
    – NickD
    Commented Nov 30 at 19:31

1 Answer 1

0

Possible fix

Adding the following to my configuration seems to fix the problem. https://github.com/bigos/prelude/commit/69d16f230570e7e255bca9bd9550e088a5bd75ba

(eval-after-load 'paredit
  '(progn
     (define-key paredit-mode-map (kbd "RET") nil)
     (define-key paredit-mode-map (kbd "C-j") nil)))

It was inspired by the following line: https://paredit.org/cgit/paredit/tree/paredit.el#n118

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.