diff options
author | Adam Porter <adam@alphapapa.net> | 2024-03-12 16:01:57 -0500 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2024-03-14 12:46:46 +0200 |
commit | c94d680f6eb46a47549633c7076fe32660b3cd42 (patch) | |
tree | a9513a4fe7e84d6886eb85f8951fdec5800ae56c /lisp/emacs-lisp | |
parent | 6d1c1fca0aa7c5a1ff0254af3f89a34d5309ea0d (diff) | |
download | emacs-c94d680f6eb46a47549633c7076fe32660b3cd42.tar.gz emacs-c94d680f6eb46a47549633c7076fe32660b3cd42.tar.bz2 emacs-c94d680f6eb46a47549633c7076fe32660b3cd42.zip |
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)
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/vtable.el | 44 |
1 files 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 @@ 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. |