unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
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	[thread overview]
Message-ID: <jwvzgjwbu66.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: CAFyQvY3QjiftXzC7XOFp5jq8KhrCRfq2tSL5=MAgqA1Qm2MLCQ@mail.gmail.com

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




  parent reply	other threads:[~2022-05-05  2:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04 18:50 Help making a map-do/seq-do based code work on emacs 26.3 Kaushal Modi
2022-05-04 19:20 ` Emanuel Berg
2022-05-05  2:20 ` Stefan Monnier via Users list for the GNU Emacs text editor [this message]
2022-05-05 16:24 ` Kaushal Modi
2022-05-05 18:32   ` Stefan Monnier
2022-05-05 21:23     ` Kaushal Modi
2022-05-05 21:33       ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvzgjwbu66.fsf-monnier+emacs@gnu.org \
    --to=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).