From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Thomas Fitzsimmons <fitzsim@fitzsim.org>, 58531@debbugs.gnu.org
Subject: bug#58531: 29.0.50; Wrong predicate used by map-elt gv getter
Date: Sun, 16 Oct 2022 01:41:54 +0300 [thread overview]
Message-ID: <87wn906765.fsf@tcd.ie> (raw)
In-Reply-To: <jwvwn91jecm.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 15 Oct 2022 11:52:27 -0400")
Stefan Monnier [2022-10-15 11:52 -0400] wrote:
>> (defun map--plist-delete (map key)
>> (let ((tail map) last)
>> @@ -346,7 +399,7 @@ map-contains-key
>> If MAP is an alist, TESTFN defaults to `equal'.
>> If MAP is a plist, `plist-member' is used instead."
>> (if (map--plist-p map)
>> - (plist-member map key)
>> + (map--plist-member map key testfn)
>> (let ((v '(nil)))
>> (not (eq v (alist-get key map v nil (or testfn #'equal)))))))
>
> Hmmm looks like we forgot to mark the `testfn` arg obsolete here with
> `advertised-calling-convention` like we did for `map-elt`.
> Could you fix that oversight in your patch while you're at it?
Sure, but generic functions don't play well with
advertised-calling-convention: each subsequent cl-defmethod overwrites
the preceding symbol-function, so any existing entry in
advertised-signature-table is no longer found after that.
What would you propose doing? Call set-advertised-calling-convention
after the last cl-defmethod in map.el and hope no third-party code
defines a new method? It's not ideal, but it's better than what we
currently have.
Or is there some other trick we can employ that works in Emacs 26+?
>> -(defun eudc-plist-member (plist prop)
>> - "Return t if PROP has a value specified in PLIST."
>> - (if (not (= 0 (% (length plist) 2)))
>> +(defun eudc--plist-member (plist prop &optional predicate)
>> + "Like `plist-member', but signal on invalid PLIST."
>> + ;; Could also use `plistp', but that would change the error.
>> + (or (zerop (% (length plist) 2))
>> (error "Malformed plist"))
>> - (catch 'found
>> - (while plist
>> - (if (eq prop (car plist))
>> - (throw 'found t))
>> - (setq plist (cdr (cdr plist))))
>> - nil))
>> + (plist-member plist prop predicate))
>
> The current error is poor (it doesn't include the offending plist, for
> example), so I think changing it (e.g. using the usual
> `wrong-type-argument` error) would be for the better.
> I do wonder whether it's worth the trouble keeping the error here, tho,
> instead of just using `plist-member` directly.
I was just being conservative, because I don't know where EUDC might get
its data from, or how important it is to catch dubious plists
red-handed.
I'd be happy to simplify the code, but let's see if Thomas (CCed) has
any comments. Thomas, the patch touching eudc.el can be found at:
https://bugs.gnu.org/58531#8.
Thanks,
--
Basil
next prev parent reply other threads:[~2022-10-15 22:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 21:45 bug#58531: 29.0.50; Wrong predicate used by map-elt gv getter Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-14 21:54 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-15 10:33 ` Lars Ingebrigtsen
2022-10-15 13:18 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-16 7:41 ` Lars Ingebrigtsen
2022-10-15 15:52 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-15 22:41 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-10-15 23:31 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-16 11:15 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-16 16:06 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-22 15:01 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-22 15:59 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-22 16:58 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-22 18:04 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=87wn906765.fsf@tcd.ie \
--to=bug-gnu-emacs@gnu.org \
--cc=58531@debbugs.gnu.org \
--cc=contovob@tcd.ie \
--cc=fitzsim@fitzsim.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.
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).