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

Conversation

Plommonsorbet
Copy link


Hi,

I was migrating all of my bookmarks to buku and in the migration process I ended up wanting to tag a lot of bookmarks so I created a few api functions for this and since this functionality was not in the module I figured I would push it.

I'm new to emacs and lisp so I'm might have missed some coding conventions or general best practice so any feedback regarding it is appreciated.

Some notes regarding my code:

The ebuku--call-buku function seems to have the option to always write to the buffer enabled so I just wrapped my functions with the with-temp-buffer function to not have to do any bigger changes to the overall code to deal with instances where the output of the function doesn't matter.

Also I don't check for any errors in the process since buku doesn't seem to return any exit code other than 0 even when it outputs [ERROR]. I suppose I could try to regexp the output, but I couldn't seem to wrap my head around how the elisp dialect of regex works so I figured I would just leave it as it is for now and get your feedback on it or return to this later with fresh eyes.

@flexibeast
Copy link
Owner

Thanks for your contribution! Overall i like this. :-)

To begin with, i'll leave specific comments on the code as review notes.

ebuku.el Outdated Show resolved Hide resolved
ebuku.el Outdated Show resolved Hide resolved
ebuku.el Outdated
(message "Added tag to bookmark")))

(defun ebuku--tags-join (tags)
"Internal function that joins a list of tags into a comma separated string of tags."
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 a list ..." Also, please wrap docstrings on word breaks so each line is less than 80 characters.

Copy link
Author

Choose a reason for hiding this comment

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

Changed the sentence a little bit so it's less than 80 characters, my linter was complaining that the first line was not a complete sentence when wrapped.

In my vim setup I usually just have a ruler for the 80 character mark that I can toggle but I'd be curious to hear how you deal with seeing if any lines are longer than that or do you have a linter that can do that?

Copy link
Owner

Choose a reason for hiding this comment

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

i use column-enforce-mode to display any characters beyond the 80-character limit in red. :-)

ebuku.el Outdated Show resolved Hide resolved
ebuku.el Outdated Show resolved Hide resolved
ebuku.el Outdated Show resolved Hide resolved
ebuku.el Outdated Show resolved Hide resolved
@Plommonsorbet
Copy link
Author

Hey,

I just wanted to say THANK YOU for taking the time to give me such great feedback! I really appreciate it, especially with naming and documentation conventions. I greatly value clean and uniform code/documentation so I'm trying to learn the generally accepted code and documentation style for elisp so your comments were really helpful!

Copy link
Owner

@flexibeast flexibeast left a comment

Choose a reason for hiding this comment

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

Sorry i've taken so long to get back to you about this! i took on a new role a couple of months ago, so i've been adjusting to that .... and there's also the pandemic, of course. :-P

To fix the indentation at the places i noted, you could use aggressive-indent-mode (which i personally do when editing ELisp).

(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.

((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"

(message "Added tag to bookmark")))

(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."

(error "Tags need to be either a string or list"))))

(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."

"--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."

"--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."

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

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."


(defun ebuku--tags-join (tags)
"Internal function to join a list of 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.

"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.

@Plommonsorbet
Copy link
Author

Heya,

Yeah it's a pretty crazy time so no worries about not getting back right away.

Thanks for the input, I'll get to this in a month. I just have one work week before going on vacation for three weeks and I can definitely feel myself beeing really worn down. So I'm just going to listen to my body right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants