Files
memex/projects/org-skill-context-manager/src/context-manager.lisp

20 lines
675 B
Common Lisp

(defvar *context-stack* nil)
(defun context-push (new-context)
"Push a new context (usually a path or a plist) onto the stack."
(push new-context *context-stack*)
(kernel-log "CONTEXT - Pushed: ~a" new-context))
(defun context-pop ()
"Pop the top context from the stack."
(let ((old (pop *context-stack*)))
(kernel-log "CONTEXT - Popped: ~a" old)
old))
(defun context-resolve-path (path)
"Resolve PATH relative to the current context if it's a directory, otherwise return as is."
(let ((current (car *context-stack*)))
(if (and current (stringp current) (uiop:directory-pathname-p current))
(merge-pathnames path current)
path)))