help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help making a map-do/seq-do based code work on emacs 26.3


From: Stefan Monnier
Subject: Re: Help making a map-do/seq-do based code work on emacs 26.3
Date: Wed, 04 May 2022 22:20:38 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Kaushal Modi [2022-05-04 14:50:37] wrote:

> Hello,
>
> I recently published the tomelr package on GNU ELPA that can take in a
> plist or alist and return a TOML string.
>
> Now I need to tackle a small problem that makes the package fail at
> run-time only on emacs 26.3 (not on emacs 27+) when a plist is passed
> to its tomelr-encode function.
>
> Recipe to reproduce failure:
>
> 1. Load emacs 26.3
> 2. Install tomelr from GNU ELPA
> 3. (require 'tomelr)
> 4. M-: (tomelr-encode '(:int 123))
>
> Error backtrace
>
> Test test-plist backtrace:
>   #f(compiled-function (pair) #<bytecode 0x313eed>)(:int)
>   mapc(#f(compiled-function (pair) #<bytecode 0x313eed>) (:int 123))
>   seq-do(#f(compiled-function (pair) #<bytecode 0x313eed>) (:int 123))
>   map--do-alist(tomelr--print-pair (:int 123))
>   map-do(tomelr--print-pair (:int 123))

    % grep -C2 plist etc/NEWS.27
    ** map.el
    
    *** Now also understands plists.
    *** Now defined via generic functions that can be extended via 
'cl-defmethod'.
    *** Deprecate the 'map-put' macro in favor of a new 'map-put!' function.
    %

IOW, you need a map that's more recent than the one that comes with Emacs<27.

> - Is there a function or few of them that I can override so that
> (tomelr-encode '(:int 123)) works on emacs 26.3 as well?

You can use something else than the `map` library.  The `map` library in
Emacs-26 doesn't make it easy to extend :-(

> - Can I force install map and seq from GNU ELPA on emacs 26.3?

For `seq`, yes, but `map` is not in GNU ELPA.

> But how can I do that if a user's package.el is installing tomelr.el
> from GNU ELPA as a dependency?

For `seq`, just add the dependency on the corresponding version of `seq`
in `Package-Requires:`.

> Also package.el will refuse to install map and
> seq because they are already present in Emacs 26.3 core.

No, if the builtin package is older, it will (modulo bugs, as always)
install (and use) the version from GNU ELPA.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]