Function: treemacs--button-open

treemacs--button-open is a macro defined in treemacs-rendering.el.

Signature

(treemacs--button-open &key BUTTON NEW-STATE NEW-ICON OPEN-ACTION POST-OPEN-ACTION IMMEDIATE-INSERT)

Documentation

Building block macro to open a BUTTON.

Gives the button a NEW-STATE, and, optionally, a NEW-ICON. Performs OPEN-ACTION and, optionally, POST-OPEN-ACTION. If IMMEDIATE-INSERT is non-nil it will concat and apply insert on the items returned from OPEN-ACTION. If it is nil either OPEN-ACTION or POST-OPEN-ACTION are expected to take over insertion.

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-rendering.el
;; TODO document open-action return strings
(cl-defmacro treemacs--button-open (&key button new-state new-icon open-action post-open-action immediate-insert)
  "Building block macro to open a BUTTON.
Gives the button a NEW-STATE, and, optionally, a NEW-ICON.  Performs OPEN-ACTION
and, optionally, POST-OPEN-ACTION.  If IMMEDIATE-INSERT is non-nil it will
concat and apply `insert' on the items returned from OPEN-ACTION.  If it is nil
either OPEN-ACTION or POST-OPEN-ACTION are expected to take over insertion."
  `(prog1
     (save-excursion
       (let ((p (point))
             lines)
         (treemacs-with-writable-buffer
          (treemacs-button-put ,button :state ,new-state)
          ,@(when new-icon
              `((beginning-of-line)
                (treemacs--button-symbol-switch ,new-icon)))
          (goto-char (line-end-position))
          ,@(if immediate-insert
                `((progn
                    (insert (apply #'concat ,open-action))))
              `(,open-action))
          (setf lines (count-lines p (point)))
          ,post-open-action
          lines)))
     (when treemacs-move-forward-on-expand
       (let* ((parent (treemacs-current-button))
              (child (next-button parent)))
         (when (equal parent (treemacs-button-get child :parent))
           (forward-line 1))))))