diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2019-01-05 17:01:21 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2019-01-05 17:03:38 +0000 |
commit | ad1425a13e64f794c04707007efcfa52bd620901 (patch) | |
tree | 6f08b6bd47fb3f43604231a9b15264e269e0f6e3 /org-d20.el | |
parent | 3e039465ec5935ed6ceed2b79b6d8acb1b414963 (diff) | |
download | org-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.el | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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))) |