Use tree-minor-mode for better json-navigator keybindings

This commit is contained in:
Jeremy Dormitzer 2020-06-03 18:08:45 -04:00
parent 720c84b4c5
commit e4c2602390

View File

@ -6,7 +6,8 @@
;; Version: 0.1.0
;; Package-Requires ((dash "2.17.0")
;; (s "1.12.0")
;; (json-navigator "0.1.1"))
;; (json-navigator "0.1.1")
;; (tree-mode "1.1.1.1"))
;; Keywords: data
;; This program is free software; you can redistribute it and/or modify
@ -33,6 +34,7 @@
(require 's)
(require 'dash)
(require 'json-navigator)
(require 'tree-mode)
(defvar structlog-fields nil
"Currently selected structlog fields")
@ -196,7 +198,8 @@
(let* ((log (tabulated-list-get-id))
(json (structlog--serialize-json log)))
(json-navigator-display-tree
(json-navigator--read-string json))))
(json-navigator--read-string json))
(tree-minor-mode)))
(defvar structlog-mode-map
(let ((map (make-sparse-keymap)))
@ -214,7 +217,21 @@
(kbd "RET") #'structlog-view-log-at-point
"S" #'tabulated-list-sort
"{" #'tabulated-list-narrow-current-column
"}" #'tabulated-list-widen-current-column))
"}" #'tabulated-list-widen-current-column)
(evil-define-key 'normal tree-mode-map
"D" #'tree-mode-delete-tree
"k" #'tree-mode-previous-node
"j" #'tree-mode-next-node
"l" #'tree-mode-next-sib
"h" #'tree-mode-previous-sib
"u" #'tree-mode-goto-parent
"r" #'tree-mode-goto-root
"gr" #'tree-mode-reflesh
"E" #'tree-mode-expand-level
"e" #'tree-mode-toggle-expand
"s" #'tree-mode-sort-by-tag
"/" #'tree-mode-keep-match
"!" #'tree-mode-collapse-other-except))
(define-derived-mode structlog-mode tabulated-list-mode "structlog"
"Major mode to query structured log lines"