Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

use-package configuration for calc not run at startup

14 views
Skip to first unread message

Loris Bennett

unread,
Aug 8, 2023, 5:47:51 AM8/8/23
to
Hi,

In my initialisation for Emacs I have:

(use-package calc
:demand t
:custom
(math-additional-units
'((bits nil "bits")
(B "8 * bits" "Bytes")

;; Decimal units
(kB "1000 B" "kilobyte")
(MB "1000^2 B" "megabyte")
(GB "1000^3 B" "gigabyte")
(TB "1000^4 B" "terabyte")
(PB "1000^5 B" "petabyte")
(EB "1000^6 B" "exabyte")
(ZB "1000^7 B" "zettabyte")
(YB "1000^8 B" "yottabyte")

;; Binary units
(KiB "1024 B" "kibibyte")
(MiB "1024^2 B" "mebibyte")
(GiB "1024^3 B" "gibibyte")
(TiB "1024^4 B" "tebibyte")
(PiB "1024^5 B" "pebibyte")
(EiB "1024^6 B" "exbibyte")
(ZiB "1024^7 B" "zebibyte")
(YiB "1024^8 B" "yobibyte")))
:config
(setq math-units-table nil))

However, this seems never to be run when Emacs is started, as calc is
unaware of units thus defined. However, the code before and after the
calc configuration is run. If I then go to the initialisation file and
explicitly eval the above code, everything works as expected.

Can anyone see what I am doing wrong?

Cheers,

Loris

--
This signature is currently under constuction.

Garjola Dindi

unread,
Sep 15, 2023, 1:30:36 PM9/15/23
to

Hi,

Would replacing :custom by :init work?

--

Loris Bennett

unread,
Jan 3, 2024, 3:25:51 AMJan 3
to
Garjola Dindi <gar...@garjola.net> writes:

> Hi,
>
> Would replacing :custom by :init work?

The replacement on its own didn't work, but the following did:

(use-package calc
:defines (math-additional-units math-units-table)
:init
(setq math-additional-units
'((bits nil "bits")
(B "8 * bits" "Bytes")

;; Decimal units
(kB "1000 B" "kilobyte")
(MB "1000^2 B" "megabyte")
(GB "1000^3 B" "gigabyte")
(TB "1000^4 B" "terabyte")
(PB "1000^5 B" "petabyte")
(EB "1000^6 B" "exabyte")
(ZB "1000^7 B" "zettabyte")
(YB "1000^8 B" "yottabyte")

;; Binary units
(KiB "1024 B" "kibibyte")
(MiB "1024^2 B" "mebibyte")
(GiB "1024^3 B" "gibibyte")
(TiB "1024^4 B" "tebibyte")
(PiB "1024^5 B" "pebibyte")
(EiB "1024^6 B" "exbibyte")
(ZiB "1024^7 B" "zebibyte")
(YiB "1024^8 B" "yobibyte")))
(setq math-units-table nil))

The main issue seems to have been that the 'setq' in front of
'math-additional-units' was missing in my original configuration.
0 new messages