/decide-mode

Random decisions for emacs, with functions and a minor mode. Roll various types of dice etc.

Primary LanguageEmacs Lisp

decide-mode.el

Random decisions for emacs, with functions and a minor mode. Roll various types of dice, generate random numbers from ranges, or generate random text from tables. It was mostly inspired by tools and activities related to being a game master in role-playing games, but are in no way restricted to making random decisions in that context.

Results are inserted at point in active buffer if possible, otherwise only echoed in the mini-buffer. The format is intended to make it possible to integrate them in a text being written with decide-mode making it easy to press ? followed by various other keys to quickly get some random result inserted in the buffer. A ? followed by space or enter will just insert the ? itself, so normally decide-mode should not interfere with typing.

The default binding of ? ? (since version 0.7) is decide-dwim-insert, a function that looks in the buffer immediately before point and if it finds a dice or range specification there it will replace it with the result of rolling the dice or picking a random number from the range. If no dice or range is found it will fall back to the normal decide-for-me-normal function that outputs a simple YES or NO result.

See the decide.el file itself for some documentation and a list of all the kebindings in decide-mode.

Example Output

This is what it can look like when typing a text in emacs with decide-mode enabled. All the functions can be called outside of decide-mode as well of course or bound to global shortcuts if you prefer. All the decide-mode shortcuts have ? as a prefix. The keys pressed have been awkwardly inserted in the example text below.

  • Answer yes an no questions. Like this? -> YES (? ?)
  • Roll dice: [2d6] -> (5 1) = 6 (? D)
  • Roll dice with modifier: [2d6+1] -> (5 3) +1 = 9 (? d 2 d 6 + 1 RET)
  • Roll more unusual dice, like FATE/Fudge dice: [4dF] -> (- 0 + +) = 1 (? F)
  • There are several special shortcuts for dice to save you some typing: [1d20] -> = 20 (? 2 0)
  • Draw a cards: [<card>] -> 2 Clubs (? t c a r d RET)
  • Pick a number from a range: [1-10] -> 5 (? r 1 - 1 0 RET)
  • Pick a number from a range, but lower numbers more likely: [1-10 (lowest of 2)] -> 4 (? r 1 < < 1 0 RET)
  • Make lower numbers even more likely by adding more signs: [1-10 (lowest of 4)] -> 1 (? r 1 < < < < 1 0 RET)
  • Of course it works to make higher numbers more likely as well: [1-10 (highest of 3)] -> 9 (? r 1 > > > 1 0 RET)
  • And you can make numbers closer to the center of the range: [1-10 (average of 3)] -> 4 (? r 1 - - - 1 0 RET)
  • Random directions:
  • [(N,S,E,W)] -> N (? w 4)
  • [(N,S,E,W,NE,NW,SE,SW)] -> NW (? w 8)
  • [(forward,left,right,back)] -> right (? W 4)
  • … and a few more like those.
  • Generate strings from silly included example tables: [<example-dragon>] -> 3 ice dragons (? t e x a m p l e - d TAB RET)
  • Another one: [<example-dragon>] -> cute dragon (? t e x a m p l e - d TAB RET)

(The variable decide-tables can be set up with the tables to generate strings from and it can include die-rolls and ranges as well to insert random numbers, and refer to other tables to build up more complex texts.)

Versions

0.5 20160306

  • First public version.

0.6 20170702

  • Custom dice can be added in decide-custom-dice variable.
  • Various minor fixes.

0.6.1 20170703

  • Cleaned up dice-parsing and improved error-handling.

0.6.2 20170703

  • Fixed regression with parsing dice in tables.

0.7 20170703

  • Do What I Mean (dice or range spec before ? ? in buffer)

0.8 TBD

  • Weighted decide-tables

Help

Suggestions and bug-fixes are very much appreciated. This was my first attempt at writing a mode for emacs, and I have very little experience with elisp (or any lisp) in general.

License

Copyright 2016, 2017, 2019 Pelle Nilsson et al

Author: Pelle Nilsson <perni@lysator.liu.se> Version: 0.7

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.