summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2021-06-05 17:13:59 -0400
committerKyle Meyer <kyle@kyleam.com>2021-06-07 00:12:07 -0400
commit6738bf5704c7d7fdf12152980b43673a591182f0 (patch)
tree61826c2809e5bfa6fe263bba81cec24a05ec791c
parent546a351b0d0082a0710da2457f7ab78a9af6a1d0 (diff)
downloadpiem-6738bf5704c7d7fdf12152980b43673a591182f0.tar.gz
lei query: Add commands for showing or scrolling message buffer
Start with direct wrappers around scroll-{up,down}-command, but it might be worth making these circle around (like magit-diff-show-or-scroll-{up,down} do) rather than signaling an error at the beginning or end of the buffer. Message-Id: <20210605211402.20304-16-kyle@kyleam.com>
-rw-r--r--piem-lei.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/piem-lei.el b/piem-lei.el
index 3cb61ab..8267da5 100644
--- a/piem-lei.el
+++ b/piem-lei.el
@@ -289,6 +289,36 @@ it to display the message."
(interactive "p")
(piem-lei-query-next-line (- n)))
+(defun piem-lei-query-show-or-scroll-up (arg)
+ "Show or scroll up message for current query line.
+If there is a visible `piem-lei-show-mode' buffer for the current
+line's message, scroll its text upward, passing ARG to
+`scroll-up-command'. Otherwise show the message with
+`piem-lei-query-show'."
+ (interactive "^P")
+ (if-let ((mid (piem-lei-query-get-mid)))
+ (let ((w (piem-lei-query--get-visible-message-window)))
+ (if (and w
+ (equal (with-current-buffer (window-buffer w)
+ piem-lei-show-mid)
+ mid))
+ (with-selected-window w
+ (scroll-up-command arg))
+ (piem-lei-query-show)))
+ (ding)))
+
+(defun piem-lei-query-show-or-scroll-down (arg)
+ "Show or scroll down message for current query line.
+If there is a visible `piem-lei-show-mode' buffer for the current
+line's message, scroll its text downward, passing ARG to
+`scroll-down-command'. Otherwise show the message with
+`piem-lei-query-show'."
+ (interactive "^P")
+ (piem-lei-query-show-or-scroll-up
+ (cond ((eq arg '-) nil)
+ (arg (- arg))
+ (t '-))))
+
(define-derived-mode piem-lei-query-mode special-mode "lei-query"
"Major mode for displaying overview of `lei q' results."
:group 'piem-lei