Giter Site home page Giter Site logo

neuron-mode's Introduction

MELPA

neuron-mode

neuron-mode is an Emacs major mode derived from markdown-mode to edit notes using the neuron Zettelkasten manager.

drawing
neuron-mode demo in doom emacs

Installation

  1. Install neuron and make sure that the neuron command is in your path.

  2. Install neuron-mode, either via MELPA (recommended) or manually by cloning this repository.

If you are using an emacs distribution like doom emacs or spacemacs, refer to this paragraph to see how neuron-mode can be integrated into your configuration.

Features

All commands are executed in the active zettelkasten which is either detected by traversing the directory hierarchy upwards until a neuron.dhall file is met (see neuron configuration), or otherwise it uses the zettelkasten that is specified by neuron-default-zettelkasten-directory (a path). Although neuron.dhall files are not mandatory to use neuron itself, this is what enables neuron-mode automatically when opening a markdown file. neuron-mode will then cache the zettels and regenerate it when needed (typically when creating a new zettel). Sometimes, when the zettelkasten is modified externally to neuron-mode, you might need to invalidate the cache and rebuild it manually, which is done with the neuron-refresh command. This will also reload the titles displayed next to zettel links (see next paragraph).

Reading

neuron-mode allows you to browse your zettelkasten directly from Emacs. Most importantly, neuron links are shown together with their titles so that you don't need to read the zettel from the associated HTML file anymore.

Navigating

neuron links can also be followed using neuron-follow-thing-at-point. For queries, it will prompt you to select a zettel that match the query under the point.

Navigating "upwards" is also possible, using the neuron-edit-uplink function.

Searching

The neuron-edit-zettel will prompt you with the list of zettels, where you can search by title, by tag or by ID using ivy.

projectile can also be useful as a complement to neuron-mode since it allows you to search the zettelkasten by content.

Editing

You can create new zettels from Emacs, neuron-mode will take care of creating the file with a generated hash in the current active zettelkasten.

Links can be inserted using neuron-insert-zettel-link which will prompt you to select an existing zettel in the active zettelkasten. Zettels can also be linked and created on the fly by using neuron-insert-new-zettel. A third way to insert links, assuming that you use company, is by typing <a few keywords and then running company-neuron. This will show all the zettels whose titles match those keywords. You can enable company-neuron automatically by calling company-neuron-setup which will trigger the autocompletion when you start typing a link. You can enable this globally by adding a hook to neuron-mode: (e.g. (add-hook 'neuron-mode-hook #'company-neuron-setup)).

To avoid typos in tags which might mess up the organization of your zettelkasten, use neuron-add-tag/neuron-add-tags which will allow you to select from already existing tags.

Using rib

Rib commands can be executed from Emacs. Running neuron-rib-generate will compile your zettelkasten to HTML. This can also be done automatically using neuron-rib-watch which will generate every time you save a zettel.

The resulting HTML files can then be accessed either from neuron-mode with neuron-open-current-zettel which will open the HTML that is associated with the zettel being edited, or globally with neuron-open-zettel.

Alternatively, you can use the rib server to read your zettelkasten from your browser. The server can be started using neuron-rib-serve and stopped using neuron-rib-kill. Similar functions are provided to open the zettels in the web app rather than local files (respectively neuron-rib-open-current-zettel and neuron-rib-open-zettel).

Function list

