[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Switching sets of variables
From: |
Barry Margolin |
Subject: |
Re: Switching sets of variables |
Date: |
Tue, 04 May 2010 15:41:16 -0000 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article <mailman.2244.1267661988.14305.help-gnu-emacs@gnu.org>,
"Sven Bretfeld" <sven.bretfeld@gmx.ch> wrote:
> Hi to all
>
> I want to have two sets of different values for the same variables and
> switch between these sets.
>
> For example:
>
> ,----First set: org-mode settings for my private context
> |
> | (defvar org-gtd-file "~/private.org")
> | (setq org-todo-keywords '((type "NEXT" "WAITING" "APPT" "DONE")))
> | (setq org-tag-alist '(("OFFICE" . ?o)
> | ("HOME" . ?h)
> | ("READING" . ?r)
> | ("SHOPPING" . ?s)))
> `----
>
> ,----Second set: org-mode settings for office organization
> |
> | (defvar org-gtd-file "~/institute.org")
> | (setq org-todo-keywords '((type "PRESENT" "HOLIDAY" "DELEGATED" "DONE")))
> | (setq org-tag-alist '(("ANNE" . ?a)
> | ("MARY" . ?m)
> | ("JOE" . ?j)
> | ("FRED" . ?f)))
> |
> `----
>
> I want to have a function that switches between these sets. How could
> that be done?
>
> Thanks for help,
>
> Sven
(defvar org-context-alist nil
"Alist mapping context name to alist of variable->value.")
(add-to-list 'org-context-alist
'(private . ((org-gtd-file . "~/private.org")
(org-todo-keywords . ((type "NEXT" "WAITING" "APPT"
"DONE")))
(org-tag-alist . (("OFFICE" . ?o)
("HOME" . ?h)
("READING" . ?r)
("SHOPPING" . ?s))))))
(add-to-list 'org-context-alist
'(office . ((org-gtd-file . "~/institute.org")
(org-todo-keywords . ((type "PRESENT" "HOLIDAY"
"DELEGATED" "DONE")))
(org-tag-alist . (("ANNE" . ?a)
("MARY" . ?m)
("JOE" . ?j)
("FRED" . ?f))))))
(defun set-org-context (context-name)
"Set all the variables in the entry in org-context-alist corresponding
to CONTEXT-NAME."
(loop for (var . val) in (cdr (assq context-name org-context-alist))
do (setf (symbol-value var) val)))
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
- Re: Switching sets of variables,
Barry Margolin <=