1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-09 15:50:40 -08:00

Handle the case where 'vtable-update-object' doesn't find old object

* lisp/emacs-lisp/vtable.el (vtable-update-object): If OLD-OBJECT
is not found, don't call ELT, since SEQ-POSITION may return nil.
(Bug#69664)
This commit is contained in:
Adam Porter 2024-03-12 16:01:57 -05:00 committed by Eli Zaretskii
parent 6d1c1fca0a
commit c94d680f6e

View file

@ -300,28 +300,28 @@ If it can't be found, return nil and don't move point."
(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.