From: Adam Porter <adam@alphapapa.net>
To: 69664@debbugs.gnu.org
Subject: bug#69664: Additional patch
Date: Tue, 12 Mar 2024 16:06:58 -0500 [thread overview]
Message-ID: <863835b0-a5da-4496-8ef1-adadc6ef3b14@alphapapa.net> (raw)
In-Reply-To: <db7c86ca-c937-4a90-80be-2d0b23c6b67a@alphapapa.net>
[-- Attachment #1: Type: text/plain, Size: 227 bytes --]
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
[-- Attachment #2: 0001-lisp-emacs-lisp-vtable.el-vtable-update-object-Ensur.patch --]
[-- Type: text/x-patch, Size: 3235 bytes --]
From 89df771a910b5d58fc667a85b4ce58a8d7ff94f5 Mon Sep 17 00:00:00 2001
From: Adam Porter <adam@alphapapa.net>
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
next prev parent reply other threads:[~2024-03-12 21:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-09 4:39 bug#69664: [PATCH] 29.2; vtable-update-object does not work Adam Porter
2024-03-12 21:06 ` Adam Porter [this message]
2024-03-13 7:58 ` bug#69664: Additional patch Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-14 10:50 ` Eli Zaretskii
2024-03-14 8:49 ` bug#69664: [PATCH] 29.2; vtable-update-object does not work Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=863835b0-a5da-4496-8ef1-adadc6ef3b14@alphapapa.net \
--to=adam@alphapapa.net \
--cc=69664@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.