(defvar project--next-dd nil) (defun project--with-next-dd (fun &rest args) (advice-remove 'command-execute #'project--with-next-dd) (let ((default-directory project--next-dd)) (apply fun args))) (defun project-switch-project (dir) (interactive (list (funcall project-prompter))) (setq project--next-dd dir) (advice-add 'command-execute :around #'project--with-next-dd))