Kungsgeten / org-brain

Org-mode wiki + concept-mapping
MIT License
1.73k stars 104 forks source link

Entry with friends fails in normal visualization mode #296

Closed riclage closed 4 years ago

riclage commented 4 years ago

In visualization mode, when I press 'm' to toggle from normal mode to mind map, I get the following error for entries with friend links:

if: Symbol’s value as variable is void: max-level
Debugger entered--Lisp error: (void-variable max-level)
  (> max-level 0)
  (if (> max-level 0) (quote stranger) (quote friend))
  (org-brain-insert-visualize-button friend (quote org-brain-friend) (if (> max-level 0) (quote stranger) (quote friend)))
  (let ((friend (car --dolist-tail--))) (insert "  ") (org-brain-insert-visualize-button friend (quote org-brain-friend) (if (> max-level 0) (quote stranger) (quote friend))) (setq --dolist-tail-- (cdr --dolist-tail--)))
  (while --dolist-tail-- (let ((friend (car --dolist-tail--))) (insert "  ") (org-brain-insert-visualize-button friend (quote org-brain-friend) (if (> max-level 0) (quote stranger) (quote friend))) (setq --dolist-tail-- (cdr --dolist-tail--))))
  (let ((--dolist-tail-- (sort (org-brain-friends entry) org-brain-visualize-sort-function))) (while --dolist-tail-- (let ((friend (car --dolist-tail--))) (insert "  ") (org-brain-insert-visualize-button friend (quote org-brain-friend) (if (> max-level 0) (quote stranger) (quote friend))) (setq --dolist-tail-- (cdr --dolist-tail--)))))
  org-brain-mind-map(("Agile" "Agile" "2AB64B7A-DA6E-455A-81FC-0241DB17B8A5") 1 1)
  (setq entry-pos (org-brain-mind-map org-brain--vis-entry org-brain-mind-map-parent-level org-brain-mind-map-child-level))
  (if org-brain-visualizing-mind-map (setq entry-pos (org-brain-mind-map org-brain--vis-entry org-brain-mind-map-parent-level org-brain-mind-map-child-level)) (insert "\n\n") (org-brain--vis-parents-siblings entry) (let ((title (org-brain-vis-title entry))) (let ((half-title-length (/ (string-width title) 2))) (if (>= half-title-length (current-column)) (delete-char (- (current-column))) (condition-case nil (progn (delete-char (- half-title-length))) (error nil)))) (setq entry-pos (point)) (insert (propertize title (quote face) (org-brain-display-face entry (quote org-brain-title)) (quote aa2u-text) t)) (org-brain--vis-friends entry) (org-brain--vis-children entry)))
  (let ((inhibit-read-only t) (entry-pos)) (delete-region (point-min) (point-max)) (org-brain--vis-pinned) (org-brain--vis-selected) (if (not nohistory) (progn (setq org-brain--vis-history (seq-filter (function (lambda (elt) (not ...))) org-brain--vis-history)) (setq org-brain--vis-history (seq-take org-brain--vis-history 15)) (setq org-brain--vis-history (cons entry org-brain--vis-history)))) (if org-brain-show-history (progn (org-brain--vis-history))) (if org-brain-visualizing-mind-map (setq entry-pos (org-brain-mind-map org-brain--vis-entry org-brain-mind-map-parent-level org-brain-mind-map-child-level)) (insert "\n\n") (org-brain--vis-parents-siblings entry) (let ((title (org-brain-vis-title entry))) (let ((half-title-length (/ (string-width title) 2))) (if (>= half-title-length (current-column)) (delete-char (- (current-column))) (condition-case nil (progn (delete-char ...)) (error nil)))) (setq entry-pos (point)) (insert (propertize title (quote face) (org-brain-display-face entry (quote org-brain-title)) (quote aa2u-text) t)) (org-brain--vis-friends entry) (org-brain--vis-children entry))) (if (and org-brain-show-resources) (progn (org-brain--vis-resources (org-brain-resources entry)))) (if org-brain-show-text (org-brain--vis-text entry) (run-hooks (quote org-brain-after-visualize-hook))) (if (eq major-mode (quote org-brain-visualize-mode)) nil (org-brain-visualize-mode)) (goto-char entry-pos))
  (save-current-buffer (set-buffer (get-buffer-create "*org-brain*")) (set (make-local-variable (quote indent-tabs-mode)) nil) (read-only-mode 1) (set (make-local-variable (quote default-directory)) (file-name-directory (org-brain-entry-path entry))) (org-brain-maybe-switch-brain) (if (eq org-brain--vis-entry entry) nil (setq org-brain--vis-entry entry) (setq org-brain-mind-map-parent-level (default-value (quote org-brain-mind-map-parent-level))) (setq org-brain-mind-map-child-level (default-value (quote org-brain-mind-map-child-level)))) (setq org-brain--vis-entry-keywords (if (org-brain-filep entry) (progn (org-brain-keywords entry)))) (let ((inhibit-read-only t) (entry-pos)) (delete-region (point-min) (point-max)) (org-brain--vis-pinned) (org-brain--vis-selected) (if (not nohistory) (progn (setq org-brain--vis-history (seq-filter (function (lambda ... ...)) org-brain--vis-history)) (setq org-brain--vis-history (seq-take org-brain--vis-history 15)) (setq org-brain--vis-history (cons entry org-brain--vis-history)))) (if org-brain-show-history (progn (org-brain--vis-history))) (if org-brain-visualizing-mind-map (setq entry-pos (org-brain-mind-map org-brain--vis-entry org-brain-mind-map-parent-level org-brain-mind-map-child-level)) (insert "\n\n") (org-brain--vis-parents-siblings entry) (let ((title (org-brain-vis-title entry))) (let ((half-title-length (/ ... 2))) (if (>= half-title-length (current-column)) (delete-char (- ...)) (condition-case nil (progn ...) (error nil)))) (setq entry-pos (point)) (insert (propertize title (quote face) (org-brain-display-face entry (quote org-brain-title)) (quote aa2u-text) t)) (org-brain--vis-friends entry) (org-brain--vis-children entry))) (if (and org-brain-show-resources) (progn (org-brain--vis-resources (org-brain-resources entry)))) (if org-brain-show-text (org-brain--vis-text entry) (run-hooks (quote org-brain-after-visualize-hook))) (if (eq major-mode (quote org-brain-visualize-mode)) nil (org-brain-visualize-mode)) (goto-char entry-pos)) (if nofocus nil (if org-brain--visualize-follow (progn (org-brain-goto-current) (run-hooks (quote org-brain-visualize-follow-hook)))) (if (or org-brain--visualize-follow org-brain-open-same-window) (pop-to-buffer "*org-brain*") (pop-to-buffer-same-window "*org-brain*"))))
  org-brain-visualize(("Agile" "Agile" "2AB64B7A-DA6E-455A-81FC-0241DB17B8A5"))
  (progn (setq org-brain-visualizing-mind-map (not org-brain-visualizing-mind-map)) (org-brain-visualize org-brain--vis-entry))
  (if (eq major-mode (quote org-brain-visualize-mode)) (progn (setq org-brain-visualizing-mind-map (not org-brain-visualizing-mind-map)) (org-brain-visualize org-brain--vis-entry)))
  org-brain-visualize-mind-map()
  funcall-interactively(org-brain-visualize-mind-map)
  call-interactively(org-brain-visualize-mind-map nil nil)
  command-execute(org-brain-visualize-mind-map)

I'm using the latest version from master

riclage commented 4 years ago

On line 3019, replacing max-parent with parent-max-level fixes the problem but I'm not sure that's the intended behavior.

Kungsgeten commented 4 years ago

Hi! Thanks for reporting this. Strange that it hasn't been noticed before this! Should be fixed now.

The feature of category text properties for link buttons in org-brain-visualize-mode was added by @dustinlacewell in #269. Currently they aren't used in the org-brain code. I don't understand the 'stranger type which Dustin introduced, so I removed it.

dustinlacewell commented 4 years ago

It was just supposed to represent the case where there is no direct association (parent, child, sibling, friend)

codingquark commented 4 years ago

Boy, I just spent an hour trying to understand what I've done wrong that might be causing an infinite loop or something. Thanks for the fix! Cheers! 🍻