From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Switching sets of variables Date: Wed, 03 Mar 2010 20:11:46 -0500 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1272988194 28415 80.91.229.12 (4 May 2010 15:49:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 4 May 2010 15:49:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 04 17:49:52 2010 connect(): No such file or directory Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O9KNc-0003f2-8Y for geh-help-gnu-emacs@m.gmane.org; Tue, 04 May 2010 17:49:52 +0200 Original-Received: from localhost ([127.0.0.1]:55753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9KNb-0008VM-Mq for geh-help-gnu-emacs@m.gmane.org; Tue, 04 May 2010 11:49:51 -0400 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!news2.euro.net!newsfeed.freenet.ag!feeder.erje.net!feeder.eternal-september.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 68 Injection-Date: Thu, 4 Mar 2010 01:11:46 +0000 (UTC) Injection-Info: barmar.motzarella.org; posting-host="+bxBiZT/p0ZLLuDb5H+JCw"; logging-data="1844"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19su8RpAGDIYiNfz3lvoox1" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:+eOBXwG1ffbB6M6LWwg8pLWa/iU= Original-Xref: usenet.stanford.edu gnu.emacs.help:177319 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:72895 Archived-At: In article , "Sven Bretfeld" 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 ***