ljos / jq-mode

Emacs major mode for editing jq queries.
GNU General Public License v3.0
110 stars 12 forks source link

can i view the result in separate buffer in interactive mode #14

Open huangyg11 opened 5 years ago

huangyg11 commented 5 years ago

In interactive mode, how can I view the result in a separate view instead of replacing current buffer.

Thanks!

ljos commented 5 years ago

This hasn't been implemented. You might be able to jury-rig it with another window showing a copy of the current buffer.

I will look into how to implement this at a later date unless someone else is interested in working on it.

danilevy1212 commented 2 years ago

This is exactly what I just did for my doom-emacs config:

  (defadvice! dan/jq-interactivly--show-original-other-window (fn beg end)
    "TODO"
    :around #'jq-interactively
    (let ((cb  (current-buffer)))
      (with-current-buffer (get-buffer-create "*jq-interactive*")
        (insert (with-current-buffer cb (buffer-string)))
        (display-buffer (current-buffer) #'display-buffer-pop-up-window)
        (with-current-buffer cb
          (funcall fn beg end))
        (kill-buffer-and-window)))))
cfclavijo commented 1 month ago

based on @danilevy1212 input, this is the equivalent with the advice-add

(defun my/jq-interactivly--show-original-other-window (fn beg end)
  "TODO"
  (let ((cb (current-buffer)))
    (with-current-buffer (get-buffer-create "*jq-interactive-original-input*")
      (insert (with-current-buffer cb (buffer-string)))
      (display-buffer (current-buffer) #'display-buffer-pop-up-window)
      (with-current-buffer cb
        (funcall fn beg end))
      (kill-buffer-and-window)
      )
    )
  )
(advice-add #'jq-interactively :around #'my/jq-interactivly--show-original-other-window)