-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Indentation does not work for me #2
Comments
Hi @petergacs ! Wrap your code in three backticks, newline, and then your code. End it with another three backticks. That should hopefully preserve the formatting. Like this: ``` which gives
Regarding your issue, I haven't used netlogo in a long time but if you can post your snippet I can take a look and see if it works as expected. I faintly recall that there was some discrepancy between format region and per-line formatting. If the direct commands give errors, it's probably related. |
Thank you! I tried the backticks, they had no effect. Here is a code snippet. to age-and-die let new-age xcor + 1 end |
Hi again @petergacs, I tried reproducing this but cannot reproduce any issues with the version in this repo. This is the output I get both from indenting the whole region, and indenting-per-line. to age-and-die
let new-age xcor + 1
ifelse (new-age <= 60)
[set xcor new-age]
[
if is-married?
[
ask spouse
[
set is-married? false
set color red
]
]
die
]
end Can you please post what version of emacs you are using, as well as a callstack for this issue? You should be able to generate one by toggling |
Hi, Ted,
In the meantime, I see that not everything is bad. Using indent-region, or using tab on the whole region works.
netlogo-indent-region generates the trace below, and using tab on a single line does not work.
Peter
I am using Aquamacs 3.4, based on GNU Emacs 25.3.50.1 .
Here is the backtrace:
Debugger entered--Lisp error: (wrong-type-argument sequencep 1)
call-interactively(netlogo-indent-region record nil)
command-execute(netlogo-indent-region record)
execute-extended-command(nil "netlogo-indent-region" "netlogo-indent-r")
funcall-interactively(execute-extended-command nil "netlogo-indent-region" "netlogo-indent-r")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
… On Nov 17, 2018, at 11:36 , Tom Olsson ***@***.***> wrote:
Hi again @petergacs, I tried reproducing this but cannot reproduce any issues with the version in this repo.
This is the output I get both from indenting the whole region, and indenting-per-line.
to age-and
-die
let new-age xcor + 1
ifelse (new-age <=
60
)
[set xcor new-age]
[
if
is-married?
[
ask spouse
[
set is-married? false
set color red
]
]
die
]
end
Can you please post what version of emacs you are using, as well as a callstack for this issue? You should be able to generate one by toggling toggle-debug-on-error to enabled, and then triggering an indentation command to get the error.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
When the indent-region fails it crashes Aquamacs. let x start-center-x - start-radius + random (2 * start-radius) However, it crashes Aquamacs on setxy (start-center-x - start-radius + random (2 * start-radius)) (y start-center-y - start-radius + random (2 * start-radius)) |
Thank you, I've got a reproducible crash with that line. Will see what I can do. |
Hi @petergacs , Can you try the new version I've added here? I've fixed two bugs for indentation, the most severe hopefully being the crash you observed. I'm not sure if it fixes single-line tab, but it should be more consistent in indentation overall. |
Hi, Tom, thank you. I have installed this, so far it has not crashed Emacs. I did a couple of trivial changes to it to mute complaints by byte-compile-file in emacs. I marked those changes in the attached file by "; Gacs:". The netlogo-indent-line still does not work the way it should. At least when I changed the (interactive (point)) to (interactive "P"), it does not give an error message. Peter |
You're absolutely correct on the triple backslash being unnecessary. It works equally for me, but I'll change it next week since it seems unnecessary. Thanks! The positive and negative indentation change is based on where you want to apply the indentation. Consider the below code, with the caret being shown at *.
So, in my mind, if we press
Now, let's take this example instead:
In this situation, we actually want to reduce the indentation on the Now, this is mostly irrelevant because we're just looking at a single line. However, this becomes very important for region-indentation, because you carry the indentation with you. So if you see something that increases indentation, you start applying that after the next linebreak. It you see something that decrements indentation, you want to apply that immediately. Note that this is actually fragile as well:
Will move With that said, I still cannot reproduce any issues with
And going line-by-line and calling
Which is what I expected. |
Hi, Tom,
This version of netlogo-mode seems to work for me (at least under a little testing). Peter |
I made another slight correction in the netlogo-indent-increase-regexp and netlogo-indent-decrease-regexp, replacing the original "\s" with "\s-" (the double backslash does not seem to come through here on the web). |
Line-by-line indentation by tab does strange things. (I cannot give an example here since in the preview all indentation disappears.)
The netlogo-indent-region and netlogo-indent-line commands return errors.
The text was updated successfully, but these errors were encountered: