Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Ignore form reader macro should "comment" the following form #72

Open
mattly opened this issue Aug 8, 2017 · 3 comments
Open

Ignore form reader macro should "comment" the following form #72

mattly opened this issue Aug 8, 2017 · 3 comments

Comments

@mattly
Copy link

mattly commented Aug 8, 2017

Description

From the Clojure reader reference

The form following #_ is completely skipped by the reader. (This is a more complete removal than the comment macro which yields nil)

grammar guides for other editors will highlight the affected forms as comments.

Steps to Reproduce

  1. put the characters #_ in front of any form, with any amount of whitespace preceding it

Expected behavior: The following form should be interpreted as a comment

Actual behavior: The following form is not interpreted as a comment

Reproduces how often: always

Versions

This has happened on every version of Atom I've used, including 1.19.0

@peter-kehl
Copy link

Additionally, could you make such comments collapsible, please. I know that for other languages, Atom doesn't make all inline comments collapsible; but for some of them it does. For example, following comment is collapsible in PHP:

  /* any multiline
     comment with code right after*/ $v= 1;

@eskemojoe007
Copy link

I took a quick look into this, but I am far from an expert on the subject of atom languages. But atom uses Tree-sitter to parse the content of the file. It parses line by line and not with multi-line support (this is an underlying assumption that is important to my argument). It relies on regex to match the opening and closing of multi-line comments (and other parameters). Other block commented languages often have a unique opening and closing statement such as /* and */ make it easier to find the closing statement. The reader macro is only closed by a paren.

Consider the following simple function:

(defn func1
  [args]
  (clojure.string/join " " (map func2 args)))

We could implement the reader macro (#_()) in a number of different places which would need to select different closing parens. I'll indicate where the comment should stop with the | character.

#_(defn func1
    [args]
    (clojure.string/join " " (map func2 args)))|

(defn func1
  [args]
  #_(clojure.string/join " " (map func2 args))|)

(defn func1
  [args]
  (clojure.string/join " " #_(map func2 args)|))

There are regex ways (using recursion) to find the opening and closing matching parens, but given that tree-sitter doesn't have knowledge of the previous lines this becomes challening to identify the right closing paren using just the built in regex tree-sitter formatting.

Needless, I've given up modifying the simple grammar/clojure.cson

@Aerijo
Copy link

Aerijo commented Apr 5, 2019

@eskemojoe007 mostly right; but Tree-sitter does work across multiple lines.

The grammar you were looking at was a TextMate grammar. Clojure does not have a Tree sitter grammar in Atom yet though, so your argument doesn’t change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants