aboutsummaryrefslogtreecommitdiff
path: root/org-d20.el
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-01-05 17:01:21 +0000
committerSean Whitton <spwhitton@spwhitton.name>2019-01-05 17:03:38 +0000
commitad1425a13e64f794c04707007efcfa52bd620901 (patch)
tree6f08b6bd47fb3f43604231a9b15264e269e0f6e3 /org-d20.el
parent3e039465ec5935ed6ceed2b79b6d8acb1b414963 (diff)
downloadorg-d20-ad1425a13e64f794c04707007efcfa52bd620901.tar.gz
shorten the display of rolls to minimise minibuffer-stretching
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'org-d20.el')
-rw-r--r--org-d20.el12
1 files changed, 10 insertions, 2 deletions
diff --git a/org-d20.el b/org-d20.el
index 68aa4e1..cdb9c8b 100644
--- a/org-d20.el
+++ b/org-d20.el
@@ -270,11 +270,19 @@ Accepts roll20's extension for rolling multiple dice and keeping
the best N of them, e.g., 4d6k3."
(interactive "sRoll: ")
(setq org-d20-roll--last exp)
- (-let [(rolls . result) (org-d20--roll exp)]
+ (-let* (((rolls . result) (org-d20--roll exp))
+ (result* (int-to-string result)))
;; if `rolls' contains no spaces then we just rolled a single
;; dice, so don't show the intermediate calculation
(if (s-contains? " " rolls)
- (message "%s = %s = %s" exp rolls (int-to-string result))
+ ;; if the frame is not wide enough to show the full result,
+ ;; strip out the spaces in the hope that it will fit
+ (let ((rolls-display (if (>
+ (+ (length exp) 3 (length rolls) 3 (length result*))
+ (frame-width))
+ (s-replace " " "" rolls)
+ rolls)))
+ (message "%s = %s = %s" exp rolls-display result*))
(message "%s = %s" exp (int-to-string result))))
(when org-d20-dice-sound
(play-sound-file org-d20-dice-sound)))