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

Small fixes, denote-rename-file-using-front-matter and signature line only when there is a value #484

Conversation

jeanphilippegg
Copy link
Contributor

In this pull request:

  • denote-front-matter-components-present-even-if-empty-value
    defaulting to '(title keywords date identifier). The signature is
    not included so things should keep working as before for users.

  • Fixed smalls issues in denote--get-file-components-for-rewrite and
    denote-rewrite-front-matter.

  • Moved the backlinks check in denote--rename-file.

  • Refactored denote-rename-file-using-front-matter. It was not
    handling all front matter components. Though it was a general issue,
    I think you noticed it when trying to integrate markdown-obsidian.
    It should work now. Check its docstring!


markdown-obsidian

I have seen your obsidian branch. I have two small comments:

1- The denote-*-key-regexp should not be empty strings for the
missing components, or else it will match. The default value ensures
that there is no match.

2- #'identity is not a suitable function for the
denote-keywords-value-function and denote-date-value-function. The
reason is that the functions should take a list or a date object as
input and return a string for the front matter. #'identity does not
do that. I know I gave this example in a previous comment. I realized
it was not valid when I tried to give them default values. It may work
anyway because there is no date or keywords in the front matter
template.

So, a correct definition would be:

(add-to-list
 'denote-file-types
 '(markdown-plain
   :extension ".md"
   :front-matter "# %s\n\n"
   :title-key-regexp "^# "
   :title-value-function identity
   :title-value-reverse-function identity
   :link denote-md-link-format
   :link-in-context-regexp denote-md-link-in-context-regexp))

@jeanphilippegg
Copy link
Contributor Author

Just pushed one last commit.

Ready to be merged!

@jeanphilippegg jeanphilippegg force-pushed the denote-rename-file-using-front-matter branch 2 times, most recently from 3f7a268 to 6caa664 Compare November 23, 2024 16:03
@jeanphilippegg
Copy link
Contributor Author

I refactored denote--format-front-matter to remove lines with empty
values (if necessary) from new front matters.

I rebased the branch on top of main.

I think this completes these issues: #474, #366 and #278.

@protesilaos protesilaos merged commit bf07d3f into protesilaos:main Nov 26, 2024
@protesilaos
Copy link
Owner

Merged, thank you!

I have seen your obsidian branch.

Thank you for the comments! I realised I was using an older version of Denote, which was messing up with my experiment. I just pushed it to the branch to not lose my progress. Will pick it up again as soon as possible.

@jeanphilippegg jeanphilippegg deleted the denote-rename-file-using-front-matter branch November 30, 2024 16:53
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