joaotavora / sly

Sylvester the Cat's Common Lisp IDE
1.26k stars 142 forks source link

Bug in the sly-indentation #183

Open PuercoPop opened 6 years ago

PuercoPop commented 6 years ago

Steps to reproduce.

Start up emacs with `emacs -Q -L . -l sly-autoloads from the sly folder. Then

M-x sly

Then open a file with the following contents

(loop for i from 0 below end by 2
                       if (char/= (char mods (1+ i)) #\-)
                       do (signal 'kbd-parse)
                       collect (case (char mods i)
                                 (#\M (list :meta t))
                                 (#\A (list :alt t))
                                 (#\C (list :control t))
                                 (#\H (list :hyper t))
                                 (#\s (list :super t))
                                 (#\S (list :shift t))
                                 (t (signal 'kbd-parse-error :string mods))))

Press tab on the do clause, or any line after the first one and before the collect clause. Or on the whole loop form (after selecting it with, C-M-SPC)

Backtrace
Debugger entered--Lisp error: (args-out-of-range # 13 93)
  indent-line-to(1)
  indent-sexp()
  pp-buffer()
  pp-to-string((:emacs-rex (slynk:buffer-first-change "/home/puercopop/scratch-2.lisp") nil t 47))
  pp((:emacs-rex (slynk:buffer-first-change "/home/puercopop/scratch-2.lisp") nil t 47) #)
  sly-pprint-event((:emacs-rex (slynk:buffer-first-change "/home/puercopop/scratch-2.lisp") nil t 47) #)
  sly-log-event((:emacs-rex (slynk:buffer-first-change "/home/puercopop/scratch-2.lisp") nil t 47) #)
  sly-net-send((:emacs-rex (slynk:buffer-first-change "/home/puercopop/scratch-2.lisp") nil t 47) #)
  sly-send((:emacs-rex (slynk:buffer-first-change "/home/puercopop/scratch-2.lisp") nil t 47))
  sly-dispatch-event((:emacs-rex (slynk:buffer-first-change "/home/puercopop/scratch-2.lisp") nil t #f(compiled-function (g12) #)))
  sly-eval-async((slynk:buffer-first-change "/home/puercopop/scratch-2.lisp"))
  sly-first-change-hook()
  indent-line-to(25)
  #f(compiled-function (&optional indent) "Indent current line as Lisp code." (interactive nil) #)()
  apply(#f(compiled-function (&optional indent) "Indent current line as Lisp code." (interactive nil) #))
  #f(compiled-function (&rest args) #)(#f(compiled-function (&optional indent) "Indent current line as Lisp code." (interactive nil) #))
  apply(#f(compiled-function (&rest args) #) #f(compiled-function (&optional indent) "Indent current line as Lisp code." (interactive nil) #) nil)
  lisp-indent-line()
  indent--funcall-widened(lisp-indent-line)
  indent-for-tab-command(nil)
  funcall-interactively(indent-for-tab-command nil)
  call-interactively(indent-for-tab-command nil nil)
  command-execute(indent-for-tab-command)

(Haven'tr tried to debug it properly yet, Its late here so I just to log the error before I forget as it seems like an edge case.)

joaotavora commented 6 years ago

This is most likely Emacs bug 32014 (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32014). It doesn't happen in Emacs 25.

The bug has been worked around in #165, but the workaround doesn't help here.

Also, would you mind if I edit your post to fix recipe for you? Or you can do it. You're missing M-x sly, sly-contribs is generally best left alone, and tab--always-complete doesn't exist (and tab-always-complete isn't needed).

The simpler recipe from a git checkout of SLY would be.

Emacs -Q -L . -l sly-autoloads -f sly /file-with-any-multiline-loop.lisp
wait for sly to turn on, then press `tab` on the second line of the loop
joaotavora commented 6 years ago

It also doesn't happen on Emacs master, confirming that the bug as been fixed.

EDIT: NOT QUITE, the bug happens when logging to the events buffer in 26.1 and master. It's most likely not the same bug as 32014, but it does appear to the an Emacs bug.

PuercoPop commented 6 years ago

@joaotavora I'm fine you you editing my instructions. I don't quite understand what you mean by the sly-contribs part but I've fix the typo in tab--....

I'm on Emacs 26.1 (although I think you've already deduced that).

joaotavora commented 6 years ago

I don't quite understand what you mean by the sly-contribs part

I meant that you don't need to add things manually to sly-contribs generally. So (push 'sly-indentation sly-contribs) isn't ever needed.

I'm on Emacs 26.1 (although I think you've already deduced that).

Yes, indeed I had.

joaotavora commented 6 years ago

I fixed it Well, I worked around it with a simple hack, but leaving the issue open since this is an Emacs bug.