From 7373fded305e44b712f483a234c50a3fc70172ec Mon Sep 17 00:00:00 2001 From: Ivan Andrus Date: Sat, 6 Apr 2024 20:05:46 -0500 Subject: [PATCH] Fix example in README and docstring around how width actually works Fixes #25 --- README.md | 6 +++--- memento-mori.el | 15 +++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8a5c530..6a949f6 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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) ``` @@ -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)) ``` diff --git a/memento-mori.el b/memento-mori.el index 6935838..3210d5e 100644 --- a/memento-mori.el +++ b/memento-mori.el @@ -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")