b19fb823431e50d98445f78bf0d150c29beb5fee — Kisaragi Hiu 1 year, 5 months ago 252bae1
collection dedupe function
1 files changed, 12 insertions(+), 0 deletions(-)

M yabookmark.el
M yabookmark.el => yabookmark.el +12 -0
@@ 56,13 56,25 @@
(cl-defstruct yabookmark-bookmark
  name path position)

(defun yabookmark-bookmark-equal-p (b1 b2)
  "Are bookmarks B1 and B2 equal to each other?

Bookmarks with the same name but different paths are considered
  (and (equal (yabookmark-bookmark-position b1)
              (yabookmark-bookmark-position b2))
       (equal (yabookmark-bookmark-name b1)
              (yabookmark-bookmark-name b2))))

;; data type: a collection of bookmarks
(defun yabookmark-collection (&rest bookmarks)
  "Return a collection of BOOKMARKS."

(defun yabookmark-collection-dedupe (collection)
  "Remove duplicate bookmarks in COLLECTION."
  (cl-remove-duplicates collection :test #'yabookmark-bookmark-equal-p))

;;;; Working with bookmarks & bookmark lists

(defun yabookmark-set (bookmark collection)