Subject: bug#38878: 26.3; EBDB fails to mark role as defunct

From: Eric Abrahamsen <[email-masked]>
Date: Sun, 12 Jan 2020 12:54:52 -0800

Jorge P. de Morais Neto <[email-masked]> writes:

> Em [2020-01-02 qui 13:59:08-0800], Eric Abrahamsen escreveu:
>
>> Hi, thanks for the report.  I haven't been able to immediately
>> reproduce this, but I'll take a look over the next couple of days and
>> get back to you.
>
> Hi.  If you could not reproduce the error, then perhaps you did not
> press "E" on the same line as me.  The error occurs when you press "E"
> on the John line *within the ACME record*.  Yesterday I managed to mark
> the role as defunct by pressing "E" on the *organization's reference
> that sits to the right of the person's name*.  It seems that I was
> pressing "E" on the wrong place.  So it appears all you have to do is:
>
> 1. Clarify the manual.
> 2. When the user presses "E" on the role field of a person in the
>    respective organization's record, then EBDB should either just work
>    or at least produce a clear and short error message.

Oh, I see -- you're right I was doing this on the wrong line. Actually
if you edit a role field on an organization using a "little edit" (with
"e"), EBDB does some fancy footwork in the background to actually edit
the role field on the person record. That didn't happen with the
customize edit ("E") -- would you eval the following and confirm that it
works correctly?

(defun ebdb-edit-field-customize (record field)
  "Use the customize interface to edit FIELD of RECORD."
  (interactive
   (list (ebdb-current-record)
	 (ebdb-current-field)))
  (let ((new-field (clone field)))
    (eieio-customize-object new-field)
    ;; If the user is editing a role field from an organization
    ;; record, do a switcharoo.
    (when (and (ebdb-record-organization-p record)
	       (ebdb-field-role-p field))
      (setq record (ebdb-gethash (slot-value field 'record-uuid) 'uuid)))
    ;; The following two variables are buffer-local, and we're hoping
    ;; this will make them local to the customization buffer: ie, an
    ;; arbitrary number of *Customize* buffers can be opened, and the
    ;; accept/apply options will all behave correctly.
    (setq ebdb-customization-field field
	  ebdb-customization-record record)))