all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#69664: [PATCH] 29.2; vtable-update-object does not work
@ 2024-03-09  4:39 Adam Porter
  2024-03-12 21:06 ` bug#69664: Additional patch Adam Porter
  2024-03-14  8:49 ` bug#69664: [PATCH] 29.2; vtable-update-object does not work Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Adam Porter @ 2024-03-09  4:39 UTC (permalink / raw)
  To: 69664

[-- Attachment #1: Type: text/plain, Size: 169 bytes --]

Hello,

Please see the attached patch that fixes the function 
'vtable-update-object', which does not currently work.  With this 
change, it seems to work.

Thanks,
Adam

[-- Attachment #2: 0001-lisp-emacs-lisp-vtable.el-vtable-update-object-Fix.patch --]
[-- Type: text/x-patch, Size: 1152 bytes --]

From 9215bc55416dda1245c75cdb429ec4ad0ed46d20 Mon Sep 17 00:00:00 2001
From: Adam Porter <adam@alphapapa.net>
Date: Fri, 8 Mar 2024 22:28:52 -0600
Subject: [PATCH] * lisp/emacs-lisp/vtable.el (vtable-update-object): Fix

The order of the arguments to 'seq-position' was wrong, and it did not
compare the correct values.
---
 lisp/emacs-lisp/vtable.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/vtable.el b/lisp/emacs-lisp/vtable.el
index 02020552e7f..5cf8d8854bb 100644
--- a/lisp/emacs-lisp/vtable.el
+++ b/lisp/emacs-lisp/vtable.el
@@ -300,7 +300,9 @@ vtable-update-object
         (error "Can't find the old object"))
       (setcar (cdr objects) object))
     ;; Then update the cache...
-    (let* ((line-number (seq-position old-object (car (vtable--cache table))))
+    (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"))
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#69664: Additional patch
  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
  2024-03-13  7:58   ` 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
  1 sibling, 2 replies; 5+ messages in thread
From: Adam Porter @ 2024-03-12 21:06 UTC (permalink / raw)
  To: 69664

[-- 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#69664: Additional patch
  2024-03-12 21:06 ` bug#69664: Additional patch Adam Porter
@ 2024-03-13  7:58   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-03-14 10:50   ` Eli Zaretskii
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-03-13  7:58 UTC (permalink / raw)
  To: Adam Porter; +Cc: 69664

Adam Porter <adam@alphapapa.net> writes:

> Hi,

Hi Adam,

Could you pls keep the subject when replying? I scan new messages wrt to
Emacs bugs via the ML <bug-gnu-emacs@gnu.org>. Neither I know all bug
topics based on the bug number, nor I know what it is about with your
changed subject. So it makes it hard to decide, whether your message
matters to me.

> Thanks,
> Adam

Thanks, and best regards, Michael.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#69664: [PATCH] 29.2; vtable-update-object does not work
  2024-03-09  4:39 bug#69664: [PATCH] 29.2; vtable-update-object does not work Adam Porter
  2024-03-12 21:06 ` bug#69664: Additional patch Adam Porter
@ 2024-03-14  8:49 ` Eli Zaretskii
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2024-03-14  8:49 UTC (permalink / raw)
  To: Adam Porter; +Cc: 69664-done

> Date: Fri, 8 Mar 2024 22:39:42 -0600
> From: Adam Porter <adam@alphapapa.net>
> 
> Please see the attached patch that fixes the function 
> 'vtable-update-object', which does not currently work.  With this 
> change, it seems to work.

Thanks, installed on the master branch, and closing the bug.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#69664: Additional patch
  2024-03-12 21:06 ` bug#69664: Additional patch Adam Porter
  2024-03-13  7:58   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-03-14 10:50   ` Eli Zaretskii
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2024-03-14 10:50 UTC (permalink / raw)
  To: Adam Porter; +Cc: 69664-done

> Date: Tue, 12 Mar 2024 16:06:58 -0500
> From: Adam Porter <adam@alphapapa.net>
> 
> 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, installed, and closing the bug.

Please in the future mention the bug number, when known, in the commit
log message, to avoid the possibility that the committer forgets to
add it.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-14 10:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-09  4:39 bug#69664: [PATCH] 29.2; vtable-update-object does not work Adam Porter
2024-03-12 21:06 ` bug#69664: Additional patch Adam Porter
2024-03-13  7:58   ` 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

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.