Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADDED new api interfaces for interacting with tags. #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions ebuku.el
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,53 @@ If an argument is excluded, get it from `ebuku-cache-default-args'."
(setq tags (nconc (map-elt bookmark 'tags) tags)))
(setq ebuku-tags (sort (seq-uniq tags) 'string-collate-lessp))))

(defun ebuku-append-tag-to-bookmark ()
"Append tag to bookmark at point."
(interactive)
(ebuku-update-tags-cache)
(let ((tag (completing-read "Append tag? " ebuku-tags))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation for this let.

(index (ebuku--get-index-at-point))
(inhibit-read-only t))
(ebuku--tags-add index tag)
(ebuku-refresh)
(message "Added tag to bookmark")))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add "." to end of message.


(defun ebuku--tags-join (tags)
"Internal function to join a list of TAGS into a comma separated string."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Internal function to join TAGS into a comma-separated string."

(cond ((stringp tags)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation for this cond.

tags)
((listp tags)
(mapconcat 'identity tags ","))
(t
(error "Tags need to be either a string or list"))))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Input must be a string or list of strings"


(defun ebuku--tags-add (index tags)
"Internal function to append TAGS to the list of tags on the INDEX."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Internal function to append TAGS to the tags for INDEX."

(with-temp-buffer
(ebuku--call-buku
`("--update" , index
"--tag", "+" , (ebuku--tags-join tags)))))

(defun ebuku--tags-remove (index tags)
"Internal function to remove TAGS from the list of tags on the INDEX."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Internal function to remove TAGS from the tags for INDEX."

(with-temp-buffer
(ebuku--call-buku
`("--update" , index
"--tag", "-" , (ebuku--tags-join tags)))))

(defun ebuku--tags-set (index tags)
"Internal function to set TAGS on the INDEX.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Internal function to set tags for INDEX to TAGS."


This function does not append to the current list of TAGS it replaces it."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This function is destructive: it does not append to the list of tags, but replaces it."

(with-temp-buffer
(ebuku--call-buku
`("--update" , index
"--tag", (ebuku--tags-join tags)))))

(defun ebuku--tags-clear (index)
"Internal function to clear all tags from INDEX."
(ebuku--tags-set index ""))


;;;###autoload
(define-derived-mode ebuku-mode special-mode "Ebuku"
Expand Down