Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ljos/jq-mode
Emacs major mode for editing jq queries.
https://github.com/ljos/jq-mode
emacs emacs-lisp emacs-mode jq
Last synced: 2 days ago
JSON representation
Emacs major mode for editing jq queries.
- Host: GitHub
- URL: https://github.com/ljos/jq-mode
- Owner: ljos
- License: gpl-3.0
- Created: 2015-08-21T11:35:24.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-01-13T12:14:36.000Z (20 days ago)
- Last Synced: 2025-01-23T23:03:51.800Z (9 days ago)
- Topics: emacs, emacs-lisp, emacs-mode, jq
- Language: Emacs Lisp
- Homepage:
- Size: 74.2 KB
- Stars: 113
- Watchers: 3
- Forks: 11
- Open Issues: 6
-
Metadata Files:
- Readme: README.org
- License: COPYING
Awesome Lists containing this project
README
* What is it?
=jq-mode= is an emacs major mode for editing [[https://github.com/stedolan/jq][jq]]-scripts.* Getting started
[[https://melpa.org/#/jq-mode][file:https://melpa.org/packages/jq-mode-badge.svg]] [[https://stable.melpa.org/#/jq-mode][file:https://stable.melpa.org/packages/jq-mode-badge.svg]]
- Download jq-mode.el and put it in a directory somewhere.
- Add the following to your .emacs file#+BEGIN_SRC emacs-lisp
(add-to-list 'load-path "/path/to/jq-mode-dir")
(autoload 'jq-mode "jq-mode.el"
"Major mode for editing jq files" t)
(add-to-list 'auto-mode-alist '("\\.jq$" . jq-mode))
#+END_SRCNow jq-mode will load whenever you visit a file whose name ends
with .jq. Alternatively, run =M-x jq-mode= in an existing
buffer containing jq commands.* Interactive mode
=jq-mode= can also be used interactively in a JSON buffer. If you
add the following to your .emacs file#+BEGIN_SRC emacs-lisp
(with-eval-after-load "json-mode"
(define-key json-mode-map (kbd "C-c C-j") #'jq-interactively))
#+END_SRCor you can call =M-x jq-interactivly=. =jq-interactively= runs the
expression that is written in the minibuffer iteratively over the
JSON buffer. Press =C-g= to abort, =C-j= for newline, =RET= commits
any changes.** Use yq for yaml
It is possible to use [[https://github.com/kislyuk/yq][yq]] to process yaml with the interactive mode instead:
#+BEGIN_SRC emacs-lisp
(setq jq-interactive-command "yq"
jq-interactive-font-lock-mode #'yaml-mode
jq-interactive-default-options "--yaml-roundtrip")
#+END_SRC* Org babel
=jq-mode= provides =ob-jq= for working with literate programming in
Org mode.Add =jq= under =org-babel-load-languages= in your .emacs file
#+BEGIN_SRC emacs-lisp
(org-babel-do-load-languages 'org-babel-load-languages
'((jq . t)))
#+END_SRC** jq specific header arguments
=ob-jq= provides some additional header arguments:
- =:compact= :: Add =-c= to =jq= arguments list suppressing pretty printing
* Bugs and Enhancements
If you have a problem or would like to see it get better in a
specific way, feel free to drop an issue in [[https://github.com/ljos/jq-mode/issues][the issue tracker]].
Enjoy!