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

Symbol’s value as variable is void: org-brain-poly-hostmode when ein:jupyter-server-start #384

Closed
hwiorn opened this issue Feb 13, 2023 · 10 comments · Fixed by #385 · May be fixed by #386
Closed

Symbol’s value as variable is void: org-brain-poly-hostmode when ein:jupyter-server-start #384

hwiorn opened this issue Feb 13, 2023 · 10 comments · Fixed by #385 · May be fixed by #386

Comments

@hwiorn
Copy link
Contributor

hwiorn commented Feb 13, 2023

ein uses poly-mode. But if org-brain is enabled, ein can't run server or notebook because of Symbol’s value as variable is void: org-brain-poly-hostmode

Is there some workaround?

I've not met any Symbol’s value as variable is void: org-brain-poly-hostmode issue before when I use org-brain only.

@hwiorn
Copy link
Contributor Author

hwiorn commented Feb 17, 2023

@Kungsgeten
Current polymode implementation of org-brain doesn't be executed on both Emacs 28.2 and Emacs 30.x with nativecomp.

I found a workaround.
org-brain needs to be changed with-eval-after-load blocks for helm, ivy and polymode like this.

(with-eval-after-load 'polymode ;; instead of "polymode"

After changes, org-brain-polymode works without any conflicts with ein and org-brain itself.
I think using with-eval-after-load itself in a package doesn't be a recommended way, though.
This issue seems to be related to #350, #352.

@hwiorn
Copy link
Contributor Author

hwiorn commented Feb 19, 2023

@Kungsgeten
Sorry. I noticed #385 doesn't fix this issue. My test was wrong.

I found out the root cause of Symbol’s value as variable is void: org-brain-poly-hostmode error is related with bytecompile and with-eval-after-load clause. That's why the fix of #352 needs doing without bytecompile.

Check this link: https://lists.gnu.org/archive/html/emacs-devel/2018-03/msg00559.html

In #386, I removed with-eval-after-load and splitted org-brain.el into three parts: ivy, helm and polymode. So user can use that packages according to their needs in their init.el.

  (use-package org-brain :ensure t   
    :init
    (setq org-brain-path "directory/path/where-i-want-org-brain")
    ;; For Evil users
    (with-eval-after-load 'evil
      (evil-set-initial-state 'org-brain-visualize-mode 'emacs))
    :config  
    (bind-key "C-c b" 'org-brain-prefix-map org-mode-map)
    ;; ... omitted ...
    )

  ;; This call `polymode` inside the package. so it doesn't need
  ;; to call `(use-package polymode)` explicitly.
  ;; If you want to load `polymode` explicitly, you can add
  ;; `:after polymode` inside the below clause and `(use-package polymode)`.
  (use-package org-brain-polymode
    :straight nil
    :hook (org-brain-visualize-mode . org-brain-polymode))

  ;; If there is no helm, below code doesn't be evaluated.
  (use-package org-brain-helm
    :straight nil
    :after helm)

  ;; If there is no ivy, below code doesn't be evaluated.
  (use-package org-brain-ivy
    :straight nil
    :after ivy)

@LazerJesus
Copy link

is this issue expected to be resolved?
i am running into it and tried all shades of fixes i found in the issues here.
various combinations of this:

(use-package polymode :defer t)

(use-package org-brain
  :ensure t
  :init
  (setq org-brain-path "~/valence/courses/elisp/brain")
  (with-eval-after-load 'evil
    (evil-set-initial-state 'org-brain-visualize-mode 'emacs))
  :config
  ;; (bind-key ", B" 'org-brain-prefix-map org-mode-map)
  (setq org-id-track-globally t)
  (setq org-id-locations-file "~/.emacs.d/.org-id-locations")
  (add-hook 'before-save-hook #'org-brain-ensure-ids-in-buffer)
  (add-hook 'org-brain-visualize-mode-hook #'org-brain-polymode)
  (with-eval-after-load 'polymode)
  (setq org-brain-visualize-default-choices 'all)
  (setq org-brain-title-max-length 12)
  (setq org-brain-include-file-entries nil)
  (setq org-brain-file-enties-use-title nil)
  (setq org-brain-headline-entry-name-format-string "%2$s")
  (setq my/default-org-brain-file "brain")
  (setq org-brain-default-file-parent my/default-org-brain-file))

(use-package org-brain-polymode
    :hook (org-brain-visualize-mode . org-brain-polymode))

(use-package polymode)
(use-package org-brain-polymode
    :hook (org-brain-visualize-mode . org-brain-polymode))

@hwiorn
Copy link
Contributor Author

hwiorn commented Mar 30, 2023

@FinnFrotscher

is this issue expected to be resolved?

Yes. Actually this issue need to be reopened. Because #385 which I made was a wrong PR. You need the PR #386

i am running into it and tried all shades of fixes i found in the issues here. various combinations of this:

What do you get error? What is your emacs kit and emacs version?

Did you apply the PR #386? You can use this snippet with #386

@LazerJesus
Copy link

My emacs version is "30.0.50" and its built from source, no doom or spacemacs.
the error I get is:

Debugger entered--Lisp error: (void-variable org-brain-poly-hostmode)
  #f(compiled-function () #<bytecode -0x18e197d61d110495>)()
  eval-after-load-helper("/Users/finn/.emacs.d/straight/build/polymode/polym...")
  run-hook-with-args(eval-after-load-helper "/Users/finn/.emacs.d/straight/build/polymode/polym...")
  do-after-load-evaluation("/Users/finn/.emacs.d/straight/build/polymode/polym...")

@hwiorn
Copy link
Contributor Author

hwiorn commented Mar 30, 2023

My emacs version is "30.0.50" and its built from source, no doom or spacemacs. the error I get is:

Debugger entered--Lisp error: (void-variable org-brain-poly-hostmode)
  #f(compiled-function () #<bytecode -0x18e197d61d110495>)()
  eval-after-load-helper("/Users/finn/.emacs.d/straight/build/polymode/polym...")
  run-hook-with-args(eval-after-load-helper "/Users/finn/.emacs.d/straight/build/polymode/polym...")
  do-after-load-evaluation("/Users/finn/.emacs.d/straight/build/polymode/polym...")

Did you apply the PR #386?
I don't use vanilla Emacs with straight.el.
The bytecompile error, it looks like it hasn't been patched.

@hwiorn
Copy link
Contributor Author

hwiorn commented Mar 30, 2023

@FinnFrotscher
I updated the snippet.

I don't prefer vanilla configuration for now.
So I tried to dig straight.el config and the issue you posted for a while.

My emacs version is also 30.0.50. I tested it with straight.el only and I confirmed it works.
I think you need to install polymode package using straight if you don't use polymode elsewhere in your config.
Check below setting.

~/.emacs

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Bootstraping
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar bootstrap-version)
(setq straight-repository-branch "develop")
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
(setq straight-vc-git-default-clone-depth 1)

(straight-use-package 'polymode)
(straight-use-package
 '(org-brain :type git
             :host github
             :repo "hwiorn/org-brain"
             :branch "split-to-each-packages"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Org-brain
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(use-package org-brain
  :ensure t
  :init
  (setq org-brain-path "~/org/brain")
  ;; For Evil users
  (with-eval-after-load 'evil
    (evil-set-initial-state 'org-brain-visualize-mode 'emacs))
  :config  
  (bind-key "C-c b" 'org-brain-prefix-map org-mode-map)
  ;; ... omitted ...
  )

;; This call `polymode` inside the package. so it doesn't need
;; to call `(use-package polymode)` explicitly.
;; If you want to load `polymode` explicitly, you can add
;; `:after polymode` inside the below clause and `(use-package polymode)`.
(use-package org-brain-polymode
  :straight nil
  :hook (org-brain-visualize-mode . org-brain-polymode))

;; If there is no helm, below code doesn't be evaluated.
(use-package org-brain-helm
  :straight nil
  :after helm)

;; If there is no ivy, below code doesn't be evaluated.
(use-package org-brain-ivy
  :straight nil
  :after ivy)

@hwiorn
Copy link
Contributor Author

hwiorn commented Apr 4, 2023

@FinnFrotscher
Did the config I pasted help you?

@LazerJesus
Copy link

@hwiorn well sort of. I implemented it just now and it works. but only when i run brain-visualize for the second time. the first time i get run-hooks: Cannot open load file: No such file or directory, org-brain-polymode.

@hwiorn
Copy link
Contributor Author

hwiorn commented Apr 10, 2023

Hm, I tried to reinstall from scratch few times, But I can't reproduce the case on straight.el config. It seems to be personal config issue. Or it might be issue by straight.el.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants