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

Allow for custom note titles on obsidian-capture #49

Open
milespossing opened this issue Jul 6, 2023 · 9 comments
Open

Allow for custom note titles on obsidian-capture #49

milespossing opened this issue Jul 6, 2023 · 9 comments

Comments

@milespossing
Copy link

Obsidian.nvim has this feature where you're able to change the note name (specifically the file name) when creating:

    -- Optional, customize how names/IDs for new notes are created.
    note_id_func = function(title)
      -- Create note IDs in a Zettelkasten format with a timestamp and a suffix.
      -- In this case a note with the title 'My new note' will given an ID that looks
      -- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md'
      local suffix = ""
      if title ~= nil then
        -- If title is given, transform it into valid file name.
        suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower()
      else
        -- If title is nil, just add 4 random uppercase letters to the suffix.
        for _ = 1, 4 do
          suffix = suffix .. string.char(math.random(65, 90))
        end
      end
      return tostring(os.time()) .. "-" .. suffix
    end,

(here a note called Hello World would be converted to 202307061244-hello-world.md)

I know that slipbox isn't the most popular style of naming, but I've come to love it myself.

I was wondering if this would be a reasonable addition to your package. I don't have a lot of experience with lisp, but I'm willing to give this addition a shot if you think that it's worth doing (and possible/reasonably implemented in emacs).

@licht1stein
Copy link
Owner

Hi @milespossing, I think it's a good idea as long as it's optional and you can specify this as a setting. Thank you!

@milespossing
Copy link
Author

I'll start hacking (hopefully this weekend) and see what I come up with. I'll target some form of optional obsidian-format-title which can be configured, but defaults to identity

@licht1stein
Copy link
Owner

People normally want either a prefix or a suffix, if I understand correctly. So you can add obsidian-capture-title-prefix and obsidian-capture-title-suffix which default to nil, and can accept options that you want to implement, like 'timestamp, 'uuid etc.

@licht1stein
Copy link
Owner

How do they handle links when there's a prefix?

@milespossing
Copy link
Author

Normally what the nvim plugin does is it adds some front matter with an alias. Here is an example from mine:

---
id: "202306220817-emp-rules-processor-initial-architecture"
aliases:
  - "EMP Rules Processor Initial Architecture"
tags: []
---

# EMP Rules Processor Initial Architecture

In this case the note (or text over which I generated a link) was EMP Rules Processor Initial Architecture. So if I were to create a new link [[EMP Rules Processor Initial Architecture]] this would work (and does work in your package as well).

Some of my notes use the note title or id including the timestamp, others just use the title of the note

@milespossing
Copy link
Author

milespossing commented Jul 6, 2023

As I think of it, this might be a bit larger than simply adding in a prefix... A change like this would require enforcing front matters automatically in any case we would have a prefix/suffix

@licht1stein
Copy link
Owner

Well, if you feel like getting into it you can start with something smaller :)

@milespossing
Copy link
Author

Let me see what I come up with, it would be nice to at very least add a new command which creates new notes with the defined prefix if any. Maybe after a tiny bit of hacking it'll be more clear to me how I can put some of this stuff together and perhaps get a few of the features that I love from the nvim plugin in here

@licht1stein
Copy link
Owner

Sounds like a good plan, let me know if you have any questions :)

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

No branches or pull requests

2 participants