felko / neuron-mode

An emacs mode for editing Zettelkasten notes with neuron
GNU General Public License v3.0
118 stars 21 forks source link

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

Closed TeknikalDomain closed 4 years ago

TeknikalDomain commented 4 years ago

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.

felko commented 4 years ago

Hello, thanks for the precise report.

I can indeed reproduce this bug using the doom-emacs sandbox system, which allows me to have a minimal config enabled. I suspect this has to do with the recent update as described in #39. neuron-mode relies on a completion system which defines the behavior of completing-read. What I think happens here is that the completion function returns the completed raw string itself instead of the propertized string, which includes all the information about the selected zettel (path, id, tags, etc...). What completion package do you use?

It turns out that, after trying multiple autocompletion backends (ivy, helm, and selectrum), only ivy and selectrum seem to work. helm and the default completion system of emacs fail with the same error. It is very likely that the way I implemented the zettel selection is a bit ugly, as it was one of my first lines of emacs lisp. I will investigate to find a better way of implementing the current feature in a way that doesn't rely on particular behavior of ivy/selectrum.

TeknikalDomain commented 4 years ago

I can't remember by exact config (it's been a long time since I touched it) but for testing I stripped everything down to just neuron-mode, a theme, and a few settings to help debugging. For more information, the actual call to map-elt is returning, for default completion, the string <12345678> Zettle Title, which I'm assuming is the cause here, if what I read is correct.

At least the fix seems simple enough - just use Ivy.

felko commented 4 years ago

Yeah using ivy will work presumably. But the whole idea of #39 was to be completely agnostic about the completion package, which is apparently not the case since helm does not support the current implementation of the zettel selection.

TeknikalDomain commented 4 years ago

Update: Ivy does indeed work. Though as I've said before I'm not too famialiar with Emacs Lisp, I can't to much to help.

felko commented 4 years ago

Alright it seems to work in https://github.com/felko/neuron-mode/commit/65a4d4cb603f6272dfc6c01e0debf987a2e7f0f3, but I'm still not satisfied with the implementation. What I would like is to provide a collection of objects to the completing function and a function that renders each object into a string with properties etc... Here I need to render the items before calling completing-read, and then extract again the information that I need when the users picks an element, which I'd like to avoid.

felko commented 4 years ago

After asking in an emacs server, it appears that there are no better solution that is still independent from the completion package.