Function: kotl-mode:promote-tree

kotl-mode:promote-tree is an interactive and byte-compiled function defined in kotl-mode.el.

Signature

(kotl-mode:promote-tree ARG)

Documentation

Move current tree a maximum of prefix ARG levels higher in current view.

Each cell is refilled iff its no-fill attribute is nil and kotl-mode:refill-flag is non-nil. With prefix ARG = 0, cells are promoted up to one level and kotl-mode:refill-flag is treated as true.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kotl-mode.el
(defun kotl-mode:promote-tree (arg)
  "Move current tree a maximum of prefix ARG levels higher in current view.
Each cell is refilled iff its `no-fill' attribute is nil and
kotl-mode:refill-flag is non-nil.  With prefix ARG = 0, cells are promoted up
to one level and kotl-mode:refill-flag is treated as true."
  (interactive "*p")
  (if (< arg 0)
      (kotl-mode:demote-tree (- arg))
    (let* ((parent) (result)
	   (lbl-sep-len (kview:label-separator-length kotl-kview))
	   (orig-id (kcell-view:idstamp))
	   (fill-p (= arg 0))
	   (orig-pos-in-cell
	    (- (point) (kcell-view:start nil lbl-sep-len)))
	   start-point)
      ;; Next line ensures point is in the root of the current tree if
      ;; the tree is at all hidden.
      (kotl-mode:beginning-of-line)
      (setq start-point (point))
      (when fill-p
	(setq arg 1))
      (unwind-protect
	  (progn
	    (backward-char 1)
	    (while (and (> arg 0)
			(setq result (kcell-view:parent nil lbl-sep-len))
			(not (eq result 0)))
	      (setq parent result
		    arg (1- arg)))
	    (when parent
	      (kotl-mode:move-after
	       (kcell-view:label start-point)
	       (kcell-view:label) nil
	       nil fill-p)))
	;; Move to start of original cell
	(kotl-mode:goto-cell orig-id)
	;; Move to original pos within cell
	(forward-char (min orig-pos-in-cell
			   (- (kcell-view:end-contents)
			      (kcell-view:start))))
	(kotl-mode:to-valid-position))
      (unless parent
	(error "(kotl-mode:promote-tree): Cannot promote any further")))))