all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Switching sets of variables
@ 2010-03-04  0:19 Sven Bretfeld
  2010-03-04  7:19 ` Andreas Röhler
  0 siblings, 1 reply; 6+ messages in thread
From: Sven Bretfeld @ 2010-03-04  0:19 UTC (permalink / raw
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Switching sets of variables
       [not found] <mailman.2244.1267661988.14305.help-gnu-emacs@gnu.org>
@ 2010-03-04  1:11 ` Barry Margolin
  2010-05-04 18:59   ` Drew Adams
  0 siblings, 1 reply; 6+ messages in thread
From: Barry Margolin @ 2010-03-04  1:11 UTC (permalink / raw
  To: help-gnu-emacs

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 ***


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Switching sets of variables
  2010-03-04  0:19 Switching sets of variables Sven Bretfeld
@ 2010-03-04  7:19 ` Andreas Röhler
  2010-03-04  9:47   ` Stephen Berman
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Röhler @ 2010-03-04  7:19 UTC (permalink / raw
  To: help-gnu-emacs

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
> 
> 
> 


Maybe define a variable, indicating the state

(defvar privat-org nil
  "If privat-org settings are active, otherwise institute-settings.")

then some function setting the vars with setq as you have shown.

(defun my-toggle-var-sets ()
  (interactive)
  (if privat-org
      (my-institute-settings)
    (my-private-settings)))

Both forms should set `privat-org' respectivly.

Andreas

--
https://code.launchpad.net/~a-roehler/python-mode
https://code.launchpad.net/s-x-emacs-werkstatt/





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Switching sets of variables
  2010-03-04  7:19 ` Andreas Röhler
@ 2010-03-04  9:47   ` Stephen Berman
  2010-03-05  0:45     ` Sven Bretfeld
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Berman @ 2010-03-04  9:47 UTC (permalink / raw
  To: help-gnu-emacs

On Thu, 04 Mar 2010 08:19:12 +0100 Andreas Röhler <andreas.roehler@easy-emacs.de> wrote:

> 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
>> 
>> 
>> 
>
>
> Maybe define a variable, indicating the state
>
> (defvar privat-org nil
>   "If privat-org settings are active, otherwise institute-settings.")

Or just use org-gtd-file, since you already have it, e.g.:

(setq org-todo-keywords
      (cond ((string= org-gtd-file (expand-file-name "~/private.org"))
	     '((type "NEXT" "WAITING" "APPT" "DONE")))
	    ((string= org-gtd-file (expand-file-name "~/institute.org"))
	     '((type "PRESENT" "HOLIDAY" "DELEGATED" "DONE")))))

Steve Berman





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Switching sets of variables
  2010-03-04  9:47   ` Stephen Berman
@ 2010-03-05  0:45     ` Sven Bretfeld
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Bretfeld @ 2010-03-05  0:45 UTC (permalink / raw
  To: help-gnu-emacs


Stephen Berman <stephen.berman@gmx.net> writes:

>> Sven Bretfeld wrote:

>>> I want to have two sets of different values for the same variables and
>>> switch between these sets.

> Or just use org-gtd-file, since you already have it, e.g.:
>
> (setq org-todo-keywords
>       (cond ((string= org-gtd-file (expand-file-name "~/private.org"))
> 	     '((type "NEXT" "WAITING" "APPT" "DONE")))
> 	    ((string= org-gtd-file (expand-file-name "~/institute.org"))
> 	     '((type "PRESENT" "HOLIDAY" "DELEGATED" "DONE")))))

This would probably also work. Thanks. I did it in the way suggested by
Andreas. 

Greetings,

Sven




^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Switching sets of variables
  2010-03-04  1:11 ` Barry Margolin
@ 2010-05-04 18:59   ` Drew Adams
  0 siblings, 0 replies; 6+ messages in thread
From: Drew Adams @ 2010-05-04 18:59 UTC (permalink / raw
  To: help-gnu-emacs

> I want to have two sets of different values for the same 
> variables and switch between these sets.

With Bookmark+ you can easily create a variable-list bookmark for each set.
Jumping to such a bookmark just restores that set of variable values.

http://www.emacswiki.org/emacs/BookmarkPlus#FunctionSequenceVarlistBookmarks

Command `bookmarkp-set-varlist-bookmark' prompts you for the variables to save.
They are saved with their current values.

If you want to create such variable sets from Lisp using specified values, you
can use function `bookmarkp-create-varlist-bookmark'. For example:

(bookmarkp-create-varlist-bookmark
 "Var Set #1"         ; NAME
 '(org-gtd-file       ; VARS
   org-todo-keywords
   org-tag-alist)
 '("~/private.org"    ; VALUES
   ((type "NEXT" "WAITING" "APPT" "DONE"))
   (("OFFICE" . ?o) ("HOME" . ?h)
    ("READING" . ?r) ("SHOPPING" . ?s))))





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-05-04 18:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-04  0:19 Switching sets of variables Sven Bretfeld
2010-03-04  7:19 ` Andreas Röhler
2010-03-04  9:47   ` Stephen Berman
2010-03-05  0:45     ` Sven Bretfeld
     [not found] <mailman.2244.1267661988.14305.help-gnu-emacs@gnu.org>
2010-03-04  1:11 ` Barry Margolin
2010-05-04 18:59   ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.