felko / neuron-mode Goto Github PK
View Code? Open in Web Editor NEWAn emacs mode for editing Zettelkasten notes with neuron
License: GNU General Public License v3.0
An emacs mode for editing Zettelkasten notes with neuron
License: GNU General Public License v3.0
I just wanted to ask if this is strictly necessary. I'm not a user of counsel, actually I use selectrum. Would be great to at least have the option of use other completion systems kindof.
It makes sense?
Currently the output of neuron ... new
commands is read directly and it is not checked whether the command has actually succeeded.
This can lead to new files being created with error messages as file names.
A little spelunking has surfaced an issue or maybe non-issue that I think deserves discussion. There are currently two functions for "adding" tags to a zettel, neuron-add-tag
and neuron-insert-tag
. I can see the differences in both, however I am slightly confused as to their naming versus their intention.
From the naming I would expect add
to add a new tag and insert
to insert and existing tag, though that is not the case. BOTH only query the existing tag set and present them via an ivy-read
call. add
attempts to do the correct thing but doesn't add text for a new tag.
I think a bit of refactoring neuron--select-tag-from-query
is needed to properly return the text if it is a new tag. I am open to working on that, but wanted to open a discussion about the intended functionality before slamming in a PR.
This can use the first title with which the zettle is created, or it can keep the id and the title in sync (which would be cooler but more complex).
Hello, Felko.
I want to thank you for writing this fantastic piece of software. Recently I started to use emacs form my writing workflow. I think neuron-mode it's the one notetaking system that is more closed to my needs but I can't make it work on my doom emacs installation. I think that It'a because after I installed it with the doom emacs especific packages you provide I haven't configured neuron-mode, since I'm not sure where nor how to do it. Is there any link you could recommend for an abdolute noob like me to learn how to configure your package and try running it in my doom emacs?
Thanks in advance and please excude my poor english (it's not my first language.
(I have installed neuron and followed the steps you list in your readme.md. I'm working in MX Linux 19.2 and using emacs 27).
In doom-emacs, C-o is mapped to better-jumper-jump-backward
which has the behavior similar to a browser's back button. It will jump the cursor back to previous search results, or any location the cursor was previously, even in another buffer or file. This doesn't work when traversing zettels in neuron-mode.
What I expect to happen in a history of: (previous file to neuron-mode) -> enter neuron-mode with index.md -> follow link to "thing" zettel at 12345.md -> search for text "text" and jump to first result -> jump second result of "text" -> follow link to "text" zettel.
I would expect C-o, or any command that I can map to C-o in neuron-mode, to be able to exactly reverse this history.
Currently, only moving backward in searches works, without regard to zettel history. If it's possible, making better-jumper-jump-backward
aware of the forward jump when user follows a zettel link should fix the behavior.
Firstly, thanks for the package.
Secondly, can we have custom binary location support for WSL users?
Something like
(setq neuron-binary-location "...."))
I'm not expert on elisp. I look at the code but I can't see anything like that. If it is exit can you put it into Customize setting
part?
Would be nice to have a command to open a zettel by backlink (folgezettel or not) relationship.
srid/neuron#206 can be used today, however a QueryGraph_BacklinksOf
would probably be easier (to shift the processing from emacs to neuron).
When I try to run neuron-new-zettel
Not sure if the problem is with neuron-mode or neuron but I got:
neuron--run-command: Command "neuron --zettelkasten-dir \~/dev/neuron/ query --uri z\:zettels" exited with code 1: neuron: user error (Zettelkasten directory ~/dev/neuron/ does not exist.)
The ~
before /dev/neuron/
might be the problem.
neuron-mode 20200805.1051
I've installed neuron-mode (and the latest neuron) on two machines in the past day and I'm seeing the same issue. Rebuilding the cache always gives a wrong-argument-type. I've done a little testing (not an emacs expert at all), and it looks like emacs is able to call into neuron ok and get a response. To my untrained eye, it almost looks like the JSON returned by neuron has unexpected ID keys. Example stack below.
I'm using the latest neuron (v 0.5.8) - I tried to roll back to earlier version of neuron to test but ran into build issues.
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
intern(nil)
#f(compiled-function (zettel) #<bytecode 0x14753b5>)(((zettelTags . []) (zettelDay . "2020-07-01") (zettelID . "270da4c0") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelTitle . "Test") (zettelTitleInBody . t)))
mapcar(#f(compiled-function (zettel) #<bytecode 0x14753b5>) [((zettelTags . []) (zettelDay . "2020-07-01") (zettelID . "270da4c0") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelTitle . "Test") (zettelTitleInBody . t)) ((zettelTags . []) (zettelDay . "2020-07-01") (zettelID . "2937754d") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelTitle . "Foo10") (zettelTitleInBody . t)) ((zettelTags . []) (zettelDay . "2020-07-01") (zettelID . "2d4a2a74") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelTitle . "Foo") (zettelTitleInBody . t)) ((zettelTags . []) (zettelDay . "2020-07-01") (zettelID . "62a8aa73") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelTitle . "Foo") (zettelTitleInBody . t)) ((zettelTags . []) (zettelDay . "2020-07-01") (zettelID . "87102e41") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelTitle . "foo7") (zettelTitleInBody . t)) ((zettelTags . []) (zettelDay . "2020-07-01") (zettelID . "91c3f4bd") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelTitle . "My first zettel") (zettelTitleInBody . t)) ((zettelTags . []) (zettelDay . "2020-07-01") (zettelID . "a5ebe114") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelTitle . "Flip") (zettelTitleInBody . t)) ((zettelTags . []) (zettelDay . "2020-07-01") (zettelID . "ecfa6007") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelTitle . "Foo3") (zettelTitleInBody . t)) ((zettelTags . []) (zettelDay . "2020-07-01") (zettelID . "ff4784ce") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelTitle . "foo5") (zettelTitleInBody . t))])
neuron--rebuild-cache()
neuron--update-current-zettelkasten("/home/fred/dev/neuron")
neuron-zettelkasten()
neuron-check-if-zettelkasten-exists()
neuron-mode()
funcall-interactively(neuron-mode)
call-interactively(neuron-mode record nil)
command-execute(neuron-mode record)
execute-extended-command(nil "neuron-mode" "neuron-mode")
funcall-interactively(execute-extended-command nil "neuron-mode" "neuron-mode")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
The asciicast demo in the README is a little bit outdated, since it shows the titles overlays as they were displayed by in a previous version (though we can still show the links as in the demo, the default behavior doesn't display the IDs anymore).
It would be nice if one could define template zettels with presets including tags and markdown structure. This could generalize daily notes.
In 09e1f47, I made neuron-refresh
run in a thread to avoid blocking Emacs which isn't necessary. However, I noticed that it slowed down cache regeneration by a very large factor (I don't know how much exactly but easily x10).
I have no idea what is causing this, I don't know how emacs lisp threading works internally.
Unless someone finds a fix for this, we have three options:
neuron-refresh
to be non blocking over being fastHi,
Thanks for all the work on this project.
I'm new to emacs and installed Doom (v2.0.9), emacs (28.0.50), and neuron with nix.
After creating some zettels with SPC z z
, when I try to edit or open them SPC z e
, or SPC z o
, I get:
Edit zettel:
<nil> nil ()
<nil> nil ()
<nil> nil ()
After selecting one of the options nothing happens.
With the elisp repl I found that the issue seems related to the neuron-zettel-cache
ELISP> neuron--zettel-cache
((c4bd7158
(path . "/home/carlos/zettelkasten/c4bd7158.md")
(day . "2020-05-19")
(id . "c4bd7158")
(title . "Index")
(tags .
[]))
(ef1be6a2
(path . "/home/carlos/zettelkasten/ef1be6a2.md")
(day . "2020-05-19")
(id . "ef1be6a2")
(title . "Writing")
(tags .
["writing" "zettelkasten" "note-taking"]))
(26a0709a
(path . "/home/carlos/zettelkasten/26a0709a.md")
(day . "2020-05-10")
(id . "26a0709a")
(title . "ZettelKasten")
(tags .
["notetaking" "zettelkasten" "organization" "writing"])))
The neuron--propertize-zettel
function seems to expect keys in the first element, by using cdr
I got it to work (I know almost nothing about lisp).
(defun cdr-neuron--propertize-zettel (zettel)
(neuron--propertize-zettel (cdr zettel)))
(defun neuron--select-zettel-from-list (zettels &optional prompt)
"Select a zettel from a given list.
ZETTELS is a list of maps containing zettels (keys: id, title, tags, path)
PROMPT is the prompt passed to `ivy-read'."
(let* ((selection
(ivy-read (or prompt "Select Zettel: ")
(mapcar #'cdr-neuron--propertize-zettel zettels)
:caller 'neuron--select-zettel-from-list)))
(get-text-property 0 'zettel selection)))
SPC z e
now gives:
Edit zettel:
<c4bd7158> Index
<ef1be6a2> Writing (writting, zettelkasten, note-taking)
<26a0709a> ZettelKasten (notetaking, zettelkasten, organization, writing)
I would love if you could customize which type of id you want to use with the neuron-new-zettel
command, so you either use --id-hash
, --id-date
or --id <something>
depending on a setting.
Neuron now supports short links like <id>
instead of [id](z:)
Calling the function neuron-toggle-connection-type
on any Zettel link emits the error
Symbol’s function definition is void: map-put!
Luckily the resolution seems straightforward, and I've made a PR to fix this.
I'm using Emacs 26.3, and the issue persisted when launching with emacs -Q
and manually eval-buffer
ing neuron-mode.el
, s.el
, dash.el
, f.el
, and markdown-mode.el
.
I don't know much about emacs plugins, so let me know if this isn't feasible.
I think this is a valid flow:
A
call neuron-insert-new-zettel
, which creates zettel B
and switches to itB
's contentneuron-edit-uplink
and use it to switch back to zettel A
Currently this flow doesn't work because zettel A
isn't saved after the link is inserted, so the plugin doesn't know that it links to B
.
Hi there!
Thanks for all of the effort on this project so far. This is the only emacs zettelkasten I've got to work out of the box.
One feature that I think might be missing, or maybe it is simply a matter of explaining in the docs, is how to use org-mode with neuron-mode.
The reason I bring this up is that of course emacs users tend to love org-mode, and this was one attractive quality of this project as well:
https://www.eliasstorms.net/zetteldeft/
This would be a cool feature, similar to roam. M-x neuron-open-daily-notes
.
%Y-%m-%d.md
if it already existsMight want a customize field for using a predefined tag (I use journal/daily
on my daily notes, so they can be queried from another zettel).
I would like to locally bind this function to a key. I've tried two methods
but get the following error
neuron-toggle-connection-type: Symbol’s function definition is void: map-put!
This seems possibly related to the #53 . The implemented change in ea260a0 enabled me to use the function interactively, but I am unable to bind it.
Would it be possible to change the implementation so that it can be bound?
According to the neuron docs, you can specify an optional host/port to listen on as an alternative to 127.0.0.1:8080.
You can override server settings such as the host and port. For example,
neuron rib -ws 127.0.0.1:8081
Since many things try to use 8080 it would be nice if an alternative could be specified through a config variable or argument to neuron-rib-serve
.
Thank you so much for neuron-mode!
For reference, see this issue in the main neuron repo:
srid/neuron#503
Neuron has added some log messages to the output of neuron query
. This breaks neuron-mode
. I filed an issue with neuron
about this, and now the log messages go to stderr
instead of stdout
. However, because of how neuron-mode
uses call-process-shell-command
, these log messages are still picked up as part of the neuron query
, which breaks neuron-mode
.
I patched my own copy of neuron-mode
in the following way, which fixes the issue when used with the newest version of neuron
:
@@ -297,7 +297,7 @@ URI is expected to have a zquery:/ scheme."
The command is executed as a synchronous process and the standard output is
returned as a string."
(let* ((result (with-temp-buffer
- (list (call-process-shell-command cmd nil t) (buffer-string))))
+ (list (call-process-shell-command (concat cmd " 2>/dev/null") nil t) (buffer-string))))
(exit-code (nth 0 result))
(output (nth 1 result)))
(if (equal exit-code 0)
However, I'm not an expert on emacs lisp, and I imagine there is probably a more idiomatic way of doing this, so I didn't create a PR with that change.
The neuron CLI has changed since srid/neuron#79
I load some zettel from zettelkasten directory into Emacs and it's recognized as markdown-mode
-- not neuron-mode
. So I run M-x neuron-mode
manually, but all I get is the error message:
Wrong type argument: stringp, nil
I'm using GNU Emacs 26.3. Is that a known problem?
I use org-roam to manage my Zettelkasten. Neuron seems like the best tool for rendering a subset of it as HTML. It seems like the missing piece is an Org -> Markdown export that generates Neuron-compatible links from the org-roam links.
The org-roam links look like:
[[file:../example-node.org][Link Text]]
Where the linked file generally has an org title annotation:
#+TITLE: Example Node
Seems like if the export generated a link like
[Link Text](z://example-node)
then the resulting markdown might work with Neuron. Is the numeric link id required for Neuron, or just a convention?
With this export in place, I'd combine it with the org-roam Roam importer to fully migrate off Roam for personal Zettels. FWIW Roam is still great for collaborative Zettelling.
When inserting markdown-style zettel links ([ID](z:/)
), one can annotate the title by doing [ID](z:/title-of-the-zettel-with-that-id)
which makes it more readable, since we don't have to follow the link to figure out why it is there. However, short links cannot be annotated for now, so readers are forced to follow all links to understand the zettel.
It would be better to automatically insert the title using the after-string
text property, which doesn't affect the contents of the buffer at all, only how it is rendered. Switching to neuron-mode should automatically add the title to all links in the buffer.
I have been using neuron-select-zettelkasten
to switch between multiple zettelkastens. Each time, this command prompts me to enter the full path (doom-emacs' auto-completion makes this comfortable).
It would be nice if there was command (neuron-switch-zettelkasten
?) that gave me a list of recently selected zettelkastens. That would be a faster way to switch.
Just like counsel-recentf
behaves.
Would be nice if this prompted for the title of the new zettel. A few times I'd create new zettels by mistake, only having to delete them manually in the command line.
Emacs already autocompletes some (if not all?) IDs by default:
I don't know the mechanism behind it. It did however make me think it would be really nice if that autocomplete popup displayed the actual title of the zettels. So the user can just type some characters from the title (just as they do in neuron search
) of the zettel they want to link to, and Emacs will auto-complete that. It would be a bonus if the user can also directly create and link to a new zettel by typing its title (autocomplete list would be empty, because no existing zettels would match for the new title) and then hitting Enter.
Stealing ideas from Roam:
Maybe related to #58 but these symptoms are different.
My setup: Emacs v26.3, neuron v0.6.10.0, neuron-mode 20200806.833 (installed via melpa).
Zettelkasten exists in ~/.zettlekasten
as the default variable for the location states.
M-x neuron-mode
loads the mode actually but the *Messages*
buffer contains the following:
user-error: Command "neuron --zettelkasten-dir /home/MYSELF/zettelkasten query --uri z\:zettels" exited with code 1: Invalid option `--zettelkasten-dir'
Usage: neuron [--version] [-d PATH] COMMAND
Neuron, future-proof Zettelkasten app <https://neuron.zettel.page/>
It seem as if neuron-mode
is passing the --zettelkasten-dir
option to the neuron
application but that option is unrecognized by it. Strangely enough that line has been in (defun neuron--make-command ...)
for months without giving any pain. What am I missing?
Needless to say both C-c C-z
for neuron-new-zettel
and C-c C-e
for neuron-edit-zettle
produce the same error.
Also sad to see M-x neuron-select-zettelkasten
gone which comes handy for people having zettelkastens on different subjects like quantum mechanics and bean growing.
I have ~/zet
as a symbolic link to another data directory. This works fine for the most part, however when I'm actually in the directory in Emacs (my pwd
is a child of that directory), neuron--get-zettelkasten
returns the unexpanded ~/zet
instead of the full /home/garrett/zet
which would work. I was able to fix this by adding an expand-file-name
around (neuron--detect-zettelkasten pwd)
.
(defun neuron--get-zettelkasten (&optional pwd)
"Return the location of the current zettelkasten.
Assuming the current working directory is PWD, first try to
detect the zettelkasten automatically by traversing the hierarchy
upwards until a neuron.dhall file is found. When no neuron.dhall
file is found, return `neuron-default-zettelkasten-directory'.
Lastly, if the default zettelkasten location doesn't point to
an actual directory, return nil."
(interactive "P")
(or
(expand-file-name (neuron--detect-zettelkasten pwd))
(let ((root neuron-default-zettelkasten-directory))
(and (f-exists? root) (f-directory? root) neuron-default-zettelkasten-directory))))
It's worth noting that doing some debugging shows that pwd
is nil
when neuron--detect-zettelkasten
is called.
This is the error I got when ~/zet
wasn't being expanded: user-error: Command "neuron --zettelkasten-dir \~/zet/ query --uri z\:zettels" exited with code 1: neuron: user error (Zettelkasten directory ~/zet/ does not exist.)
I'd like to define keymaps that would be enabled dynamically based on the tags of the current zettel. I don't know if Emacs allows this kind of thing though. Some ideas here: #55 (comment)
Hooks could also be used to run code when opening a zettel with some tag, or adding this tag on the current zettel.
Emacs version: (standard) GNU Emacs 26.3
Attempting to call neuron-edit-zettel
produces the error: Wrong-type-argument: number-or-marker-p, path
.
Checking with the debugger, this is from line 426, specifically with (map-elt zettel 'path)
.
init.el
(minus adding melpa)neuron-mode
from melpaneuron-edit-zettel
.Note: I'm not 100% famialiar with Emacs debugging. I can give more information if needed but I can't do much investigating on my own.
SPC p f
is projectile-find-file
. Projectile is a project management systems for Emacs. SPC p p
works like SPC z s
(select zettelkasten), but it also prompts to open the first file.
SPC p f
, which allows you to open a file in the current project, however, is slightly different ... in that, if your current active buffer is from some other project, then it will show a list of files in that project (regardless which project you had choosen before).
I work with multiple zettelkastens. I select the Foo zettelkasten; and later I would be editing the Bar zettelkasten. And when I do SPC z e
here, neuron-mode would show me a list of zettels from Foo, when I would have expected it to show me the list from Bar.
This behaviour also affects neuron-follow-thing-at-point
(which pulls zettels from another zettelkasten, despite using the query from a different one).
Currently neuron-rib-open-page
opens a new tab in the browser on localhost
, regardless of whether a rib instance is running.
It could be useful to replace it with a neuron-open-zettel
function that would open the generated HTML page instead when no instance is running.
Currently neuron-refresh-buffer
is used for both regenerating the cache (global) but also to refresh the title overlays displayed next to zettel IDs (local). Switching to an already open zettel buffer does not refresh the titles so neuron-refresh-buffer
would need to be called a second time.
It would be preferable to expose cache regeneration as a global command which would update all buffers in neuron-mode.
I get this error when trying to create new note (I have set the notes path to the one below)
Command "neuron --zettelkasten-dir /Users/USER/Dropbox/notes new Untitled" exited with code 127: zsh:1: command not found: neuron
Any help welcome, thanks.
Implement a counsel-projectile like system for remembering previously used zettelkastens.
A persistent list would store known zettelkastens, from which we would be able to add and remove new ones.
The last edited zettelkasten would be selected at startup.
Syntax is documented here: https://neuron.zettel.page/2011504.html
Basically <...>
is deprecated (still supported) in favour of the new default: [[...]]
as well as [[[...]]]
.
When point is at a zquery URI, neuron-follow-thing-at-point
opens a new buffer named zquery.md
(it could be search.md
or tag.md
depending on where exactly the point is in the URI). It should instead do perhaps one of the following:
neuron-edit-zettel
but filtered to zettels matching the queryI somehow recall that it used to behave like the later?
There is already the nice 'neuron-open-daily-notes' function which makes opening, viewing or editing the days journal note easy, but in order to open up a previously created journal note, you would have to type in the date by hand by inputting month, date year etc.
What would be nice would be a way to go back/forward in time when looking at a journal entry. This would also be nice as a way to just browse in chronological order.
Optionally(maybe preferrably), there could be a function to create a link to the previous/next journal entry so that you could use the links to navigate back and forward in time not only in emacs, but in any client by link clicking
Static files are stored inside a static
directory at the root of zettelkasten directories. It would be convenient to have a command that would first prompt for a file using something like counsel-find-file
, and then insert [](static/path/to/the/file)
.
During SPC m z L
I think this was triggered by srid/neuron#144 (at minimum, I should probably fix this to return non-zero exit code).
MELPA appears to be an Emacs package manager of choice. It would be good to submit zettel-mode to it.
When working with neuron .md files, neuron-mode is by default not enabled, resulting in the need to call M-x neuron-mode, for each file worked on. Maybe this is configurable, though it isn't documented yet on the GitHub page.
For example when calling neuron mode actions such as neuron-create-and-insert-zettel-link, or neuron-open-zettel, it should be possible for the newly opened buffer to already be in neuron-mode
If there is an elisp line that can enable this behavior without just enabling neuron-mode for all .md files, it should be documented as a configuration option.
When clicked, neuron links should trigger neuron-follow-thing-at-point
or open the associated HTML file in the browser.
I've been getting this when creating a new zettel.
My neuron version is 0.6.12.3
user-error: Command "neuron -d /Users/sudeepkumar/open_source/zettelkasten/ new --id-hash test" exited with code 1: Invalid option `--id-hash'
Usage: neuron [--version] [-d PATH] COMMAND
Neuron, future-proof Zettelkasten app <https://neuron.zettel.page/>
I'm having the following assumptions
--id-hash
option went away. It's replaced by ----random-id
, which is also the default.--id-date
option doesn't seem to be supported anymore.I managed to get it working by removing the --id-hash
argument .
I want to confirm my assumptions before I could raise a PR to fix it.
If the above assumptions are correct:
--id-hash
with ----random-id
and that's that.neuron-id-format
) are then either of hash
or prompt
.What do you guys think?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.