Reputation: 13457
I use a custom version of org-mode
called lawlist-org-mode
-- every function and variable have the prefix lawlist-
and the modified version has many custom features that are not available in the stock version. Occasionally, I like to use the stock org-mode
version -- however, that requires manually modifying the auto-mode-alist
and then restarting Emacs. This is necessary due to the function and variable org-agenda-files
and the check that org-mode
performs to verify that the proper major-mode is present. Is there an efficient method to modify this programmatically depending upon the function being called?
The stock org-mode
needs this entry:
(add-to-list 'auto-mode-alist '("\\.todo\\'" . org-mode))
The custom version called lawlist-org-mode
needs this entry:
(add-to-list 'auto-mode-alist '("\\.todo\\'" . lawlist-org-mode))
Examples:
If I call M-x org-agenda
, the .todo
files needs to be in org-mode
.
If I call M-x lawlist-org-agenda
, the .todo
file needs to be in lawlist-org-mode
.
Some Ideas: The org-agenda-files
are generally accessed by org-agenda functions using the following lines of code -- (org-agenda-files nil 'ifmode) . . . (while (setq file (pop files))
. Perhaps modifying the function org-agenda-files
would be an option?
Upvotes: 3
Views: 218
Reputation: 30701
The FUNCTION
part of an auto-mode-alist
entry (i.e., the cdr) is just a function. It is called, in principle to set up a major mode. But it can do anything.
In particular, you could have an entry ("\\.todo\\'" . foo)
, where function foo
conditionally calls either lawlist-org-mode
or org-mode
.
E.g, it could use lawlist-org-mode
when the moon is full and org-mode
otherwise. Or it could test a global variable, which you set when you want to switch from one to the other. And so on.
At least that's my reading of the auto-mode-alist
doc string. I've never tried it.
Upvotes: 4