@@ -137,14 +137,6 @@ Never set or modify this variable directly.")
137137 " The Outline buffer displaying the tree view." )
138138
139139
140- (defvar-local org-ol-tree-core--DOM nil
141- " Hold the root node for the displayed outline." )
142-
143-
144- (defvar-local org-ol-tree-core--rebuild-DOM-p nil
145- " Flag indicating the root hading needs to be rebuild." )
146-
147-
148140(defvar-local org-ol-tree-action--debounce-timer nil
149141 " The timer waiting to debounce click operations on the tree view." )
150142
@@ -591,7 +583,6 @@ an Org buffer, raises a `user-error'."
591583 (widen )
592584 (goto-char (point-min ))
593585 (let ((root (org-ol-tree-core--headline-create-internal
594- :name (org-ol-tree-core--find-title)
595586 :id " 0"
596587 :marker (point-min-marker )
597588 :level 0 ))
@@ -627,18 +618,6 @@ transformed to title case."
627618 (t (s-titleized-words (buffer-name ))))))))
628619
629620
630- (defun org-ol-tree-core--doc ()
631- " Return the root headline for the outline in the current window.
632-
633- The root headline is cached on a buffer local variable"
634- (unless (and org-ol-tree-core--DOM (not org-ol-tree-core--rebuild-DOM-p))
635- (when org-ol-tree--buffer-p
636- (setq-local org-ol-tree-core--DOM
637- (org-ol-tree-core--create-dom org-ol-tree--org-buffer))
638- (setq-local org-ol-tree-core--rebuild-DOM-p nil )))
639- org-ol-tree-core--DOM)
640-
641-
642621
643622; ;;; --- UI
644623
@@ -781,7 +760,8 @@ displays the Outline buufer into it."
781760 (-> org-ol-tree--buffer
782761 (display-buffer-in-side-window `((side . , org-ol-tree-ui-window-position )))
783762 (select-window )
784- (set-window-dedicated-p t ))))
763+ (set-window-dedicated-p t ))
764+ (add-hook 'window-configuration-change-hook 'org-ol-tree-ui--window-resize nil t )))
785765
786766
787767(defun org-ol-tree-ui--get-window ()
@@ -967,7 +947,7 @@ The majority of the code in this function was copied from the Emacs function
967947 (kill-buffer-and-window ))))
968948
969949
970- (defun org-ol-tree-ui--rebuild -tree ()
950+ (defun org-ol-tree-ui--build-outline -tree ()
971951 " Erase and re-draw the entire tree hierarchy for the current Outline."
972952 (let ((buffer (if org-ol-tree--buffer-p (current-buffer ) org-ol-tree--buffer)))
973953 (unless buffer
@@ -977,11 +957,10 @@ The majority of the code in this function was copied from the Emacs function
977957 (treemacs-with-writable-buffer
978958 (erase-buffer )
979959 (treemacs-ORG-OL-DOC-extension)
960+ (org-ol-tree-core--node-put :headline (org-ol-tree-core--create-dom)
961+ (org-ol-tree-core--root-node))
980962 (treemacs-expand-org-ol-doc)
981963 (save-excursion
982- (add-text-properties (point-at-bol )
983- (point-at-eol )
984- (list :headline org-ol-tree-core--DOM))
985964 (goto-char (point-max ))
986965 (insert " \n " ))))))
987966
@@ -1244,12 +1223,13 @@ for comparison and uses the provided name instead."
12441223 (current-name (org-ol-tree-core--headline-name headline)))
12451224 (list headline (read-string " New name: " current-name) current-name)))
12461225 (let ((marker (org-ol-tree-core--headline-marker headline))
1226+ (root-headline (org-ol-tree-core--root-headline))
12471227 (progress (org-ol-tree-core--headline-progress headline)))
12481228 (when (not (equal current-name new-title))
12491229 (setf (org-ol-tree-core--headline-name headline) new-title)
1250- (if (eq headline org-ol-tree-core--DOM )
1230+ (if (eq headline root-headline )
12511231 (progn
1252- (org-ol-tree-ui--rebuild -tree)
1232+ (org-ol-tree-ui--build-outline -tree)
12531233 (with-current-buffer org-ol-tree--org-buffer
12541234 (org-ol-tree-action--rename-title new-title)))
12551235 (with-current-buffer org-ol-tree--org-buffer
@@ -1330,15 +1310,7 @@ For more information on EVENT, check the documentation of
13301310 " Initialize an org-ol-tree for the current Org buffer."
13311311 (org-ol-tree-ui--setup-buffer)
13321312 (org-ol-tree-ui--setup-window t )
1333- (with-eval-after-load 'cfrs
1334- (define-key cfrs-input-mode-map [escape] #'cfrs-cancel )
1335-
1336- (when (org-ol-tree-system--evil-p)
1337- (evil-define-key 'normal cfrs-input-mode-map " q" #'cfrs-cancel )))
1338-
1339- (org-ol-tree-ui--rebuild-tree)
1340-
1341- (add-hook 'window-configuration-change-hook 'org-ol-tree-ui--window-resize nil t )
1313+ (org-ol-tree-ui--build-outline-tree)
13421314 (org-ol-tree-action--start-watching-buffer)
13431315 (beginning-of-line ))
13441316
@@ -1406,11 +1378,13 @@ With a prefix ARG call `org-ol-tree-ui--kill-buffer' instead."
14061378 :ret-action 'org-ol-tree-action--visit
14071379 :after-expand (org-ol-tree-ui--window-resize)
14081380 :after-collapse (org-ol-tree-ui--window-resize)
1409- :query-function (reverse (org-ol-tree-core--headline-children (org-ol-tree-core--doc)))
1381+ :query-function (reverse
1382+ (org-ol-tree-core--headline-children
1383+ (org-ol-tree-core--node-get :headline node)))
14101384 :top-level-marker t
14111385 :root-face 'org-ol-tree-document-face
1412- :root-key-form (org-ol-tree-core--headline-id ( org-ol-tree-core--doc ))
1413- :root-label (org-ol-tree-core--headline-name (org-ol-tree-core--doc) )
1386+ :root-key-form (car ( last ( org-ol-tree-core--root-path) ))
1387+ :root-label (org-ol-tree-core--find-title )
14141388 :render-action
14151389 (treemacs-render-node :icon (org-ol-tree-ui--section-icon item 'collapsed )
14161390 :label-form (org-ol-tree-core--headline-name item)
0 commit comments