Say I'm developing a minor mode
A that happens to need minor mode
B enabled during its lifetime.
The most straightforward way is to do something like:
(define-minor-mode A-mode :global t :lighter " A" (if A-mode (B-mode 1) (B-mode 0))) ; hooks here are added/removed...
(add-hook 'A-mode-hook 'B-mode)
The problem with these approaches is that the original status is not preserved. I could simply use a global variable to keep track of it but I was hoping to find a more elegant solution.
For example I can solve a similar issue involving variables like this:
(progn (setq foo 10) (print foo) ; 10 (let ((foo 42)) (print foo)) ; 42 (print foo)) ; 10
There is one more problem: the user could manually disable minor mode
B while minor mode
A is still on; and this shouldn't happen.
Probably is just bad practice to even require this behavior...
(FYI in my case minor mode