aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2021-06-05 17:13:46 -0400
committerKyle Meyer <kyle@kyleam.com>2021-06-07 00:12:06 -0400
commit2526059d47ca4645976ca2bc91900ebcf5bb2f48 (patch)
treec36b04e8ca5645842e9f9899cfa1e6c880530858
parentb13cd7660bb479a195ebcddab7d7de4db7f07568 (diff)
downloadpiem-2526059d47ca4645976ca2bc91900ebcf5bb2f48.tar.gz
piem-lei-show: Let caller suppress displaying buffer
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. Message-Id: <20210605211402.20304-3-kyle@kyleam.com>
-rw-r--r--piem-lei.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/piem-lei.el b/piem-lei.el
index 5b986fc..fe6ab79 100644
--- a/piem-lei.el
+++ b/piem-lei.el
@@ -30,10 +30,13 @@
;;;; 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 @@
(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."