neil-lindquist / lisp-paredit

Paredit for Atom
MIT License
24 stars 5 forks source link

Indent does not work #42

Open habruening opened 2 years ago

habruening commented 2 years ago

The command Lisp Paredit: Indent works incorrectly.

This code

(defun make-key-button-instance-with-action (&key button short-help long-help action) (g-signal-connect button "clicked" (lambda (widget) (declare (ignore widget)) (funcall action))) (make-key-button-instance :button button :short-help short-help :long-help long-help))

is incorrectly replaced by this

(defun make-key-button-instance-with-action (&key button short-help long-help action) (g-signal-connect button "clicked" (lambda (widget (declare (ignore widget)) (funcall action)))) (make-key-button-instance :button button :short-help short-help :long-help long-help))

I have lisp-paredit 0.8.0 installed. I found out that the problem does not occur when I disable the package parinfer, which is also installed.

neil-lindquist commented 2 years ago

I'm having trouble reproducing this issue since Github collapsed all the spaces in your code snippets. Could you format the code in code blocks? The MarkDown should look like something like

```lisp
(defun make-key-button-instance-with-action (&key button short-help long-help action)
 (g-signal-connect button "clicked"
  (lambda (widget)
   (declare (ignore widget))
   (funcall action)))
 (make-key-button-instance :button button :short-help short-help :long-help long-help))
habruening commented 2 years ago

Yes, Github deletes the spaces. But the problem is that the closing bracket in line 3 is deleted and the result is incorrect code.

This

(defun make-key-button-instance-with-action (&key button short-help long-help action)
 (g-signal-connect button "clicked"
  (lambda (widget)
   (declare (ignore widget))
   (funcall action)))
 (make-key-button-instance :button button :short-help short-help :long-help long-help))

becomes this

(defun make-key-button-instance-with-action (&key button short-help long-help action)
  (g-signal-connect button "clicked"
                     (lambda (widget
                                               (declare (ignore widget))
                                               (funcall action))))
  (make-key-button-instance :button button :short-help short-help :long-help long-help))
neil-lindquist commented 2 years ago

I'm still having trouble replicating this. Could you clarify some details that might help me replicate it?

  1. Is your original source indented with spaces or tabs?
  2. What are your paredit and parinfer settings (particularly the checkboxes)?
  3. Are you using CRLF or LF line endings?
  4. Are you using the Lisp grammar in Atom or another grammar?
  5. What version of Atom are you using?
  6. Does this issue occur if the snippet is the only thing in the file?

My current guess at what's happening is that paredit is mis-indenting, then parinfer "corrects" the parenthesis to match the indentation.

habruening commented 2 years ago
  1. The contents is indented with spaces. But it looks and behaves like tabs. But when copy and pasting to another text editor, it is spaces.
  2. Paredit has the option "enabled, when enabled the paredit commands are bount to editors that have Lisp grammar" ticket. The strict mode is disabled. The key bindings are enabled. Parinfer has no settings available.
  3. I suppose it is LF, because I only work on Linux. But I am not sure. I may have copy and pasted something from Internet. You can have a look at the file. I tested it with this file: https://github.com/habruening/lisped/tree/master/src/load.lisp
  4. I cannot say how the Lisp grammar comes into Atom. I have the package language-lisp installed. When I disable this, the syntax highlighting disappears, so I think that package makes the grammar.
  5. Atom is 1.58.0, x64
  6. No

Interestingly to 6, if I have the text in a separate file, then the tab key has no effect on the very first line. Only in the second line. But it behaves correctly. This is different to the file where I originally had the code.

I found out, that when I press tabulator twice, the code gets corrected.