ljos / sparql-mode

A SPARQL mode for emacs
GNU General Public License v3.0
59 stars 23 forks source link

sparql-indent-offset variable does not affects blank nodes indention #61

Closed jgrzebyta closed 6 years ago

jgrzebyta commented 7 years ago

Ref #60

I found when I change sparql-indent-offset it does not affect indention within blank nodes. By default it always stay 2.

It would be great if blank nodes indention value would be negative. Maybe it is worth to create variable sparql-bnode-indent-offset.

ljos commented 7 years ago

What do you mean by the indentation value being negative? Can you show me an example?

ljos commented 7 years ago

I pushed a patch for the first part; the indentation of blank nodes is always 2.

jgrzebyta commented 7 years ago

File with example of the negative indention is attached with exmaple indent value -4. It is simply 4 spaces to the left from the nearest open bracket ([) column.

negative-indent.txt

ljos commented 7 years ago

Is this desirable? The way it is implemented now (especially with the latest patch) is the way that the specification formats blank nodes. I could see an argument for indenting blank nodes the same way as other parenthesis, so

select * where {
  ?row raw:hasParameterX ?param1 ;
  raw:hasParameterY ?param2 ;
  raw:hasReading [
    rdf:rest*/rdf:first [
      raw:unit ?unit ;
      rdf:value ?value ;
    ] ;
  ] .
}

Which would mean we just indent in according to previous indentation column instead the special case of blank nodes where the indentation is based on the column of the previous [. This could be configurable, but a negative indentation based on the column of [ feels strange to me.

Do you have a reason for wanting to do that? It could make it difficult in some instances where the negative indentation is further back than the current indentation.

jgrzebyta commented 7 years ago

@ljos No I do not have any special reason to have negative indentation. It seems your argumentation is correct: indentation should be based on the previous bracket not the current one.