ljos / jq-mode Goto Github PK
View Code? Open in Web Editor NEWEmacs major mode for editing jq queries.
License: GNU General Public License v3.0
Emacs major mode for editing jq queries.
License: GNU General Public License v3.0
indentation seems to be lost when there are 3 or more nested ifs
#!/usr/bin/env jq -Mf
if .x == null then
if .y == null then
if .z == null then
.
else
.
end
else
.
end
else
.
end
I'd like to see
#!/usr/bin/env jq -Mf
if .x == null then
if .y == null then
if .z == null then
.
else
.
end
else
.
end
else
.
end
It would be great to be able to see the buffer narrowing as you type (and perhaps have tab-completion). Wrapping calls to jq
in something like this would get you part of the way there, but you'd then need to reconstruct the original query:
.|with_entries(select(.key|match("^foo.*")))
*Of course, this breaks lists
It seems a blank line resets the indent level.
#!/usr/bin/env jq -Mf
def x:
# first comment
# second comment after blank line
.
;
I'd like to see
#!/usr/bin/env jq -Mf
def x:
# first comment
# second comment after blank line
.
;
I wanted to convert a bunch of log lines to a csv. jq-interactively
worked amazingly well, but I ultimately wanted to be able to use the -r
option to jq so that I would just print out the result instead of a json string with the result in it.
I was thinking you could use C-r or M-r or toggle raw output.
If you're not opposed to the idea, I might even try to throw together a PR.
Jq has string interpolation like "The input was \(.), which is one less than \(.+1)"
. It would be nice if we showed the interpolated part as normal jq code.
Invoking C-p
(previous input) should bring up the last query. This is conventional for Emacs commands with history.
In interactive mode, how can I view the result in a separate view instead of replacing current buffer.
Thanks!
It seems the indent level is reset to 0 after the top level comments inside of def.
This is what I got
def func():
# top level comment
{
# inner comment
{}
}
The curly bracket should be aligned with the top level comment.
def func():
# top level comment
{
# inner comment
{}
}
The indent after the inner comments work as I expected.
As far as I can see, it's not currently possible to get input from more than one file in a jq block.
I propose adding a new header argument, which can appear more than once, to allow for several files to be read into variables. Something like this:
#+header: :slurpfile file1=file1.json :slurpfile file2=file2.json
When the jq block ends with @csv
, somehow the results aren't converted into a table in org-mode, but returned as quoted and comma-separated strings. Adding :results table
doesn't help. Is this just me?
Using: Emacs 29.1 on Windows, org 9.6.10, jq-mode-20230823.1003.
Great package, thanks!
I was searching for a way to get at the value of the jq expression I last typed in...
I ended up binding a key in json-mode
to do this
(kill-new (car minibuffer-history))
and that more or less does what I want, but I have to press that key after finishing jq-interactively
. Perhaps it would be useful to add an option to jq-mode
that would cause the last interactive jq expression to be pushed to the kill-ring automatically.
Hi,
What do you think about adding yaml support using https://github.com/kislyuk/yq ? Since it's a wrapper around jq
it uses the same filter language, so it wouldn't take a lot of work to support in your project.
I deal with yaml all day long as an SRE in Kubernetes land, so it would be excellent to have a yq
babel source block and a yq-interactively
function.
*Note: there are unfortunately two different projects named yq, don't mix them up. The other one (written in go) doesn't use jq and has significant breakage between major versions... I think it would be a much bigger headache to integrate with.
See code from 305ead8#L168 and onwards.
We are trying to use the same buffer as the json file that we are editing, but we don't want to change the content of the file before the user commits. We use an overlay to hide the original text and show the edited text. The problem is that we don't get font-locking for the edited text. It would be nice if this was possible.
Hi, thanks for this package!
I noticed that indentation rules sometimes don't behave well. One case I noticed today is object literals:
{
"foo":1,
"bar":2,
"baz":3
}
Currently, this gets formatted as:
{
"foo":1,
"bar":2,
"baz":3
}
which isn't very useful.
Hi,
Thanks very much for a great mode, I was using jq from the command line and this is much better! One small question though: when I use jq-interactively
on a indented buffer, the output buffer appears to be un-indented. Is there some option I can set for the output to become indented?
Thanks for your time.
Marco
It seems the nested def resets the indent level
#!/usr/bin/env jq -Mf
def x:
def y:
{
"abc": 123
};
. |= y # this line lost the indent level
;
I'd like to see
#!/usr/bin/env jq -Mf
def x:
def y:
{
"abc": 123
};
. |= y
;
highlight lines that start with # ...
as comments
Hi!
Great work! I was really pleased to find this package on MELPA. Can you add a add a comment to the README to show that this is available from the MELPA repository? Maybe add one of the badges they provide to the "Getting Started" section.
Seems like the overlay prevents any scrolling... is there something I'm missing? Sometimes the thing I want to drill down on is both off screen and out of (my) memory and I need to go look, preferably without cancelling out the interactive session.
Thanks for writing this mode! Could you publish this on MELPA to make it easier to install?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.