Closed sudeepdino008 closed 3 years ago
Hello, thanks for your PR.
I was finally able to update neuron, to version 0.9.0.0.
It appears that the option ----random-id
isn't supported by recent versions of neuron, as mentionned in https://github.com/felko/neuron-mode/issues/63#issuecomment-699093607.
Instead, the random ID is generated when the command doesn't specify the zettel ID.
@srid is there still a way to specify the title of a new zettel from the CLI? like neuron new --title "A zettel with a random ID"
Just like content, title cannot be specified anymore (unless an explicit ID is passed as an argument of course, in which case title is inferred from the ID, unless one is explicitly set by the user in the note file).
From a UX point of view, apps should prompt for the zettel ID only (allowing the use of random hash), making it clear that ID is basically filename without extension. Title, content, tags, etc. are all up to the user, until templates support get implemented in neuron (then UX can also prompt for template variables, which can include title, among other things).
This is how the new-zettel dialog looks in Cerveau for reference:
Thanks for the clarification!
So title prompts should go away completely, we should only prompt for ID.
Two approaches here that we can take for the neuron-id UX in neuron-mode:
We can merge the 'hash and 'prompt option to present an input prompt like:
ID (press enter to use random id):
The second option is to keep 'hash and 'prompt separate (as it is today):
'hash would ask for no input and directly create a zettel (using random hash) on neuron-new-zettel
'prompt will ask for an id. It can fallback to using random hash if blank string is provided (this is same as 1.)
The first option is same as cerveaus' interface. The second option is slightly more convenient if you only want to use hash. I'm inclined towards the option 1. Let me know if you think differently.
I'd prefer option 2, it's more convenient. For those use title id, edit option to 'prompt
is just a few keystrokes away.
Now that there's a single ID format, we should rename neuron-id-format
to e.g. neuron-id-prompt
which would take some boolean value (if nil it will let neuron generate an unique ID). This is more or less option 2 which I prefer as well.
Since the title can't be generated together with the zettel anymore, the title
argument of zettel creation functions should be removed in some way. This should be straightforward but other features will have to be adapted/removed like the neuron-create-zettel-from-selected-title
command. I suggest we don't bother with that for now and I'll adapt those myself after dogfooding
I will miss neuron-create-and-insert-zettel-link
though. Sadly, it needs title as an input to neuron to work. Now I've to create a new zettel (then add title), then go back in hierarchy, do a neuron-refresh. Only after this I can find/insert the new zettel with title.
Me too, could neuron new
take an optional --title
argument @srid?
I removed the explicit taking of header from neuron new
just to avoid an UX confusion due to use of title ids (and also because level-1 headers are strictly not required in neuron notes). For example, neuron new "Hello world"
creates a zettel file named Hello world.md
. Here, no title needs to be set, as the title is inferred from the filename ("Hello world"). If the user sees --title
, that would be confusing - keeping the semantics of the title id in mind (the whole point of title id is such that one does not have to specify a title in the markdown file content itself). This is not an issue however with random IDs, which is what I presume you folks to be using.
I'm generally happy to change the neuron cli to make the job of editors easier, but I don't like --title
(see above). We could use instead --heading1
(indicating clearly the user is setting level-1 heading in markdown), but at this point I'm thinking -- especially as it has come to setting specific elements of Pandoc AST -- why not just let the user specify whatever Markdown text that will follow the YAML block? As in:
$ echo "# My custom title\n\n" >> $(neuron new)
How complicated is it to do this from emacs?
I plan to release v1 in a few days, so if nothing else can be thought of, we can just add --heading1
in (PR welcome) for your use case. Ultimately I imagine that https://github.com/srid/neuron/issues/328 would supplant all of these cli-hacks.
Ok this should be easy since I open the new zettel in most cases anyway (to add default tags). I could use this to insert the title as well if one is provided. This way the neuron-mode interface doesn't change at all and we can keep neuron-id-format
, and possibly add more formats like 'title
which just passes the title as an ID (since IDs can contains spaces now), or 'slug
, etc... (maybe we should remove 'date
however)
I tried this and it appears to work:
(defun neuron--make-new-command (&optional id title)
(neuron-check-if-zettelkasten-exists)
(unless id
(setq id (pcase neuron-id-format
('prompt
(if-let* ((id (read-string "ID: "))
((neuron--is-valid-id id)))
id
(user-error "Invalid zettel ID: %S" id)))
((pred functionp)
(let ((id (funcall neuron-id-format title)))
(if (neuron--is-valid-id id)
id
(user-error "Invalid zettel ID: %S" id)))))))
(let ((args (if id (list id) nil)))
(apply #'neuron--make-command "new" args)))
...
(defun neuron-create-zettel-buffer (title &optional id no-default-tags)
(interactive (list (read-string "Title: ")))
(neuron-check-if-zettelkasten-exists)
(when (or (not id) (and id (not (neuron--get-cached-zettel-from-id id))))
(let* ((cmd (neuron--make-new-command id title))
(path (neuron--run-command cmd))
(buffer (find-file-noselect path)))
(with-current-buffer buffer
(unless no-default-tags
(dolist (tag neuron-default-tags)
(neuron-add-tag tag)))
(when title
(goto-char (point-max))
(insert title))
(save-buffer))
(neuron--rebuild-cache)
(message "Created %s" (f-filename path))
buffer)))
+ removed the neuron--generate-id-arguments
function.
This only inserts the title as given, without a heading or anything. To implement this properly we would need a format
argument.
We should also relax the neuron--is-valid-id
constraint to any valid filename, and handle this:
“Some note title” is the title ID, corresponding to the note filename Some note title.md, that is generated in the Web interface as the HTML file named Some_note_title.html.
@felko @srid Thanks for the inputs. I've done the following in the PR:
neuron-id-format
can be a function (using slug titles as example)neuron-title-format
which formats the title. This formatted string is then used to populate a new zettel.neuron--is-valid-id
to include spaces (folgezettel links won't work now though because of <filename with spaces>
format).Great! Thanks a lot for your work, and good idea for neuron-title-format
and the example with slug titles.
I'll try to fix the links next.
date
option for neuron-id-format (as it's support is removed from latest neuron)