Skip to content

Commit

Permalink
Fix example in README and docstring around how width actually works
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
Ivan Andrus authored and gvol committed Apr 7, 2024
1 parent 440ed78 commit c558851
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ birth). Every day it will choose a new memento randomly and put it into
`global-mode-string' which is usually displayed in the mode line. There is also
an option to show it in the frame title instead of the global-mode-string.

# Installation
## Installation

Install from [MELPA](https://melpa.org/#/memento-mori).

Expand All @@ -27,7 +27,7 @@ e.g. If you have something like the following in your emacs config
```emacs-lisp
(require 'memento-mori)
(setq memento-mori-mementos
'(("%.2f years old" :since "1970-01-01")))
'(("%.5Y years old" :since "1970-01-01")))
(memento-mori-mode)
```

Expand All @@ -37,7 +37,7 @@ Or using `use-package`:
(use-package memento-mori
:ensure t
:custom (memento-mori-mementos
'(("%.2f years old" :since "1970-01-01")))
'(("%.5Y years old" :since "1970-01-01")))
:config (memento-mori-mode))
```

Expand Down
15 changes: 9 additions & 6 deletions memento-mori.el
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,15 @@ sequences below. They also support all the flags supported by
%F The result of the `:formula' as a float.
%% A literal percent sign.
As shown, most sequences have a upper case and a lower case
version. The lower case versions are truncated to integers since
this is a common use case. The upper case versions return a
float for full control, but will likely require a width or
precision specifier in practice, such as \"%.2Y\" to show the
number of years with two decimal points of precision."
As shown, most sequences have a upper case and a lower case version.
The lower case versions are truncated to integers since this is a common
use case. The upper case versions return a float for full control, but
will likely require a width or precision specifier in practice.
Unfortunately, the width and precision specifiers behave like the
corresponding ones in format when applied to %s, so they define the
width in characters, not the number of decimal places. Therefore,
\"%.5Y\" will show the number of years with two or three decimal points
of precision depending on if it's longer than 10 years or not."
:group 'memento-mori
:type '(repeat (cons
(string :tag "Format string")
Expand Down

0 comments on commit c558851

Please sign in to comment.