From 554df5fa4f79fea8eaabd331f8fa248a38f36a87 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Thu, 30 Sep 2010 13:38:09 -0700 Subject: Add a macro for setting up code to always run in a given persp. --- perspective.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/perspective.el b/perspective.el index 6b199a7..e9a6c92 100644 --- a/perspective.el +++ b/perspective.el @@ -652,6 +652,20 @@ from the current perspective at time of creation." (loop for persp being the hash-values of (with-selected-frame frame perspectives-hash) do (push entry (persp-local-variables persp))))))) +(defmacro persp-setup-for (name &rest body) + "Add code that should be run to set up the perspective named NAME. +Whenever a new perspective named NAME is created, runs BODY in +it. In addition, if one exists already, runs BODY in it immediately." + (declare (indent 1)) + `(progn + (add-hook 'persp-created-hook + (lambda () + (when (string= (persp-name persp-curr) ,name) + ,@body)) + 'append) + (when (gethash ,name perspectives-hash) + (with-perspective ,name ,@body)))) + (defun persp-set-ido-buffers () (setq ido-temp-list (let ((names (remq nil (mapcar 'buffer-name (persp-buffers persp-curr))))) -- cgit v1.0