-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adhere to melpa package conventions
- 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
Showing
1 changed file
with
13 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
@@ -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")) | ||
|
@@ -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*")) | ||
|
@@ -45,4 +50,5 @@ | |
|
||
|
||
(provide 'counsel-jq) | ||
|
||
;;; counsel-jq.el ends here |