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

feat: use generate_note_filename for renaming notes #345

Conversation

onemoresuza
Copy link
Contributor

@onemoresuza onemoresuza commented Oct 12, 2024

Proposed change

This PR makes so that generate_filename_note is used when renaming notes.

It is now possible to go from a uuid-title/title-uuid to title or uuid or the
other way around -- note that when going from uuid to uuid-title/title-uuid the
old uuid will be used as a title and a new uuid will be created.

It is not possible going from title-uuid to uuid-title or vice-versa, since the
current implementation will consider the old title the new uuid and the old uuid
the new title.

In all cases in which the new implementation is unable to succeed, manual
renaming of the files will be needed.

The following breaking changes are introduced:

  1. Telekasten rename_note now passes only the filename without the uuid for
    the user to edit, while now being affected by filename_space_subst.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Code quality improvements to existing code or addition of tests
  • Documentation update

Additional information

Checklist

  • I am running the latest version of the plugin.
  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • The code has been formatted using Stylua (a .stylua.toml file is provided)
  • The code has been checked with luacheck (a .luacheckrc file is provided)
  • The README.md has been updated according to this change.
  • The doc/telekasten.txt helpfile has been updated according to this change.

@onemoresuza onemoresuza marked this pull request as ready for review October 12, 2024 20:09
@lambtho12
Copy link
Member

I do not really understand the sepsubst stuff. Could you explain a bit more the logic ?

@onemoresuza
Copy link
Contributor Author

I do not really understand the sepsubst stuff. Could you explain a bit more the logic ?

Sure.

It's to ensure that there's only one uuid_sep on the filename. For instance, for a config that has either uuid-title or title-uuid for new_note_filename, when the user calls Telekasten new_note and types my-note-name the filename shall be:

my_note_name-<uuid>

This ensures that the uuid may be retrieved regardless of what is in uuid_type.

@lambtho12
Copy link
Member

I am not a fan of overwriting stuff like that. If the user types the hyphens on purpose, it is reasonable to assume that they want the hyphens and not something else. I feel that this may cause more complaints than anything.

Couldn't we just find the UUID part using some regexes based uuid_type and uuid_sep instead ?

@onemoresuza
Copy link
Contributor Author

We can:

> title_uuid = "name-with-hifens-uuid12"
> uuid_title = "uuid12-name-with-hifens"
> print(title_uuid:match("^(.+)%-(.-)$"))
name-with-hifens	uuid12
> print(uuid_title:match("^(.-)%-(.+)$"))
uuid12	name-with-hifens

Going to update the PR.

@onemoresuza onemoresuza force-pushed the note-rename-use-generate_filename_note branch from 2f3bcd6 to 463f9ba Compare October 16, 2024 11:18
@onemoresuza onemoresuza force-pushed the note-rename-use-generate_filename_note branch from 463f9ba to 98e8d13 Compare October 16, 2024 11:19
@onemoresuza
Copy link
Contributor Author

@lambtho12, I've implemented the regexes based on uuid_type and uuid_sep.

@lambtho12 lambtho12 merged commit 6a10a79 into nvim-telekasten:main Oct 26, 2024
2 checks passed
@lambtho12
Copy link
Member

Great addition. Thank you very much for this PR and for your patience.

If you have some time, you are welcome to work on other opened issues, its always great to see people getting involved when I have very little time to move this project forward myself 😄

@onemoresuza onemoresuza deleted the note-rename-use-generate_filename_note branch October 27, 2024 14:11
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.

[BUG] rename-note doesn't use title config
2 participants