From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id eOzlLTPpu2C5dAAAsNZ9tg (envelope-from ); Sat, 05 Jun 2021 21:14:27 +0000 Received: from out2.migadu.com ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id oNXFLS/pu2CORgAAbx9fmQ (envelope-from ); Sat, 05 Jun 2021 21:14:23 +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=1622927663; 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=20yURLPMS3LQr3SOL61YXtpUjNguhSURPctMN0yEeD8=; b=vSuDr64MvZLw+qdLXMA65mAHXr8NFh3e3OtfXdDx6PaQGO6BRkLRziVGcR3eVHggRuFjqq DJ7XewoXdcE22pdzd3us5VnM2Uysel8kBJSqGTm0uqCqhGAWYEJuhsaTUTuvsj5/YuokvW p7RKS4cqRdnTzjWHPM/G67coVSb5R6E7/dFKukhKZHhYHn6OlL1FqLD9s0VEbRxzI15i5e ruFlRiFL1ts3uOMwK4hZZQnoulrH8tPIytnB1nbY7aphwvHTyWk+WDMWEEnig4LDmJpr7K q6OWUrUuUDJJoPhIzuZxdYMRbPDsgi1wQOy0YXDCSxt8rrrriYCkeyxMKqWs7g== From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [PATCH 02/18] piem-lei-show: Let caller suppress displaying buffer Date: Sat, 5 Jun 2021 17:13:46 -0400 Message-Id: <20210605211402.20304-3-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: GddQFYz/xAvV piem-lei-show switches to the message buffer with pop-to-buffer, but that behavior won't work well in the context of a mode that gives an overview of lei-q search results. In that case, a wrapper command will want to control the display of the buffer so that it can keep a split window layout and avoid switching to the piem-lei-show-mode buffer. And more generally, Lisp callers are likely to want to handle the display themselves. Add an optional 'display' parameter that defaults to nil for non-interactive calls. --- piem-lei.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/piem-lei.el b/piem-lei.el index 5b986fc0..fe6ab79a 100644 --- a/piem-lei.el +++ b/piem-lei.el @@ -30,10 +30,13 @@ (defgroup piem-lei nil ;;;; Message display -(defun piem-lei-show (mid) - "Show message for MID." +(defun piem-lei-show (mid &optional display) + "Show message for MID. +When called non-interactively, return the buffer but do not display it +unless DISPLAY is non-nil." (interactive - (list (read-string "Message ID: " nil nil (piem-mid)))) + (list (read-string "Message ID: " nil nil (piem-mid)) + 'display)) (with-current-buffer (get-buffer-create "*lei-show*") (let ((inhibit-read-only t)) (erase-buffer) @@ -44,7 +47,9 @@ (defun piem-lei-show (mid) (delete-region (line-beginning-position) (1+ (line-end-position)))) (piem-lei-show-mode)) - (pop-to-buffer (current-buffer)))) + (if display + (pop-to-buffer (current-buffer)) + (current-buffer)))) (define-derived-mode piem-lei-show-mode special-mode "lei-show" "Major mode for displaying message via lei." -- 2.31.1