I'm developing a set of minor modes that I use in my LaTeX copy-editing work.
I have, e.g.. a list of three minor modes stored in a variable:
(defvar latex-editing-mode
'(preamble-editing-mode
biblio-editing-mode
proofs-editing-mode))
I need them to be active one at a time. E.g. when I turn-on biblio-editing-mode
the other two modes must be turned-off.
I'm trying to write a function:
(defun activate-mode-in-list (MINOR_MODE MINOR_MODE_LIST)
(interactive)
(let ((MINOR_MODE_LIST (delete MINOR_MODE MINOR_MODE_LIST)))
(mapcar (lambda (mode) (setq mode nil)) MINOR_MODE_LIST)
(setq MINOR_MODE t)))
I need to use it this way:
(activate-mode-in-list biblio-editing-mode latex-editing-mode)
because I want to use it to write a set of functions to be called with dedicated and consistent keybindings. Eg.
(defun activate-biblio-editing-mode ()
"Activate `biblio-editing-mode` and deactivate the other ones
setted in the `latex-editing-mode` variable"
(interactive)
(activate-mode-in-list biblio-editing-mode latex-editing-mode))
And then:
(require 'preamble-editing-mode)
(global-set-key (kbd "<C-M-kp-0>") 'activate-preamble-editing-mode)
(require 'biblio-editing-mode)
(global-set-key (kbd "<C-M-kp-1>") 'activate-biblio-editing-mode)
;; ...
(require 'proofs-editing-mode)
(global-set-key (kbd "<C-M-kp-9>") 'activate-proofs-editing-mode)
But my activate-mode-in-list
function doesn't work as I wrote it. I guess I'm getting lost in quoting stuff because evaluating:
(setq preamble-editing-mode nil)
(setq biblio-editing-mode t)
works as expected.
- Where am I doing wrong?
- Is there a better way to achieve my goal?
All I need is a function that activates a specific minor-mode and deactivate some other minor modes. I can store this set of minor modes in a variable.. In my workflow, "in most cases", only one minor mode of this set of minor modes should be active at a time (but in some cases I would have more then one active at the same time. In this case I'd open them in the standard way).