From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id cJOdE0rpu2AaYwAAsNZ9tg (envelope-from ); Sat, 05 Jun 2021 21:14:50 +0000 Received: from out2.migadu.com ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id SMX3E0bpu2AeWgAAB5/wlQ (envelope-from ); Sat, 05 Jun 2021 21:14:46 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1622927686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lrs90TYr6gkDYsrmlcKk7uRYRo2id5+hdvQSjRL2MkY=; b=AHR2Ff0y6rYKlfHvcsrekJqZ6TEpYOLCFfrvba3xQ0Vsp5zyyLXMyzAoSPTqRzRPyhegNg se4PScAY31kYj0AyCiUSIGrbPW1VuoDiFQz5l1lGTvdyLGwPofpCoCEttjA5/gXtsucWva yJtDtd2S4jy2O1IGibs/uvpVdh7JHre9bvlRwL+UoXGTh9GybVQ3xdVkrT9knCi5k7Mp+H KR83JBwK3jsdIZpbz4tqr1WovPVRIUVXOlmliR9l5FvoTrI73lin4XpZoSrAIV9WxH8/vk H99oM031yenHmwyRhaqlgh8uPY724IsgTFA8o6u7+dyKoflOIqkWouYBICzwdA== From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [PATCH 15/18] lei query: Add commands for showing or scrolling message buffer Date: Sat, 5 Jun 2021 17:13:59 -0400 Message-Id: <20210605211402.20304-16-kyle@kyleam.com> In-Reply-To: <20210605211402.20304-1-kyle@kyleam.com> References: <20210605211402.20304-1-kyle@kyleam.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: kyle@kyleam.com X-TUID: d46MMZ7RDUU/ 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. --- piem-lei.el | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/piem-lei.el b/piem-lei.el index 3cb61abc..8267da5b 100644 --- a/piem-lei.el +++ b/piem-lei.el @@ -289,6 +289,36 @@ (defun piem-lei-query-previous-line (n) (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 -- 2.31.1