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

neuron-mode fails to initialize #58

Open
peti opened this issue Aug 11, 2020 · 10 comments
Open

neuron-mode fails to initialize #58

peti opened this issue Aug 11, 2020 · 10 comments
Labels
bug Something isn't working

Comments

@peti
Copy link

peti commented Aug 11, 2020

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?

@felko
Copy link
Owner

felko commented Aug 11, 2020

Normally neuron-mode should be enabled automatically whenever one opens a markdown file in a zettelkasten, assuming the directory has a neuron.dhall file at its root.
However, manually enabling neuron-mode shouldn't give an error, regardless of the existence of neuron.dhall.
Could you provide the backtrace?

@peti
Copy link
Author

peti commented Aug 11, 2020

How do I generate a backtrace?

@felko
Copy link
Owner

felko commented Aug 11, 2020

Running M-x toggle-debug-on-error should open a buffer with the backtrace when an error occurs.

@peti
Copy link
Author

peti commented Aug 11, 2020

I get this error:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  intern(nil)
  #f(compiled-function (zettel) #<bytecode 0x16ce4d1>)(((zettelTags . ["learning"]) (zettelDay . "2020-07-25") (zettelID . "bb86db02") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . [["ZettelQuery_ZettelByID" ["e692b9e8" nil]]]) (zettelFormat . "markdown") (zettelPath . "bb86db02.md") (zettelTitle . "How to Use the Zettelkasten System?") (zettelTitleInBody . t)))
  mapcar(#f(compiled-function (zettel) #<bytecode 0x16ce4d1>) [((zettelTags . ["learning"]) (zettelDay . "2020-07-25") (zettelID . "bb86db02") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . [["ZettelQuery_ZettelByID" ["e692b9e8" nil]]]) (zettelFormat . "markdown") (zettelPath . "bb86db02.md") (zettelTitle . "How to Use the Zettelkasten System?") (zettelTitleInBody . t)) ((zettelTags . ["learning"]) (zettelDay) (zettelID . "e692b9e8") (zettelError (Right . [])) (zettelContent . []) (zettelQueries . []) (zettelFormat . "markdown") (zettelPath . "e692b9e8.md") (zettelTitle . "Using Feynman Notes for Learning") (zettelTitleInBody . t))])
  neuron--rebuild-cache()
  byte-code("\301\010!\203\011\0\302 \210\303\304!\207" [neuron-zettelkasten f-directory\? neuron--rebuild-cache provide neuron-mode] 2)
  autoload-do-load((autoload "neuron-mode" "A major mode to edit Zettelkasten notes with neuron.\n\n(fn)" t nil) neuron-mode)
  command-execute(neuron-mode record)
  execute-extended-command(nil "neuron-mode")
  smex-read-and-run(("toggle-debug-on-error" "neuron-mode" "R" "cd" "5x5" "arp" "dbx" "dig" "erc" "ert" "eww" "ftp" "gdb" "irc" "jdb" "man" "mpc" "pdb" "pwd" "rsh" "sdb" "xdb" "bbdb" "calc" "diff" "dirs" "ffap" "gnus" "grep" "help" "ielm" "info" "life" "mail" "mpuz" "ping" "pong" "smex" "talk" "term" "undo" "yank" "zone" "align" "chmod" "debug" "diary" "dired" "ediff" "edirs" ...))
  smex()
  funcall-interactively(smex)
  #<subr call-interactively>(smex nil nil)
  apply(#<subr call-interactively> smex (nil nil))
  call-interactively@ido-cr+-record-current-command(#<subr call-interactively> smex nil nil)
  apply(call-interactively@ido-cr+-record-current-command #<subr call-interactively> (smex nil nil))
  call-interactively(smex nil nil)
  command-execute(smex)

@felko felko added the bug Something isn't working label Aug 11, 2020
@felko
Copy link
Owner

felko commented Aug 11, 2020

That is odd. I'm almost certain that the compiled function that gives the error is assoc-id defined here:

(defun neuron--rebuild-cache ()
  "Rebuild the zettel cache with the current zettelkasten."
  (let ((zettels (neuron--query-url-command "z:zettels"))
        (assoc-id (lambda (zettel) (cons (intern (map-elt zettel 'zettelID)) zettel))))
    (setq neuron--zettel-cache (mapcar assoc-id zettels))))

But this would mean that (map-elt zettel 'zettelID) returns nil, which sounds impossible given that the list of zettels in te backtrace provide a zettelID field for each entry.

What is the value of neuron-default-zettelkasten-directory? Also, do you have the neuron.dhall file at the root of your zettelkasten?

@peti
Copy link
Author

peti commented Aug 12, 2020

What is the value of neuron-default-zettelkasten-directory?

neuron-default-zettelkasten-directory’s value is "/home/simons/zettelkasten", which is where the zettelkasten lives. I used to have it at ~/src/zettelkasten, but eventually moved it because keeping the directory in a non-default place caused all kinds of trouble with neuron itself, etc.

Also, do you have the neuron.dhall file at the root of your zettelkasten?

Yes, I do:

$ cat neuron.dhall
{ siteTitle     = "Peter Simons' Zettelkasten"
, siteBaseUrl   = Some "http://cryp.to"
}

@peti
Copy link
Author

peti commented Aug 25, 2020

Do you have any idea what might be causing this issue?

@felko
Copy link
Owner

felko commented Aug 25, 2020

Sorry for the late response, unfortunately I wasn't able to reproduce the bug.
Could you try updating both neuron and neuron-mode just to be sure? (<id> links are still supported for now, I'll do wikilinks next)
And then try reproducing the error and backtrace without compiling your config so that I can be sure where the error comes from
Not sure how to run emacs without using the precompiled files though

@peti
Copy link
Author

peti commented Aug 29, 2020

I usually install these Emacs modes via Nix, which means that I get whatever version of these that Nixpkgs currently contains. Nix snapshots ELPA and other repositories every couple of weeks, so it's possible that these versions are not completely up-to-date. Anyhow, the errors I experience come from the Nix-based installation. So I tried something else and installed neuron-mode via package.el in Emacs. Lo and behold, that installation works just fine.

So it's safe to say that this issue is not caused by a bug in neuron-mode itself. Rather, it's some kind of incompatibility between neuron-mode and some older version of some other library that it uses.

@felko
Copy link
Owner

felko commented Aug 29, 2020

I usually install these Emacs modes via Nix

Interesting, how does it work? I think you can also do declarative builds directly in emacs using something like straight (doom emacs configs are more or less declarative for example, it is based on straight). The only issue is that you can't install external software this way.

I'll leave the issue open in case someone finds a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants