aboutsummaryrefslogtreecommitdiff
path: root/perspective.el
diff options
context:
space:
mode:
authorNathan Weizenbaum <nweiz@google.com>2010-09-30 13:38:09 -0700
committerNathan Weizenbaum <nweiz@google.com>2010-09-30 13:38:09 -0700
commit554df5fa4f79fea8eaabd331f8fa248a38f36a87 (patch)
tree093f9c8c25c99ea60d7a2d6a9c72b01e142a93bc /perspective.el
parent2669a8ce9bb3df7f10c1e056746854d2d027eeb6 (diff)
Add a macro for setting up code to always run in a given persp.
Diffstat (limited to 'perspective.el')
-rw-r--r--perspective.el14
1 files changed, 14 insertions, 0 deletions
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)))))