Emacs on OS X by default binds several keys with the super modifier. I do not want these bindings as I switch between OS X and Windows frequently, and want a clean slate on both platforms to bind super keys for my own purposes.
(defun global-unset-all-super-key () "Will unset any single key in global keymap that has the super modifier." (let ((km (current-global-map))) (while km (let ((maybe-event (and (listp (car km)) (caar km)))) (if (and (eventp maybe-event) ; Also filters out maybe-event ; when nil because (car km) was not a list. (memq 'super (event-modifiers maybe-event))) (global-unset-key (vector maybe-event)))) (setq km (cdr km))))) (provide 'global-unset-all-super-key)
Lines added to init.el.
;; Remove default super bindings on Mac systems. ;; Do this early, before any mappings are added. (when (string-equal system-type "darwin") (require 'global-unset-all-super-key) (global-unset-all-super-key))
- Is this reasonably idiomatic lisp?
- Are there elisp constructs that would simplify the implementation?
- Are there elisp constructs that would make the implementation clearer?
- And finally, is
(while <list> <body> (setq <list> (car <list>)))the best that can be done to loop over a list taking each element in turn and doing something for side effects?
mapdoesn't seem like a reasonable alternative because I'm not trying to build up a list to return. Something like Clojure's