Subject: bug#69666: closed (Re: bug#69666: [PATCH] (vtable-update-object): Make old-object argument optional)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 21 Mar 2024 10:46:02 +0000

Your bug report

#69666: [PATCH] (vtable-update-object): Make old-object argument optional

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
69666: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69666
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#69666: [PATCH] (vtable-update-object): Make old-object argument optional
From: Eli Zaretskii <[email-masked]>
To: Adam Porter <[email-masked]>
Cc: [email-masked]
Date: Thu, 21 Mar 2024 12:44:36 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Sat, 16 Mar 2024 23:29:52 -0500
> Cc: [email-masked]
> From: Adam Porter <[email-masked]>
> 
> Thanks, please see the attached patch.

Thanks, installed, and closing the bug.

> For future reference, is there a way to know whether the heading line is
> too long for the ChangeLog entry, other than manually counting?

I suggest to arrange for fill-column to be set in the buffers where
you edit the log messages, then M-q or auto-fill-mode will do this for
you.

Subject: [PATCH] (vtable-update-object): Make old-object argument optional
From: Adam Porter <[email-masked]>
To: [email-masked]
Date: Fri, 8 Mar 2024 23:51:33 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Please see the attached patch which makes `vtable-update-object' easier 
to use in the common case of updating an existing object's 
representation in a table (rather than replacing it with another object).

Thanks,
Adam

From ebb5a2a6ea5bc0437fd39d0e87406fe723183e5a Mon Sep 17 00:00:00 2001
From: Adam Porter <[email-masked]>
Date: Fri, 8 Mar 2024 23:43:14 -0600
Subject: [PATCH] (vtable-update-object): Make old-object argument optional

* lisp/emacs-lisp/vtable.el (vtable-update-object): Make 'old-object'
argument optional.
* doc/misc/vtable.texi (Interface Functions): Update documentation.

It's often necessary to update the representation of a single object in
a table (e.g a struct, whose identity does not change when its slots'
values are changed).  To do so, now the function may be called like
this:

  (vtable-update-object table foo)

Instead of like this:

  (vtable-update-object table foo foo)
---
 doc/misc/vtable.texi      | 7 ++++---
 lisp/emacs-lisp/vtable.el | 7 +++++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/doc/misc/vtable.texi b/doc/misc/vtable.texi
index a4f2ed29d93..f6a2ae05818 100644
--- a/doc/misc/vtable.texi
+++ b/doc/misc/vtable.texi
@@ -554,9 +554,10 @@ Interface Functions
 also updates the displayed table.
 @end defun
 
-@defun vtable-update-object table object old-object
-Change @var{old-object} into @var{object} in @var{table}.  This also
-updates the displayed table.
+@defun vtable-update-object table object &optional old-object
+Change @var{old-object} into @var{object} in @var{table}; or, without
+@var{old-object}, update existing @var{object} in @var{table}.  This
+also updates the displayed table.
 
 This has the same effect as calling @code{vtable-remove-object} and
 then @code{vtable-insert-object}, but is more efficient.
diff --git a/lisp/emacs-lisp/vtable.el b/lisp/emacs-lisp/vtable.el
index 02020552e7f..ae6a5296cef 100644
--- a/lisp/emacs-lisp/vtable.el
+++ b/lisp/emacs-lisp/vtable.el
@@ -283,8 +283,11 @@ vtable-goto-column
       (goto-char (prop-match-beginning match))
     (end-of-line)))
 
-(defun vtable-update-object (table object old-object)
-  "Replace OLD-OBJECT in TABLE with OBJECT."
+(defun vtable-update-object (table object &optional old-object)
+  "Replace OLD-OBJECT in TABLE with OBJECT.
+Without OLD-OBJECT, just update existing OBJECT in TABLE."
+  (unless old-object
+    (setq old-object object))
   (let* ((objects (vtable-objects table))
          (inhibit-read-only t))
     ;; First replace the object in the object storage.
-- 
2.30.2