ljos / jq-mode

Emacs major mode for editing jq queries.
GNU General Public License v3.0
110 stars 12 forks source link

Add :compact parameter for ob-jq #11

Closed Fuco1 closed 6 years ago

Fuco1 commented 6 years ago

This will add -c flag to jq output to suppress pretty-printing. Useful when we use jq to generate queries for MongoDB or other machine processing where we don't need the output to be pretty and take up unnecessary space.

By default pretty print the output.

ljos commented 6 years ago

It is possible to already do this with :cmd-line -c, but if you feel it is convenient to add it as another header argument I don't mind. I would like to to use --compact-output instead of -c in the mode source instead though. It just makes it clearer what is going on when reading later.

Fuco1 commented 6 years ago

Initially I tried to somehow make this work with :results pp but that behaves quite oddly and the docs are super unclear about what it should actually do

pp Result converted to pretty-print source code. Enclosed in a ‘src’ code block. Languages supported: Emacs Lisp, Python, and Ruby. Usage example: :results value pp.

The fact that it only works for 3 languages is kind of odd. So I guess this is not exactly in line with what we want to achieve here.

I think that an extra argument makes it a bit more discoverable but also I'm not sure about adding extra bloat for each switch (I was not aware of the possibility to do this with :cmd-line although it seems obvious now :D)

ljos commented 6 years ago

I think the :results pp is for printing source code and not results, or the same as :results code but it formats as well.

ljos commented 6 years ago

Also, I don't mind adding the :compact header. I think it is something that people will use often compared to other arguments, so it is fine to add it. However, as I said, I would prefer the emacs lisp code to use the long form and not the short as it is easier to read.

If you make this change I think it is OK to merge this.

Fuco1 commented 6 years ago

Yea, agreed. I'll try to get to it.