Skip to content

Conversation

@omar-polo
Copy link
Contributor

From time to time, I'd like to tweak the lyrics fetched from versuri. Maybe it's just a wrong line break, or a typo, or a strange quoting, something like that.

This PR adds a versuri-lyric-edit command that pops a buffer in text-mode where the user can edit the existing buffer. Even better: after save the lyric buffer gets automatically updated :D

It's still a draft, I just noticed that the temporary file used to store the lyric remains and clutters the /tmp.

I'd also like to add a versuri-add-lyric command to manually insert a lyric for those cases where versuri fails to fetch one. (use case: I don't seem to be able to fetch the lyric for "It's the end of the world as we know it (and I feel fine)", but still like to be able to read it using versuri)

Cheers

Extract the "pop edit buffer" logic into its own function
versuri--pop-edit-buffer and reuse it to implement versuri-add-lyric
to type a lyric from scratch.  This also requires
versuri--pop-edit-buffer and versuri-save-lyric to handle a nil lyric
or buffer.
versuri-lyric-edit-meta allows to change the artist and/or song title
of an already saved song.  It's useful to fix typos introduced with
versuri-add-lyric.
Don't delete-lyrics + save-lyric, just to the update in the db.
@omar-polo
Copy link
Contributor Author

I've also added versuri-lyric-edit-meta to change the author and song title, and did a bit of refactoring of my versuri-lyric-edit-meta function to do directly the update in the db instead of adding/removing the row.

Some of this commits could be squashed together if you prefer.

Cheers :)

P.S.: this time I haven't forgot to update the readme :P

P.P.S.: I noticed that the readme don't seem to document the interactive functions, so I haven't documented the lyrics-edit and edit-meta functions, or should I? (no problem, just wondering)

@omar-polo omar-polo marked this pull request as ready for review November 13, 2021 13:46
@mihaiolteanu
Copy link
Owner

mihaiolteanu commented Nov 15, 2021

Awesome!
I haven't thought about this feature. Looks like a nice addition!

Wouldn't it be easier (or more intuitive) to change the lyrics mode to a non-read-only mode?
That way, you can edit the db lyrics directly from the lyrics buffer. True, you would have to change the keybindings (from r to C-r, for example).
I would imagine editing the first line would mean editing the song artist and song name. Currently, - is used to split the two visually, but we can use whatever we like (then you can parse the first line using this char to split the string into artist and song) One question would need to be answering. If the user edits the artist and/or song that already exists in the db, what happens? Add a new entry in the db or modify/replace the existing one? Or allow the user to choose between the two?

If you agree, then maybe you would just need the new interactive function versuri-add-lyric that would just open a normal, but blank lyrics buffer where the user can add whatever. Maybe add placeholders for where the artist, song name and lyrics would go in the new buffer,

[artist] - [song]

[lyrics]

@mihaiolteanu
Copy link
Owner

I noticed that the readme don't seem to document the interactive functions

I might have not noticed some of them?!
Of course, they should be there.

@omar-polo
Copy link
Contributor Author

omar-polo commented Nov 15, 2021 via email

@mihaiolteanu
Copy link
Owner

the rationale was to disallow accidental changes to the lyrics

I understand your point.
First, the user would, somehow, have to not see his accidental changes.
Second, he would have to not know how to undo the buffer.
Third, he would actually have to C-x C-s to change the db, as well. Otherwise, he can answer no when closing an edited buffer.
Worst case, he can re-fetch the lyrics completely new from the web, so nothing is lost for good.

I currently have some binding like n to forward-line and p to previous line in versuri-mode.

Yes, I have that too.
First, how often do you need to move through the lyrics buffer.
Second, with a non-read-only buffer you will have to fall-back to C-n and C-p like in a regular buffer. Would that be (much) worse that simply using n and p.

there's no reason the "-" (or even " - ") can't appear on the artist name or song title

Correct! That is a real concern. If we don't know any artist with - in its name, it doesn't mean it doesn't exist. But, we're the presidents here, we can choose whatever we like :)) |, maybe. Or split the line in two,

[artist]
[song]

[lyrics]

which we may even make the default or mention in the documentation

It looks to me like the Emacs/Lisp/Unix way is to allow the user to do whatever he likes. You can even change the car to point to whatever you like, for example. It is not useful, but nobody is stopping you if you have some crazy ideas. So I would favor this approach. And yes, updating the documentation to let the user know what happens when he opens a lyrics buffer, that he can edit it, that he can modify it and if he doesn't like that he can disable it, is an excellent idea!

I'm not 100% convinced of anything yet. Just floating ideas around. :)

@omar-polo
Copy link
Contributor Author

omar-polo commented Nov 15, 2021 via email

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