From e4c2602390647eb5612226916ce6a34d7cf1a4f4 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 3 Jun 2020 18:08:45 -0400 Subject: [PATCH] Use tree-minor-mode for better json-navigator keybindings --- structlog-mode.el | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/structlog-mode.el b/structlog-mode.el index 6d66be8..9d78920 100644 --- a/structlog-mode.el +++ b/structlog-mode.el @@ -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"