bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#70664: 29.3; vtable-insert-object cannot insert at top of table


From: Joost Kremers
Subject: bug#70664: 29.3; vtable-insert-object cannot insert at top of table
Date: Thu, 02 May 2024 12:12:21 +0200
User-agent: mu4e 1.12.2; emacs 29.3

On Thu, May 02 2024, Adam Porter wrote:
> To be clear, I don't plan to work on this anytime soon.  :)

No problem. I would kinda like to give it a try myself, but I'm not going to
make any promises, either. :-)

> Beyond that, IMHO it might be good to write a function with a different
> signature that would allow more flexibility, e.g.
>
> (cl-defun vtable-add (object table &key after before at)
>   "Add OBJECT to TABLE at specified position.
> AFTER may be an object after which to insert it; or BEFORE may be an object
> before which to insert it; or AT may be an integer position at which to insert
> the object, 0 meaning first and -1 meaning last (only one of these three
> arguments should be given).")

I personally don't like the "only one of these three arguments should be given"
part (what happens if more than one are given?), so perhaps a different
suggestion:

(defun vtable-add (object table &optional position before)
   ...)

with POSITION being either an object or an integer. If an object, BEFORE being
non-nil would mean "insert before POSITION", and nil would mean "insert after
POSITION"). If POSITION is an integer, BEFORE is simply ignored. (With this
signature, vtable-insert-object could actually be aliased to vtable-add.)

Though I admit your suggestion has the advantage of explicit keywords.

Do let me know which approach you prefer, in case I do decide to give it a try.

-- 
Joost Kremers
Life has its moments





reply via email to

[Prev in Thread] Current Thread [Next in Thread]