Skip to content

Comment handling in Janet #173

@jmckernon

Description

@jmckernon

Symex makes some efforts to handle comments smartly, but this doesn't currently work for Janet, which uses # to begin comments (which run to the end of the line). For instance, in the following buffer:

(first sexp)

# comment for second sexp
(second sexp)

Deleting the first sexp with symex will delete the comment, too. (Whereas this seems to work if the comment is a semicolon comment.)

Overriding the following functions appears to fix this issue:

(defun symex-comment-line-p ()
  "Check if we're currently at the start of a comment line."
  (save-excursion
    (back-to-indentation)
    (or (looking-at-p ";") (looking-at-p "#"))))

(defun symex-inline-comment-p ()
  "Check if there is an inline comment following point."
  (looking-at-p "[[:space:]]*[;#]"))

However, I think these changes, as they are, would probably break things for other lisps. Not a problem for me as I largely use Janet, but I wouldn't want to put them into the code base, without some mechanism to check conditionally what the currently comment character is or similar, which is beyond my knowledge.

There may also be other functions which would need amending but these are the ones I found for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions