Skip to content
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

Strange behavior in Janet files #47

Open
MaxGyver83 opened this issue Jan 7, 2024 · 2 comments · May be fixed by #50
Open

Strange behavior in Janet files #47

MaxGyver83 opened this issue Jan 7, 2024 · 2 comments · May be fixed by #50

Comments

@MaxGyver83
Copy link
Contributor

I noticed some strange behavior in Janet files.

Example 1:

(defmacro $<
  [& args]
  (def specs (collect-proc-specs args))
  (tuple $<* ;specs)
  # ~(upscope
  #   (pp ,specs)
  #   (tuple ,$<* ,;specs))
  )

When I select the comment lines (linewise visual mode) and delete them with d, I end up with this:

(defmacro $<
  [& args]
  (def specs (collect-proc-specs args))
  (tuple $<* ;specs)
  ((
  )

These two opening parentheses are unexpected.

Example 2a:

(defn- escape [str]
  (->> str
    (string/replace-all " " "\\ ")
    (string/replace-all `"` `\"`)
    ))

When I put the cursor in line 4 of this snippet and delete/cut the line with dd, I end up with:

(defn- escape [str]
  (->> str
    (string/replace-all " " "\\ ")
    ("
    ))

The (" is not expected.

Example 2b:

When I put the cursor again in line 4 in example 2a and try to copy the line with yyp (instead of deleting it), I end up with:

(defn- escape [str]
  (->> str
    (string/replace-all " " "\\ ")
    (string/replace-all `"` `\"`)
     string/replace-all ` ` `\"`)
    ))

The opening parenthesis in the new line 5 is missing.

@kovisoft
Copy link
Owner

Sorry for the late response. Well, TBH the janet support was not part of the original implementation, it was added as a contribution here:
9f5ba8a

I myself do not know anything about the janet language. I looked it up here: https://janet-lang.org/docs/syntax.html and it seems that its syntax differs from the general lisp syntax in many places. One of them is the commenting. In lisp the comment is ; which seems to be used for a shorthand of (splice ) in janet, and the comment is # in janet. This is causing the first issue, because paredit does not recognize that we are inside a comment block.

The other issues are caused by the backquote that again means something different in janet.

@MaxGyver83
Copy link
Contributor Author

Thank you for this hint. See #49 which fixes the behavior of example 1.

@MaxGyver83 MaxGyver83 linked a pull request Feb 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants