Skip to content

Commit

Permalink
feat: Adhere to melpa package conventions
Browse files Browse the repository at this point in the history
       - Ran package-lint
       - Read https://www.gnu.org/software/emacs/manual/html_node/elisp/Simple-Packages.html
       - Ran checkdoc
       - Set version to 1.0.0
       - Enable lexical-binding
       - Prefix function with reader macro #'
  • Loading branch information
munen committed Nov 3, 2019
1 parent 3e6d782 commit 33d709f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions counsel-jq.el
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
;;; package -- Live preview of "jq" queries using counsel.
;;; counsel-jq.el --- Live preview of "jq" queries using counsel. -*- lexical-binding: t; -*-
;;; Version: 1.0.0
;;; Author: Alain M. Lafon <[email protected])
;;; Package-Requires: ((swiper "0.12.0") (emacs "24.1"))
;;; Keywords: convenience, data, matching
;;; URL: https://github.com/200ok-ch/counsel-jq
;;; Commentary:
;;; Needs the "jq" binary and ivy/counsel installed.
;;; Needs the "jq" binary installed.
;;; Code:

(defun jq-json (&optional query)
(defun counsel-jq-json (&optional query)
"Call 'jq' with the QUERY with a default of '.'."
(with-current-buffer
;; The user entered the `counsel-jq` query in the minibuffer.
Expand All @@ -21,11 +26,11 @@
(or query "."))))

(defun counsel-jq-query-function (input)
"Wrapper function passing INPUT over to jq-json."
(if (get-buffer "*jq-json*")
"Wrapper function passing INPUT over to `counsel-jq-json'."
(when (get-buffer "*jq-json*")
(with-current-buffer "*jq-json*"
(erase-buffer)))
(jq-json input)
(counsel-jq-json input)
(split-string
(with-current-buffer "*jq-json*"
(buffer-string)) "\n"))
Expand All @@ -34,7 +39,7 @@
"Counsel interface for dynamically querying jq."
(interactive)
(ivy-read "jq query: " #'counsel-jq-query-function
:action '(1
:action #'(1
("s" (lambda (x)
(split-window-below)
(switch-to-buffer "*jq-json*"))
Expand All @@ -45,4 +50,5 @@


(provide 'counsel-jq)

;;; counsel-jq.el ends here

0 comments on commit 33d709f

Please sign in to comment.