From: Kristoffer Balintona <krisbalintona@gmail.com>
To: emacs-devel@gnu.org
Subject: Should vtable-goto-object use 'equal instead of 'eq?
Date: Sat, 16 Nov 2024 22:48:57 +0100 [thread overview]
Message-ID: <CANVbq5kjPpCKwMBSYfHHLMFXAX7vAgy+D=uLAwJoTGQ5cLSjFQ@mail.gmail.com> (raw)
Hello,
I have been using vtable.el for a project of mine and have come across a
bit of an undesirable design choice in vtable, namely, in
vtable-goto-object. Its definition on master is as follows:
(defun vtable-goto-object (object)
"Go to OBJECT in the current table.
Return the position of the object if found, and nil if not."
(let ((start (point)))
(vtable-beginning-of-table)
(save-restriction
(narrow-to-region (point) (save-excursion (vtable-end-of-table)))
(if (text-property-search-forward 'vtable-object object #'eq)
(progn
(forward-line -1)
(point))
(goto-char start)
nil))))
The relevant line is the one calling text-property-search-forward. I am
wondering whether using equal instead of eq as the predicate is
preferable.
Take the following example. The objects in a given vtable are strings.
For whatever reason, I would like to go to the vtable object
corresponding to the string "foo." I call (vtable-goto-object "foo") but
it returns nil (does nothing). The reason is because vtable-goto-object
uses eq instead of equal. This same situation occurs regardless of what
kind of objec the vtable uses.
As far as I can think of, the only way to productively use
vtable-goto-object is if the objects are stored in e.g. a variable and
referenced within that variable somehow, which is a significant
constraint.
The only case where eq would be desirable is if the vtable contains
duplicate objects, that is, objects which return t on equal but nil on
eq. With these cases in mind, would it be best for vtable-goto-object to
have as a parameter the predicate used by text-property-search-forward
(the default being eq)?
--
Best,
Kristoffer
next reply other threads:[~2024-11-16 21:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-16 21:48 Kristoffer Balintona [this message]
2024-11-16 22:57 ` Should vtable-goto-object use 'equal instead of 'eq? Adam Porter
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='CANVbq5kjPpCKwMBSYfHHLMFXAX7vAgy+D=uLAwJoTGQ5cLSjFQ@mail.gmail.com' \
--to=krisbalintona@gmail.com \
--cc=emacs-devel@gnu.org \
/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).