[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#71415: 30.0.50; vtable-current-object off by one
From: |
Eli Zaretskii |
Subject: |
bug#71415: 30.0.50; vtable-current-object off by one |
Date: |
Mon, 17 Jun 2024 19:24:18 +0300 |
> From: john muhl <jm@pub.pink>
> Cc: Eli Zaretskii <eliz@gnu.org>, 71415@debbugs.gnu.org
> Date: Mon, 17 Jun 2024 08:35:50 -0500
>
> Adam Porter <adam@alphapapa.net> writes:
>
> > Hi Eli, John,
> >
> > My first thought i> Hi Eli, John,
> >
> > On 6/15/24 03:40, Eli Zaretskii wrote:
> >>> From: john muhl <jm@pub.pink>
> >>> Date: Fri, 07 Jun 2024 09:15:07 -0500
> >>>
> >>> After updating an object, ‘vtable-current-object’ in the displayer
> >>> and formatter functions points to the object after the one that
> >>> was updated. Running the following:
> >>>
> >>> (with-current-buffer (get-buffer-create "vtable-demo")
> >>> (require 'vtable)
> >>> (erase-buffer)
> >>> (make-vtable
> >>> :columns '("Index" "Number")
> >>> :objects `((1 ,(random)) (2 ,(random)) (3 ,(random)))
> >>> :displayer (lambda (value &rest _)
> >>> ;; vtable-current-object is off by one; e.g.
> >>> ;; update the first row and v-c-o will be the second
> >>> row;
> >>> ;; update the final row and v-c-o will be nil.
> >>> (message "%s %s" value (vtable-current-object))
> >>> (propertize (number-to-string value) 'face 'vtable)))
> >>> (let* ((table (vtable-current-table))
> >>> (first (nth 0 (vtable-objects table)))
> >>> (other (nth 1 (vtable-objects table)))
> >>> (final (nth 2 (vtable-objects table))))
> >>> (setf (nth 1 first) 1)
> >>> (setf (nth 1 other) 2)
> >>> (setf (nth 1 final) 3)
> >>> (vtable-update-object table first)
> >>> (vtable-update-object table other)
> >>> (vtable-update-object table final)))
> >>>
> >>> I see in the messages buffer:
> >>>
> >>> 1 (2 2) [2 times]
> >>> 2 (3 3) [2 times]
> >>> 3 nil [2 times]
> >>>
> >>> when I expect to see:
> >>>
> >>> 1 (1 1) [2 times]
> >>> 2 (2 2) [2 times]
> >>> 3 (3 3) [2 times]
> >> Adam, any comments or suggestions?
> >
> s that this code had some changes recently, and the
> > bug report indicates that the version of Emacs used was compiled from
> > revision f2309557ff366a81183859bda88b9a0012a5d9d6, but I can't find
> > that in emacs.git/master. So I'd suggest trying to reproduce it with
> > a build of Emacs from master after the related changes.
> >
> > Secondly, it seems likely to be a violation of intent to call
> > `vtable-current-object' inside the table's displayer function. I
> > don't think that function is intended to be used within the process of
> > updating a vtable. It's intended to be used from outside vtable code
> > to find what object's representation point is on in a vtable.
> >
> > So if it works correctly in that case but not in this apparently
> > contrived one, I doubt that this would indicate a bug. And in that
> > case, I'd suggest that we be told what the user is actually trying to
> > accomplish, in case there's a real bug elsewhere that was
> > "rabbit-trailed" into a misunderstanding here. :)
> >
> > Thanks,
> > Adam
>
> Right. It’s my mistake. Sorry for the bother.
No sweat.
So should we now close this bug?