Kungsgeten / org-brain

Org-mode wiki + concept-mapping
MIT License
1.71k stars 103 forks source link

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

Open tumashu opened 3 years ago

tumashu commented 3 years ago

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)))))
Kungsgeten commented 3 years ago

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.

tumashu commented 3 years ago

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

Kungsgeten commented 3 years ago

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.

tumashu commented 3 years ago
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 commented 3 years ago

I will create a new issue about merge.