Command Default binding Description
neuron-new-zettel C-c C-z Create a new zettel and open it for edition
neuron-edit-zettel C-c C-e Select an existing zettel and open it for editing
neuron-edit-uplink C-c C-, Select and edit a zettel that links to the current one
neuron-add-tag C-c C-t Select and insert a tag in the current zettel's YAML metadata block
neuron-add-tags C-c C-S-t Same as neuron-add-tag but adds multiple tags simultaneously
neuron-query-tags N/A Select a tag and then a zettel with that tag
neuron-replace-tag N/A Replace a tag by another across the entire zettelkasten
neuron-open-current-zettel C-c C-r Open the current zettel's generated HTML file in the browser
neuron-insert-zettel-link C-c C-l Search a zettel by content and insert the link at point
neuron-insert-new-zettel C-c C-S-l Combine neuron-new-zettel and neuron-insert-zettel-link
neuron-create-and-insert-zettel-link N/A Like neuron-insert-zettel-link but can also create new zettels
neuron-create-zettel-from-selected-title N/A Transform the selected text into a new zettel
neuron-insert-static-link C-c C-s Insert a link to a selected file in the static directory
neuron-toggle-connection-type N/A Toggle the connection type under point, between cf and folgezettel
neuron-open-daily-notes C-c C-o Open today's notes if it exists, or create it otherwise
neuron-refresh C-c C-S-r Regenerate the zettel cache and title overlays in all neuron-mode buffers
neuron-toggle-id-visibility N/A Toggle between showing the titles next to the IDs or over them
neuron-follow-thing-at-point N/A Override markdown-follow-thing-at-point to handle zettel URI protocol
neuron-edit-zettelkasten-configuration N/A Open the neuron.dhall file at the root of the current zettelkasten
neuron-rib-generate N/A Perform a one-off generation of the site
neuron-rib-serve N/A Start the wep application on localhost:8080
neuron-rib-open-z-index N/A Open the web application at localhost:8080/z-index.html
neuron-rib-open-zettel N/A Select and open a zettel note in the web appliation
neuron-rib-kill N/A Kill the web application process
company-neuron N/A Trigger a company tooltip in which you can insert links by autocompleting by title

Configuration

Customize settings

  • neuron-default-zettelkasten-directory (default: "~/zettelkasten)
    Defines the fallback zettelkasten when the current directory is not located in a zettelkasten.
  • neuron-executable (default: neuron)
    Path or wrapper around the neuron executable.
    Example: this can be useful when using Emacs from Windows, while having neuron installed on WSL, in which case you can set neuron-executable to wsl neuron.
  • neuron-generate-on-save (default: nil)
    Generates the site when saving a note. Opens a compilation buffer (neuron-rib-generate)
  • neuron-id-format (default: 'hash)
    Controls the default ID format used when creating new notes.
    It can be set to:
    • 'hash: generates an unique 32 bit UUID (default behavior of neuron)
    • 'prompt: asks for the ID when creating a new zettel
    • a function: generate a custom ID based on the zettel title. (not recommended for actual knowledge based zettelkastens but might be useful for e.g. slugging the titles for documentations) The function has to generate a valid neuron ID.
      Example: If you want to have slug-converted title as ID, you can put the following in .emacs \
      (defun sluggify (title)
       (s-join "-" (split-string (s-downcase title))))
       
      (setq neuron-id-format 'sluggify)
  • neuron-title-format (default: # %s)
    Format string for title of a new zettel. This format string will be run through format (with title as argument) to populate the new zettel.
  • neuron-default-tags (default: nil)
    A list of tags to add to zettels when they are created. This does not affect daily notes.
    Example: stub (to mimic Wikipedia's stubs)
  • neuron-tag-specific-title-faces (default: nil)
    An alist that associates tags to faces, which will appear in the title overlay when a link points to a zettel that has the corresponding tag. Example: '(("stub" hl-todo))
  • neuron-daily-note-id-format (default: "%Y-%m-%d")
    Format that controls the filenames of newly created daily notes
  • neuron-daily-note-title-format (default: "%x")
    The format of titles for new daily notes
  • neuron-daily-note-tags (default: (list "journal/daily"))
    The default tag of daily notes.
  • neuron-rib-server-host (default: localhost) \
  • neuron-rib-server-port (default: 8080)
    The host and port on which the rib server will run
  • neuron-max-completion-width (default: 30)
    The maximum number of columns after which the company completion will truncate the titles to fit the given width.

Other variables

  • neuron-make-title (default: capitalizes the first word)
    A function that is called by neuron-create-zettel-from-selection to transform the text into the actual title of the new zettel.
  • neuron-show-ids (default: nil)
    Whether to show the IDs next to zettel titles, rather than having the titles completely hide them. Can be toggled using neuron-toggle-id-visibility.

Appendix: integration to Emacs distributions

doom-emacs configuration

doom-emacs users can use this configuration to work with neuron-mode:

https://gist.github.com/felko/cdb3fc19b3a60db27eb3c5bd319fc479

(include those files in .doom.d/modules/tools/neuron)

This creates a private module that can then be enabled by inserting neuron under the :tools section of your doom! block (inside your init.el).

Spacemacs integration

A spacemacs layer for neuron-mode along with installation instructions can be found in the LightAndLight/spacemacs-neuron repository.

neuron-mode's People

Contributors

bbigras avatar ednolan avatar felko avatar jomtek avatar jonascarpay avatar pjones avatar prsteele avatar srid avatar sudeepdino008 avatar syohex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neuron-mode's Issues

org-roam export

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.

Neuron-Mode should be able to be automatically enabled

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.

Feature request: Add ability to easily navigate between journal entries

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

Daily notes

This would be a cool feature, similar to roam. M-x neuron-open-daily-notes.

  • Open %Y-%m-%d.md if it already exists
  • Otherwise create it and open.

Might 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).

Feature request: allow specifying host/port to listen on for rib server

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!

Add command for inserting links to static files

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).

Update asciicast to show new features

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).

neuron-follow-thing-at-point opens zquery.md

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:

  • Do nothing
  • Bring up the query results, behaving like neuron-edit-zettel but filtered to zettels matching the query

I somehow recall that it used to behave like the later?

org-mode integration

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/

Error when creating new note

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.

The function `neuron-toggle-connection-type` fails

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-buffering neuron-mode.el, s.el, dash.el, f.el, and markdown-mode.el.

Ignore log messages in output of 'neuron query'

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.

Add mouse support for links

When clicked, neuron links should trigger neuron-follow-thing-at-point or open the associated HTML file in the browser.

neuron-mode fails to initialize

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?

Counsel dep

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?

neuron-edit-zettel fails with wrong-type-argument

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).

Steps to reproduce:

  1. Have a blank init.el (minus adding melpa)
  2. Install neuron-mode from melpa
  3. Attempt to run neuron-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.

Cannot bind neuron-toggle-connection-type

I would like to locally bind this function to a key. I've tried two methods

  1. with use-package and :bind
  2. interactively with M-x local-set-key

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?

Adding new tags

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.

Template zettels

It would be nice if one could define template zettels with presets including tags and markdown structure. This could generalize daily notes.

Maybe the most noob question that can be asked...

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).

