Skip to content

Instantly share code, notes, and snippets.

@lislon
Created July 25, 2016 10:54
Show Gist options
  • Select an option

  • Save lislon/66d696d6a41379806da49f0957dd9e16 to your computer and use it in GitHub Desktop.

Select an option

Save lislon/66d696d6a41379806da49f0957dd9e16 to your computer and use it in GitHub Desktop.
(defun my-count-maps (keymap depth)
(let ((count 0))
(cl-loop for touple in (cdr keymap)
;; touple == (27 keymap (9 . ispell-complete-word))
do
(progn
(if (eq (car-safe (cdr-safe touple)) 'keymap)
;; descent into sub keymap
(setq count (+ count
(my-count-maps (cdr touple) (1+ depth))))
;; else condition
(if (characterp (car-safe touple))
(progn
(setq count (1+ count))
(message "Map: %s%s %s" (make-string depth (string-to-char "-")) (char-to-string (car touple)) (cdr touple)))
(message "not character keymap %s" touple)))
;; (message "touple: %s" (car-safe touple))
))
;; return value
count))
(message "total: %d" (my-count-maps org-mode-map 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment