I currently have the following:
(defun my-hide-code ()
(interactive)
(set-selective-display 2))
(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
(define-key my-keys-minor-mode-map (kbd "<f2>") 'my-hide-code)
(define-minor-mode my-keys-minor-mode
"use"
t " my-keys" 'my-keys-minor-mode-map)
(my-keys-minor-mode 1)
Now, I want to toggle between
(set-selective-display 2)
and
(set-selective-display ‘nil)
Now, if I was in scheme, I would just create a s closure, and the closure would store a state variable, which would allow me to know which state I was in, and how to toggle.
However, Elisp is apparently a lisp-2 where variables and functions have different scope. Given this, how do I create closures / have be a toggle key?
selective-displayitself is the variable that contains the state you need to check, so you can writeAs for closures in general, I had need of them for a project long ago and resorted to inserting uninterned symbols into a function definition using backquote substitution to avoid global variables. E.g.
which when run produces
I guess this qualifies as a kludge, but I know of no other way to get anything like a closure in Emacs-Lisp.