Function: treemacs-with-path
treemacs-with-path is a macro defined in treemacs-macros.el.
Signature
(treemacs-with-path PATH &key FILE-ACTION EXTENSION-ACTION NO-MATCH-ACTION)
Documentation
Execute an action depending on the type of PATH.
FILE-ACTION is the action to perform when PATH is a regular file node. EXTENSION-ACTION is performed on extension-created nodes.
If none of the path types matches, NO-MATCH-ACTION is executed.
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-macros.el
(cl-defmacro treemacs-with-path (path &key file-action extension-action no-match-action)
"Execute an action depending on the type of PATH.
FILE-ACTION is the action to perform when PATH is a regular file node.
EXTENSION-ACTION is performed on extension-created nodes.
If none of the path types matches, NO-MATCH-ACTION is executed."
(declare (indent 1))
(let ((path-symbol (make-symbol "path")))
`(let ((,path-symbol ,path))
(cond
,@(when file-action
`(((stringp ,path-symbol) ,file-action)))
,@(when extension-action
`(((or (symbolp ,path)
(symbolp (car ,path))
(stringp (car ,path)))
,extension-action)))
(t
,(if no-match-action
no-match-action
`(error "Path type did not match: %S" ,path-symbol)))))))