unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "J.P." <jp@neverwas.me>
To: Philip Kaludercic <philipk@posteo.net>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	 emacs-devel <emacs-devel@gnu.org>,
	 Amin Bandali <bandali@gnu.org>,
	 emacs-erc@gnu.org
Subject: Re: Adding 'compat' from ELPA as an optional dependency to ERC
Date: Mon, 25 Jul 2022 20:04:10 -0700	[thread overview]
Message-ID: <87fsiofuc5.fsf@neverwas.me> (raw)
In-Reply-To: <87bktddnrs.fsf@posteo.net> (Philip Kaludercic's message of "Mon,  25 Jul 2022 18:56:39 +0000")

Philip Kaludercic <philipk@posteo.net> writes:

> "J.P." <jp@neverwas.me> writes:
>
>>                              Although, I believe doing so would also
>> define compat- prefixed variants in all versions of Emacs, the idea
>> being to save third-party packages from having to do stuff like
>>
>>   (defmacro erc-compat--json-parse-string (string &rest args)
>>     `(,(if (fboundp 'compat-json-parse-string)
>>            'compat-json-parse-string
>>          'json-parse-string)
>>       ,string
>>       ,@args))
>
> If a function like this were to be definied upstream
>
>         (defun get-compatibility-func (name)
>           "Return the function NAME of a compatibility alias."
>           (let* ((compat (intern-soft (format "compat-%s" name))))
>             (or (symbol-function (if (fboundp name) name compat))
>                 (error "No definition for %S could be found" name))))
>
> then all that ERC would have to do is
>
>         (defalias 'erc-json-parse-string
>           (get-compatibility-func 'json-parse-string))
>

Nice. That looks really handy.

(BTW, wouldn't a real life `get-compatibility-func' need some extra
pizzazz to favor the prefixed form for certain versions? Because, as
shown, something like (erc-jason-parse-string "42") would still signal a
`json-parse-error' on Emacs 27, no?)

>> But in ERC's case, there'd be no avoiding this kind of indirection.
>> (Please correct me if that's a flawed understanding.)
>
> While prefixing is used, no, because we cannot assume that compat is
> installed.

Right. Makes sense.

So, getting back to the main thrust of this thread, I guess I'll go
ahead and add the proposed changes to Emacs 29, barring any last-minute
objections. Thanks.



  reply	other threads:[~2022-07-26  3:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19 14:43 Adding 'compat' from ELPA as an optional dependency to ERC F. Jason Park
2022-07-19 16:17 ` Stefan Monnier
2022-07-19 16:25   ` Philip Kaludercic
2022-07-19 22:34     ` J.P.
2022-07-25 18:56       ` Philip Kaludercic
2022-07-26  3:04         ` J.P. [this message]
2022-07-26 15:17           ` Philip Kaludercic
2022-07-27 12:55             ` J.P.
2022-07-26 21:00         ` Copying autoloads (was: Adding 'compat' from ELPA as an optional dependency to ERC) Stefan Monnier
2022-07-26 23:00           ` Copying autoloads Philip Kaludercic

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=87fsiofuc5.fsf@neverwas.me \
    --to=jp@neverwas.me \
    --cc=bandali@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-erc@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=philipk@posteo.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).