Subject: bug#38918: 26.3; EBDB fails to edit (add) tags

From: Eric Abrahamsen <[email-masked]>
Date: Sat, 04 Jan 2020 10:55:41 -0800

[email-masked] (Jorge P. de Morais Neto) writes:

>  0x8000078ebdb<return><return>eE
>
> Hello.  I use the latest EBDB (0.6.11) on an updated Spacemacs (develop
> branch) atop GNU Emacs 26.3 on an updated Debian buster.  Emacs was
> installed via GNU Guix.
>
> I cannot add tags to EBDB records.  To help you with reproducing the
> bug, I reproduced it on a GNU Emacs configuration where the only
> customization was augmenting `package-archives' (which I later realized
> was unnecessary) and installing `ebdb'.  I also used a minimal EBDB
> database.  I then inserted a tags field in one record; EBDB did not ask
> for the contents of the field, so an empty tags field was inserted.

Would you please eval the following forms and let me know if everything
works as expected?

(cl-defmethod ebdb-read ((field (subclass ebdb-field-tags)) &optional slots obj)
  (let* ((crm-separator (cadr (assq 'ebdb-field-tags ebdb-separator-alist)))
	 (val (completing-read-multiple
	       (format "Tags (separate with \"%s\"): " crm-separator)
	       ebdb-tags
	       nil nil
	       (when obj (ebdb-string obj)))))
    (cl-call-next-method field (plist-put slots :tags val))))

(cl-defmethod ebdb-fmt-field :around ((_fmt ebdb-formatter-ebdb)
				      (field ebdb-field)
				      _style
				      (_record ebdb-record))
  "Put the 'ebdb-field text property on FIELD.  The value of the
property is the field instance itself."
  (let ((str (cl-call-next-method)))
    (propertize (if (or (null str)
			(string-empty-p str))
		    "<empty>"
		  str)
		'ebdb-field field)))