Custom binary location support

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?

Another failure when initializing neuron mode

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.

wrong-argument-type when rebuilding cache

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)

Non blocking cache regeneration is very slow

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:

  • forget about the latency, prefer neuron-refresh to be non blocking over being fast
  • go back to blocking implementation
  • make the behavior configurable

Show zettel title next to single-result queries

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.

`neuron-insert-new-zettel` should save the parent before switching to the child

I don't know much about emacs plugins, so let me know if this isn't feasible.

I think this is a valid flow:

  1. In zettel A call neuron-insert-new-zettel, which creates zettel B and switches to it
  2. Fill out the zettel B's content
  3. Call neuron-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.

Navigate "nearby zettels"

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).

Tag specific keymaps

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.

Allow creating new zettels with a custom id

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.

Remember previously selected zettelkastens

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.

Screenshots and asciicasts

Would be nice to have in the README, to visualy demonstrate the neuron-mode features at first glance.

Here's one to begin with:

image

(Or/and we can add them to neuron.zettel.page as a zettel).

main directory symlink

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.)

Link autocomplete by title

Emacs already autocompletes some (if not all?) IDs by default:

image

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:

image

Make cache regeneration global

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.

Fallback on generated HTML when rib is not running

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.

--id-hash and --id-date not supported anymore

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

  1. In the latest neuron, the --id-hash option went away. It's replaced by ----random-id, which is also the default.
  2. Also, --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:

  1. For the first, we can simply replace --id-hash with ----random-id and that's that.
  2. We can probably remove it. The valid id formats (neuron-id-format) are then either of hash or prompt.

What do you guys think?

Detect neuron command failures

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.

can't run `neuron-new-zettel` in dired-mode

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

Quick selecting of a recently chosen zettelkasten

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.

Should `SPC z e` work like `SPC p f`? (projectile)

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).

Open/Edit zettel gives only <nil> nil ()

Hi,
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)

feature request: jump back in history to previous zettel

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.

`SPC z z` - prompt title

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.