org-brain icon indicating copy to clipboard operation
org-brain copied to clipboard

[Suggest] proper deal with when a nickname is an exist entry.

Open tumashu opened this issue 4 years ago • 5 comments

For example:

(defun eh-org-brain-add-nickname (entry nickname)
  (interactive (list (org-brain-entry-at-pt)
                     (read-string "Nickname: ")))
  (let* ((targets (org-brain--all-targets))
         (nickname-entry (org-brain-entry-from-id
                          (cdr (assoc nickname targets)))))
    (if (not nickname-entry)
        (org-brain-add-nickname entry nickname)
      (when (yes-or-no-p (format "Entry '%s' already exists, merge it to '%s' then delete it? " nickname (nth 1 entry)))
        (org-brain-add-parent entry (org-brain-parents nickname-entry))
        (org-brain-add-child entry (org-brain-children nickname-entry))
        (org-brain-add-friendship entry (org-brain-friends nickname-entry))
        (org-brain-delete-entry nickname-entry t)
        (org-brain-add-nickname entry nickname)))))

tumashu avatar Jul 24 '20 00:07 tumashu

I think it makes sense to have some kind of warning if a user tries to add a nickname which clashes with another entry. I'm not quite sure it makes sense to suggest merging the entries though. I guess that depends on how the user normally uses org-brain.

Kungsgeten avatar Jul 27 '20 08:07 Kungsgeten

The featuer mergeing two entries to one is useful, we shoud provide a command.

tumashu avatar Jul 27 '20 08:07 tumashu

Yes, I agree that it seems useful. However it should probably also consider text, resources, attachments, etc since an entry doesn't only consist of its title and relationships.

Kungsgeten avatar Jul 27 '20 08:07 Kungsgeten

However it should probably also consider text, resources, attachments, etc since an entry doesn't only consist of its title and relationships.

I agree :-)

tumashu avatar Jul 27 '20 08:07 tumashu

I will create a new issue about merge.

tumashu avatar Jul 31 '20 00:07 tumashu