all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: "J.P." <jp@neverwas.me>
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: Tue, 26 Jul 2022 15:17:50 +0000	[thread overview]
Message-ID: <874jz3aoo1.fsf@posteo.net> (raw)
In-Reply-To: <87fsiofuc5.fsf@neverwas.me> (J. P.'s message of "Mon, 25 Jul 2022 20:04:10 -0700")

"J.P." <jp@neverwas.me> writes:

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

Yes, you are right, I could imagine using an optional argument to
indicate a minimal version.

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

If there are no technical objects, I think the only thing that could be
added would be a comment explaining why compat is used or linking to
this thread.?



  reply	other threads:[~2022-07-26 15:17 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.
2022-07-26 15:17           ` Philip Kaludercic [this message]
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

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

  git send-email \
    --in-reply-to=874jz3aoo1.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=bandali@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-erc@gnu.org \
    --cc=jp@neverwas.me \
    --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.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.