Subject: bug#69664: Additional patch

From: Adam Porter <[email-masked]>
Date: Tue, 12 Mar 2024 16:06:58 -0500

Hi,

Please see the attached patch, which should be applied on top of the 
previous one.  It handles the case in which the old object is not found 
in the vtable, avoiding calling ELT with a nil position argument.

Thanks,
Adam

From 89df771a910b5d58fc667a85b4ce58a8d7ff94f5 Mon Sep 17 00:00:00 2001
From: Adam Porter <[email-masked]>
Date: Tue, 12 Mar 2024 16:01:57 -0500
Subject: [PATCH] * lisp/emacs-lisp/vtable.el (vtable-update-object): Ensure
 found obj

The OLD-OBJECT may not be found in the table, so SEQ-POSITION may return
nil, in which case ELT should not be called.
---
 lisp/emacs-lisp/vtable.el | 44 +++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/lisp/emacs-lisp/vtable.el b/lisp/emacs-lisp/vtable.el
index 5cf8d8854bb..15a430f5c26 100644
--- a/lisp/emacs-lisp/vtable.el
+++ b/lisp/emacs-lisp/vtable.el
@@ -300,28 +300,28 @@ vtable-update-object
         (error "Can't find the old object"))
       (setcar (cdr objects) object))
     ;; Then update the cache...
-    (let* ((line-number (seq-position (car (vtable--cache table)) old-object
-                                      (lambda (a b)
-                                        (equal (car a) b))))
-           (line (elt (car (vtable--cache table)) line-number)))
-      (unless line
-        (error "Can't find cached object"))
-      (setcar line object)
-      (setcdr line (vtable--compute-cached-line table object))
-      ;; ... and redisplay the line in question.
-      (save-excursion
-        (vtable-goto-object old-object)
-        (let ((keymap (get-text-property (point) 'keymap))
-              (start (point)))
-          (delete-line)
-          (vtable--insert-line table line line-number
-                               (nth 1 (vtable--cache table))
-                               (vtable--spacer table))
-          (add-text-properties start (point) (list 'keymap keymap
-                                                   'vtable table))))
-      ;; We may have inserted a non-numerical value into a previously
-      ;; all-numerical table, so recompute.
-      (vtable--recompute-numerical table (cdr line)))))
+    (if-let ((line-number (seq-position (car (vtable--cache table)) old-object
+                                        (lambda (a b)
+                                          (equal (car a) b))))
+             (line (elt (car (vtable--cache table)) line-number)))
+        (progn
+          (setcar line object)
+          (setcdr line (vtable--compute-cached-line table object))
+          ;; ... and redisplay the line in question.
+          (save-excursion
+            (vtable-goto-object old-object)
+            (let ((keymap (get-text-property (point) 'keymap))
+                  (start (point)))
+              (delete-line)
+              (vtable--insert-line table line line-number
+                                   (nth 1 (vtable--cache table))
+                                   (vtable--spacer table))
+              (add-text-properties start (point) (list 'keymap keymap
+                                                       'vtable table))))
+          ;; We may have inserted a non-numerical value into a previously
+          ;; all-numerical table, so recompute.
+          (vtable--recompute-numerical table (cdr line)))
+      (error "Can't find cached object in vtable"))))
 
 (defun vtable-remove-object (table object)
   "Remove OBJECT from TABLE.
-- 
2.30.2