Skip to content

Commit

Permalink
Merge pull request 200ok-ch#6 from mcraveiro/master
Browse files Browse the repository at this point in the history
feat: set the major mode for jq-json buffer
  • Loading branch information
munen authored Dec 30, 2020
2 parents aaf33fc + e8eb238 commit 153d70b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ Demo:

[[file:images/demo-counsel-jq.gif][./images/demo-counsel-jq.gif]]

** Configuration

By default, the resulting =*jq-json*= buffer will have the major mode
=js-mode=, but that can be customized with the
=counsel-jq-json-buffer-mode= variable if you prefer =json-mode=,
=rsjx-mode= or any other mode.

** EmacsConf 2020 talk on =counsel-jq=

On [2020-11-29 Sun], [[https://github.com/munen/][Zen Monk Alain M. Lafon (@munen)]] gave a talk at
Expand Down
7 changes: 7 additions & 0 deletions counsel-jq.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

(require 'swiper)

(defcustom counsel-jq-json-buffer-mode 'js-mode
"Major mode for the resulting *jq-json* buffer."
:type '(function)
:require 'counsel-jq
:group 'counsel-jq)

(defun counsel-jq-json (&optional query)
"Call 'jq' with the QUERY with a default of '.'."
(with-current-buffer
Expand All @@ -31,6 +37,7 @@
"Wrapper function passing INPUT over to `counsel-jq-json'."
(when (get-buffer "*jq-json*")
(with-current-buffer "*jq-json*"
(funcall counsel-jq-json-buffer-mode)
(erase-buffer)))
(counsel-jq-json input)
(split-string
Expand Down

0 comments on commit 153d70b

Please sign in to comment.